Skip to content

Commit 569a9a9

Browse files
authored
Merge pull request #729 from acacode/format-code
Some chores
2 parents 7413b52 + fad6586 commit 569a9a9

File tree

61 files changed

+46601
-49039
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

61 files changed

+46601
-49039
lines changed

.github/workflows/main.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,5 +21,8 @@ jobs:
2121
- name: Install dependencies
2222
run: yarn install --immutable
2323

24+
- name: Check formatting
25+
run: yarn format:check
26+
2427
- name: Run the tests
2528
run: yarn test-all

biome.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,14 @@
33
"files": {
44
"ignore": [
55
"package.json",
6-
"tests/**/*.json",
76
"tests/**/expected.ts",
87
"tests/**/expected/**",
98
"tests/**/generated/**",
109
"tests/**/schema.d.ts",
1110
"tests/**/schema.js",
1211
"tests/**/schema.ts"
13-
]
12+
],
13+
"maxSize": 10000000
1414
},
1515
"formatter": {
1616
"enabled": true,

index.d.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ interface GenerateApiParamsBase {
88
*/
99
name?: string;
1010

11-
/**
11+
/**
1212
* name of the main exported class
1313
*/
1414
apiClassName?: string;
@@ -181,7 +181,7 @@ interface GenerateApiParamsBase {
181181
extractingOptions?: Partial<ExtractingOptions>;
182182

183183
/** configuration for fetching swagger schema requests */
184-
requestOptions?: null | Partial<import("node-fetch").RequestInit>;
184+
requestOptions?: null | Partial<RequestInit>;
185185

186186
/** ts compiler configuration object (for --to-js option) */
187187
compilerTsConfig?: Record<string, any>;
@@ -682,7 +682,7 @@ export interface GenerateApiConfiguration {
682682
};
683683
routeNameDuplicatesMap: Map<string, string>;
684684
apiClassName: string;
685-
requestOptions?: import("node-fetch").RequestInit;
685+
requestOptions?: RequestInit;
686686
extractingOptions: ExtractingOptions;
687687
};
688688
modelTypes: ModelType[];
@@ -697,7 +697,7 @@ export interface GenerateApiConfiguration {
697697
routes: ParsedRoute[];
698698
}[];
699699
};
700-
requestOptions?: null | Partial<import("node-fetch").RequestInit>;
700+
requestOptions?: null | Partial<RequestInit>;
701701
utils: {
702702
formatDescription: (description: string, inline?: boolean) => string;
703703
internalCase: (value: string) => string;

package.json

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -42,6 +42,8 @@
4242
"cli:help": "node index.js -h",
4343
"cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
4444
"cli:yaml": "node index.js -r -d -p ./swagger-test-cli.yaml -n swagger-test-cli.ts",
45+
"format": "biome format --write .",
46+
"format:check": "biome format .",
4547
"generate": "node tests/generate.js",
4648
"generate-extended": "node tests/generate-extended.js",
4749
"node": "node swagger-test-cli/generate.js",

templates/README.md

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
1-
# swagger-typescript-api
1+
# swagger-typescript-api
22

3-
# templates
3+
# templates
44

5-
Templates:
6-
- `api.ejs` - *(generates file)* Api class module (locations: [default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/api.ejs), [modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/api.ejs))
7-
- `data-contracts.ejs` - *(generates file)* all types (data contracts) from swagger schema (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contracts.ejs))
8-
- `http-client.ejs` - *(generates file)* HttpClient class module (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.ejs))
9-
- `procedure-call.ejs` - *(subtemplate)* route in Api class (locations: [default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/procedure-call.ejs), [modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/procedure-call.ejs))
10-
- `route-docs.ejs` - *(generates file)* documentation for route in Api class (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-docs.ejs))
11-
- `route-name.ejs` - *(subtemplate)* route name for route in Api class (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-name.ejs))
12-
- `route-type.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.ejs))
13-
- `route-types.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.ejs)) - `data-contract-jsdoc.ejs` - *(subtemplate)* generates JSDOC for data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contract-jsdoc.ejs))
5+
Templates:
146

