Skip to content

Release 10.0.2 #419

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Oct 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
94087ec
fix: problem with default http request headers in axios client
js2me Aug 16, 2022
edf5044
feat: improve type declaration for inline types; fix: nullable option…
js2me Aug 17, 2022
73c6eec
fix: problem with sortTypes option; docs: update CHANGELOG
js2me Aug 17, 2022
498b75f
Merge remote-tracking branch 'origin/master' into next
js2me Aug 17, 2022
619e738
docs: update README linked with custom templates
js2me Aug 17, 2022
13221be
feat: separate data-contracts.ejs onto 4 pieces (enum, interface, typ…
js2me Aug 17, 2022
804e6e9
fix createFormData code duplication (#392)
ApacheEx Aug 18, 2022
09494a2
chore: add title for DC in jsdoc; internal: add templates for future …
js2me Aug 29, 2022
ad3ff91
Merge remote-tracking branch 'origin/next' into next
js2me Aug 29, 2022
f347040
Merge remote-tracking branch 'origin/master' into next
js2me Aug 29, 2022
80236cb
fix: problem with host.fileExists is not a function
js2me Oct 15, 2022
1f76852
fix: order of headers in fetch http client
js2me Oct 15, 2022
ee581c3
fix: max file size for axios (fetching swagger file)
js2me Oct 15, 2022
48c10c9
fix: fs.rmSync usage
js2me Oct 15, 2022
e89acaa
fix: getNewLine, readFile in LanguageServicehost (ts)
js2me Oct 15, 2022
69f7004
docs: add docs for unwrapResponseData flag
js2me Oct 15, 2022
2940475
fix: problems with nested required properties based with upper requir…
js2me Oct 15, 2022
4f51404
chore: refresh test generated schemas
js2me Oct 15, 2022
7e4b32b
bump: up version to 10.0.3, update CHANGELOG
js2me Oct 15, 2022
21ab2a4
docs: update changelog
js2me Oct 15, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion .prettierignore
Original file line number Diff line number Diff line change
Expand Up @@ -10,4 +10,7 @@ node_modules
.openapi-generator
.vscode
assets
templates
templates
*.yml
*.yaml
*.json
19 changes: 18 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,27 @@
# next release

# 10.0.2

fix: host.fileExists is not a function
fix: other problems linked with new typescript version (4.8.*) (thanks @elkeis, @Jnig)
fix: problem with required nested properties based on root required properties list
fix: fetch http client headers content type priority
fix: fs.rmSync (thanks @smorimoto)
fix: locally overridden security schemes (security flag) (#418, thanks @EdwardSalter)
docs: add documentation for `unwrapResponseData` nodejs option (thanks @simowe)
BREAKING_CHANGE: rename `.eta` file extensions to `.ejs`. Backward capability should be existed.
fix: problem with `--sort-types` option

# 10.0.*

fix: problem with default http request headers in axios client

# 10.0.1

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

# 10.0.0

Expand Down
42 changes: 25 additions & 17 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,7 @@ generateApi({
toJS: false,
extractRequestParams: false,
extractRequestBody: false,
unwrapResponseData: false,
prettier: { // By default prettier config is load from your project
printWidth: 120,
tabWidth: 2,
Expand Down Expand Up @@ -145,16 +146,23 @@ generateApi({
## 💎 options
### **`--templates`**
This option needed for cases when you don't want to use the default `swagger-typescript-api` output structure
You can create custom templates with extensions `.ejs` or `.eta`

Templates:
- `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))
- `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))
- `http-client.eta` - HttpClient class module (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/http-client.eta))
- `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))
- `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))
- `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))
- `route-type.eta` - *(`--route-types` option)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.eta))
- `route-types.eta` - *(`--route-types` option)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-types.eta))
- `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))
- `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))
- `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))
- `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))
- `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))
- `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))
- `route-type.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/route-type.ejs))
- `route-types.ejs` - *(`--route-types` option)* *(subtemplate)* (locations: [/templates/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: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/data-contract-jsdoc.ejs))

