Skip to content

Commit e8ffa3f

Browse files
js2meApacheEx
andauthored
Release 10.0.2 (#419)
* fix: problem with default http request headers in axios client * feat: improve type declaration for inline types; fix: nullable option for objects * fix: problem with sortTypes option; docs: update CHANGELOG * docs: update README linked with custom templates * feat: separate data-contracts.ejs onto 4 pieces (enum, interface, type, jsdoc) * fix createFormData code duplication (#392) * chore: add title for DC in jsdoc; internal: add templates for future improvements * fix: problem with host.fileExists is not a function chore: set all deps as fixed versions * fix: order of headers in fetch http client * fix: max file size for axios (fetching swagger file) * fix: fs.rmSync usage * fix: getNewLine, readFile in LanguageServicehost (ts) * docs: add docs for unwrapResponseData flag * fix: problems with nested required properties based with upper required properties * chore: refresh test generated schemas * bump: up version to 10.0.3, update CHANGELOG * docs: update changelog Co-authored-by: Oleg Kuzava <[email protected]>
1 parent 3886119 commit e8ffa3f

File tree

130 files changed

+28420
-11464
lines changed

Some content is hidden

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

130 files changed

+28420
-11464
lines changed

.prettierignore

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,7 @@ node_modules
1010
.openapi-generator
1111
.vscode
1212
assets
13-
templates
13+
templates
14+
*.yml
15+
*.yaml
16+
*.json

CHANGELOG.md

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,27 @@
11
# next release
22

3+
# 10.0.2
4+
5+
fix: host.fileExists is not a function
6+
fix: other problems linked with new typescript version (4.8.*) (thanks @elkeis, @Jnig)
7+
fix: problem with required nested properties based on root required properties list
8+
fix: fetch http client headers content type priority
9+
fix: fs.rmSync (thanks @smorimoto)
10+
fix: locally overridden security schemes (security flag) (#418, thanks @EdwardSalter)
11+
docs: add documentation for `unwrapResponseData` nodejs option (thanks @simowe)
12+
BREAKING_CHANGE: rename `.eta` file extensions to `.ejs`. Backward capability should be existed.
13+
fix: problem with `--sort-types` option
14+
15+
# 10.0.*
16+
17+
fix: problem with default http request headers in axios client
18+
319
# 10.0.1
420

521
- fix problem linked with [this.name is not a function](https://github.com/acacode/swagger-typescript-api/issues/381)
622
- [internal] add cli tests
7-
- fix problem with not correct working the `--no-client` option
23+
- fix problem with not correct working the `--no-client` option
24+
- separate data-contracts.ejs onto 4 pieces (enum, interface, type, jsdoc)
825

926
# 10.0.0
1027

README.md

Lines changed: 25 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -107,6 +107,7 @@ generateApi({
107107
toJS: false,
108108
extractRequestParams: false,
109109
extractRequestBody: false,
110+
unwrapResponseData: false,
110111
prettier: { // By default prettier config is load from your project
111112
printWidth: 120,
112113
tabWidth: 2,
@@ -145,16 +146,23 @@ generateApi({
145146
## 💎 options
146147
### **`--templates`**
147148
This option needed for cases when you don't want to use the default `swagger-typescript-api` output structure
149+
You can create custom templates with extensions `.ejs` or `.eta`
148150

149151
Templates:
150-
- `api.eta` - Api class module (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/api.eta), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/api.eta))
151-
- `data-contracts.eta` - all types (data contracts) from swagger schema (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contracts.eta))
152-
- `http-client.eta` - HttpClient class module (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.eta))
153-
- `procedure-call.eta` - route in Api class (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/procedure-call.eta), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/procedure-call.eta))
154-
- `route-docs.eta` - documentation for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-docs.eta))
155-
- `route-name.eta` - route name for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-name.eta))
156-
- `route-type.eta` - *(`--route-types` option)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.eta))
157-
- `route-types.eta` - *(`--route-types` option)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.eta))
152+
- `api.ejs` - *(generates file)* Api class module (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/api.ejs), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/api.ejs))
153+
- `data-contracts.ejs` - *(generates file)* all types (data contracts) from swagger schema (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contracts.ejs))
154+
- `http-client.ejs` - *(generates file)* HttpClient class module (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.ejs))
155+
- `procedure-call.ejs` - *(subtemplate)* route in Api class (locations: [/templates/default](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default/procedure-call.ejs), [/templates/modular](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular/procedure-call.ejs))
156+
- `route-docs.ejs` - *(generates file)* documentation for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-docs.ejs))
157+
- `route-name.ejs` - *(subtemplate)* route name for route in Api class (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-name.ejs))
158+
- `route-type.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.ejs))
159+
- `route-types.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.ejs))
160+
- `data-contract-jsdoc.ejs` - *(subtemplate)* generates JSDOC for data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contract-jsdoc.ejs))
161+
162+
[//]: # (- `enum-data-contract.ejs` - *&#40;subtemplate&#41;* generates `enum` data contract &#40;locations: [/templates/base]&#40;https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/enum-data-contract.ejs&#41;&#41;)
163+
[//]: # (- `interface-data-contract.ejs` - *&#40;subtemplate&#41;* generates `interface` data contract &#40;locations: [/templates/base]&#40;https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/interface-data-contract.ejs&#41;&#41;)
164+
[//]: # (- `type-data-contract.ejs` - *&#40;subtemplate&#41;* generates `type` data contract &#40;locations: [/templates/base]&#40;https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/type-data-contract.ejs&#41;&#41;)
165+
158166

159167
How to use it:
160168
1. copy `swagger-typescript-api` templates into your place in project
@@ -171,15 +179,15 @@ NOTE:
171179
`@default` - [path to single api file templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default)
172180
`@modular` - [path to multiple api files templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular)
173181
Examples:
174-
- `includeFile("@base/data-contracts.eta", configuration)`
175-
- `includeFile("@default/api.eta", configuration)`
176-
- `includeFile("@default/procedure-call.eta", configuration)`
177-
- `includeFile("@modular/api.eta", configuration)`
178-
- `includeFile("@modular/procedure-call.eta", configuration)`
179-
- `includeFile("@base/route-docs.eta", configuration)`
180-
- `includeFile("@base/route-name.eta", configuration)`
181-
- `includeFile("@base/route-type.eta", configuration)`
182-
- `includeFile("@base/route-types.eta", configuration)`
182+
- `includeFile("@base/data-contracts.ejs", { ...yourData, ...it })`
183+
- `includeFile("@default/api.ejs", { ...yourData, ...it })`
184+
- `includeFile("@default/procedure-call.ejs", { ...yourData, ...it })`
185+
- `includeFile("@modular/api.ejs", { ...yourData, ...it })`
186+
- `includeFile("@modular/procedure-call.ejs", { ...yourData, ...it })`
187+
- `includeFile("@base/route-docs.ejs", { ...yourData, ...it })`
188+
- `includeFile("@base/route-name.ejs", { ...yourData, ...it })`
189+
- `includeFile("@base/route-type.ejs", { ...yourData, ...it })`
190+
- `includeFile("@base/route-types.ejs", { ...yourData, ...it })`
183191

184192
### **`--module-name-index`**
185193
This option should be used in cases when you have api with one global prefix like `/api`

index.d.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,11 @@ interface GenerateApiParamsBase {
4444
*/
4545
generateResponses?: boolean;
4646

47+
/**
48+
* unwrap the data item from the response
49+
*/
50+
unwrapResponseData?: boolean;
51+
4752
/**
4853
* generate js api module with declaration file (default: false)
4954
*/
@@ -329,6 +334,7 @@ export interface GenerateApiConfiguration {
329334
disableStrictSSL: boolean;
330335
disableProxy: boolean;
331336
extractRequestParams: boolean;
337+
unwrapResponseData: boolean;
332338
fileNames: {
333339
dataContracts: string;
334340
routeTypes: string;
@@ -343,7 +349,7 @@ export interface GenerateApiConfiguration {
343349
routeName: string;
344350
};
345351
routeNameDuplicatesMap: Map<string, string>;
346-
apiClassName: string
352+
apiClassName: string;
347353
};
348354
modelTypes: ModelType[];
349355
rawModelTypes: SchemaComponent[];

index.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ const options = program
6767
.option("--clean-output", "clean output folder before generate api. WARNING: May cause data loss", false)
6868
.option("--api-class-name <string>", "name of the api class")
6969
.option("--patch", "fix up small errors in the swagger source definition", false)
70+
.option("--debug", "additional information about processes inside this tool", false)
7071
.parse(process.argv)
7172
.opts();
7273

@@ -105,6 +106,7 @@ generateApi({
105106
typeSuffix: options.typeSuffix,
106107
patch: !!options.patch,
107108
apiClassName: options.apiClassName,
109+
debug: options.debug,
108110
}).catch((err) => {
109111
// NOTE collect all errors on top level and shows to users in any case
110112
console.error(err);

0 commit comments

Comments
 (0)