15-
[//]: # (- `enum-data-contract.ejs` - *&#40;subtemplate&#41;* generates `enum` data contract &#40;locations: [base]&#40;https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/enum-data-contract.ejs&#41;&#41;)
16-
[//]: # (- `interface-data-contract.ejs` - *&#40;subtemplate&#41;* generates `interface` data contract &#40;locations: [base]&#40;https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/interface-data-contract.ejs&#41;&#41;)
17-
[//]: # (- `type-data-contract.ejs` - *&#40;subtemplate&#41;* generates `type` data contract &#40;locations: [base]&#40;https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/type-data-contract.ejs&#41;&#41;)
7+
- `api.ejs` - _(generates file)_ Api class module (locations: [default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/api.ejs), [modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/api.ejs))
8+
- `data-contracts.ejs` - _(generates file)_ all types (data contracts) from swagger schema (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contracts.ejs))
9+
- `http-client.ejs` - _(generates file)_ HttpClient class module (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.ejs))
10+
- `procedure-call.ejs` - _(subtemplate)_ route in Api class (locations: [default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/procedure-call.ejs), [modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/procedure-call.ejs))
11+
- `route-docs.ejs` - _(generates file)_ documentation for route in Api class (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-docs.ejs))
12+
- `route-name.ejs` - _(subtemplate)_ route name for route in Api class (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-name.ejs))
13+
- `route-type.ejs` - _(`--route-types` option)_ _(subtemplate)_ (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.ejs))
14+
- `route-types.ejs` - _(`--route-types` option)_ _(subtemplate)_ (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.ejs)) - `data-contract-jsdoc.ejs` - _(subtemplate)_ generates JSDOC for data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contract-jsdoc.ejs))
15+
16+
[//]: # "- `enum-data-contract.ejs` - *(subtemplate)* generates `enum` data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/enum-data-contract.ejs))"
17+
[//]: # "- `interface-data-contract.ejs` - *(subtemplate)* generates `interface` data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/interface-data-contract.ejs))"
18+
[//]: # "- `type-data-contract.ejs` - *(subtemplate)* generates `type` data contract (locations: [base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/type-data-contract.ejs))"

templates/base/README.md

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,7 @@
1-
# swagger-typescript-api
1+
# swagger-typescript-api
22

3-
# templates/base
3+
# templates/base
44

5-
This templates use both for multiple api files and single api file
5+
This templates use both for multiple api files and single api file
66

7-
8-
path prefix `@base`
7+
path prefix `@base`

templates/default/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# swagger-typescript-api
1+
# swagger-typescript-api
22

3-
# templates/default
3+
# templates/default
44

5-
This templates use for single api file (without `--modular` option)
5+
This templates use for single api file (without `--modular` option)
66

7-
path prefix `@default`
7+
path prefix `@default`

templates/modular/README.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
1-
# swagger-typescript-api
1+
# swagger-typescript-api
22

3-
# templates/modular
3+
# templates/modular
44

5-
This templates use for multiple api files (`--modular` option)
5+
This templates use for multiple api files (`--modular` option)
66

7-
path prefix `@modular`
7+
path prefix `@modular`

tests/README.md

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
1-
# swagger-typescript-api
1+
# swagger-typescript-api
22

3-
## 📃 EXAMPLES
3+
## 📃 EXAMPLES
44

5-
As you see above here is two folders:
6-
1. [**`schemas`**](./schemas) -
7-
- [**`v2.0`**](./schemas/v2.0) - schemas with Swagger 2.0
8-
- [**`v3.0`**](./schemas/v3.0) - schemas with OA 3.0
9-
1. [**`generated`**](./generated) -
10-
- [**`v2.0`**](./generated/v2.0) - generated api modules for Swagger 2.0 schemas from above folder
11-
- [**`v3.0`**](./generated/v3.0) - generated api modules for OA 3.0 schemas from above folder
5+
As you see above here is two folders:
126

7+
1. [**`schemas`**](./schemas) -
8+
- [**`v2.0`**](./schemas/v2.0) - schemas with Swagger 2.0
9+
- [**`v3.0`**](./schemas/v3.0) - schemas with OA 3.0
10+
1. [**`generated`**](./generated) -
11+
- [**`v2.0`**](./generated/v2.0) - generated api modules for Swagger 2.0 schemas from above folder
12+
- [**`v3.0`**](./generated/v3.0) - generated api modules for OA 3.0 schemas from above folder
1313

14-
Most schemas taken from [apis.guru](https://apis.guru/openapi-directory/), [swagger.io github repo](https://swagger.io/), [Github api description](https://github.com/github/rest-api-description) and [up-banking](https://github.com/up-banking/api)
14+
Most schemas taken from [apis.guru](https://apis.guru/openapi-directory/), [swagger.io github repo](https://swagger.io/), [Github api description](https://github.com/github/rest-api-description) and [up-banking](https://github.com/up-banking/api)

tests/schemas/v2.0/another-example.json

Lines changed: 14 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,10 @@
225225
}
226226
],
227227
"security": [],
228-
"consumes": ["application/x-www-form-urlencoded", "multipart/form-data"],
228+
"consumes": [
229+
"application/x-www-form-urlencoded",
230+
"multipart/form-data"
231+
],
229232
"tags": ["pet"]
230233
}
231234
},
@@ -263,7 +266,10 @@
263266
}
264267
],
265268
"security": [],
266-
"consumes": ["multipart/form-data", "application/x-www-form-urlencoded"],
269+
"consumes": [
270+
"multipart/form-data",
271+
"application/x-www-form-urlencoded"
272+
],
267273
"tags": ["pet"]
268274
}
269275
},
@@ -996,7 +1002,12 @@
9961002
},
9971003
"PetNames": {
9981004
"type": "string",
999-
"enum": ["Fluffy Hero", "Piggy Po", "Swagger Typescript Api", "UPPER_CASE"]
1005+
"enum": [
1006+
"Fluffy Hero",
1007+
"Piggy Po",
1008+
"Swagger Typescript Api",
1009+
"UPPER_CASE"
1010+
]
10001011
},
10011012
"PetIds": {
10021013
"type": "integer",

0 commit comments

Comments
 (0)