[//]: # (- `enum-data-contract.ejs` - *(subtemplate)* generates `enum` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/enum-data-contract.ejs)))
[//]: # (- `interface-data-contract.ejs` - *(subtemplate)* generates `interface` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/interface-data-contract.ejs)))
[//]: # (- `type-data-contract.ejs` - *(subtemplate)* generates `type` data contract (locations: [/templates/base](https://github.com/acacode/swagger-typescript-api/tree/next/templates/base/type-data-contract.ejs)))


How to use it:
1. copy `swagger-typescript-api` templates into your place in project
Expand All @@ -171,15 +179,15 @@ NOTE:
`@default` - [path to single api file templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/default)
`@modular` - [path to multiple api files templates](https://github.com/acacode/swagger-typescript-api/tree/next/templates/modular)
Examples:
- `includeFile("@base/data-contracts.eta", configuration)`
- `includeFile("@default/api.eta", configuration)`
- `includeFile("@default/procedure-call.eta", configuration)`
- `includeFile("@modular/api.eta", configuration)`
- `includeFile("@modular/procedure-call.eta", configuration)`
- `includeFile("@base/route-docs.eta", configuration)`
- `includeFile("@base/route-name.eta", configuration)`
- `includeFile("@base/route-type.eta", configuration)`
- `includeFile("@base/route-types.eta", configuration)`
- `includeFile("@base/data-contracts.ejs", { ...yourData, ...it })`
- `includeFile("@default/api.ejs", { ...yourData, ...it })`
- `includeFile("@default/procedure-call.ejs", { ...yourData, ...it })`
- `includeFile("@modular/api.ejs", { ...yourData, ...it })`
- `includeFile("@modular/procedure-call.ejs", { ...yourData, ...it })`
- `includeFile("@base/route-docs.ejs", { ...yourData, ...it })`
- `includeFile("@base/route-name.ejs", { ...yourData, ...it })`
- `includeFile("@base/route-type.ejs", { ...yourData, ...it })`
- `includeFile("@base/route-types.ejs", { ...yourData, ...it })`

### **`--module-name-index`**
This option should be used in cases when you have api with one global prefix like `/api`
Expand Down
8 changes: 7 additions & 1 deletion index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,11 @@ interface GenerateApiParamsBase {
*/
generateResponses?: boolean;

/**
* unwrap the data item from the response
*/
unwrapResponseData?: boolean;

/**
* generate js api module with declaration file (default: false)
*/
Expand Down Expand Up @@ -329,6 +334,7 @@ export interface GenerateApiConfiguration {
disableStrictSSL: boolean;
disableProxy: boolean;
extractRequestParams: boolean;
unwrapResponseData: boolean;
fileNames: {
dataContracts: string;
routeTypes: string;
Expand All @@ -343,7 +349,7 @@ export interface GenerateApiConfiguration {
routeName: string;
};
routeNameDuplicatesMap: Map<string, string>;
apiClassName: string
apiClassName: string;
};
modelTypes: ModelType[];
rawModelTypes: SchemaComponent[];
Expand Down
2 changes: 2 additions & 0 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,7 @@ const options = program
.option("--clean-output", "clean output folder before generate api. WARNING: May cause data loss", false)
.option("--api-class-name <string>", "name of the api class")
.option("--patch", "fix up small errors in the swagger source definition", false)
.option("--debug", "additional information about processes inside this tool", false)
.parse(process.argv)
.opts();

Expand Down Expand Up @@ -105,6 +106,7 @@ generateApi({
typeSuffix: options.typeSuffix,
patch: !!options.patch,
apiClassName: options.apiClassName,
debug: options.debug,
}).catch((err) => {
// NOTE collect all errors on top level and shows to users in any case
console.error(err);
Expand Down
Loading