swagger-typescript-api 11.0.0--beta-6 → 11.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -8,6 +8,10 @@
8
8
  - new codebase (class way)
9
9
  - ability to change everything in codegen process configuration with using NodeJS Api
10
10
  - ability to call `generateApi` function 2 and more times per 1 NodeJS process.
11
+ - new command `generate-templates` to create source templates
12
+
13
+ ## [feature] Ability to generate source templates
14
+ New command `generate-templates` which allow you to generate source templates which using with option `--templates`
11
15
 
12
16
  ## [feature] Ability to modify internal codegen typescript structs
13
17
  Everything which creates codegen about output typescript code now contains in `Ts` field in [`src/configuration`](src/configuration.js).
package/README.md CHANGED
@@ -34,6 +34,7 @@ All examples you can find [**here**](https://github.com/acacode/swagger-typescri
34
34
  ```muse
35
35
  Usage: sta [options]
36
36
  Usage: swagger-typescript-api [options]
37
+ Usage: swagger-typescript-api generate-templates [options]
37
38
 
38
39
  Options:
39
40
  -v, --version output the current version
@@ -73,7 +74,18 @@ Options:
73
74
  --patch fix up small errors in the swagger source definition (default: false)
74
75
  --debug additional information about processes inside this tool (default: false)
75
76
  --another-array-type generate array types as Array<Type> (by default Type[]) (default: false)
77
+ --sort-types sort fields and types (default: false)
76
78
  -h, --help display help for command
79
+
80
+ Commands:
81
+ generate-templates Generate ".ejs" templates needed for generate api
82
+ -o, --output <string> output path of generated templates
83
+ -m, --modular generate templates needed to separate files for http client, data contracts, and routes (default: false)
84
+ --http-client <string> http client type (possible values: "fetch", "axios") (default: "fetch")
85
+ -c, --clean-output clean output folder before generate template. WARNING: May cause data loss (default: false)
86
+ -r, --rewrite rewrite content in existing templates (default: false)
87
+ --silent Output only errors to console (default: false)
88
+ -h, --help display help for command
77
89
  ```
78
90
 
79
91
  Also you can use `npx`:
@@ -83,7 +95,7 @@ Also you can use `npx`:
83
95
 
84
96
  You can use this package from nodejs:
85
97
  ```js
86
- const { generateApi } = require('swagger-typescript-api');
98
+ const { generateApi, generateTemplates } = require('swagger-typescript-api');
87
99
  const path = require("path");
88
100
  const fs = require("fs");
89
101
 
@@ -158,6 +170,16 @@ generateApi({
158
170
  })
159
171
  .catch(e => console.error(e))
160
172
 
173
+
174
+ generateTemplates({
175
+ cleanOutput: false,
176
+ output: PATH_TO_OUTPUT_DIR,
177
+ httpClientType: "fetch",
178
+ modular: false,
179
+ silent: false,
180
+ rewrite: false,
181
+ })
182
+
161
183
  ```
162
184
 
163
185
 
@@ -220,6 +242,9 @@ When we change it to `--module-name-index 1` then Api class have two properties
220
242
  This option will group your API operations based on their first tag - mirroring how the Swagger UI groups displayed operations
221
243
 
222
244
 
245
+ ## `generate-templates` command
246
+ This command allows you to generate source templates which using with option `--templates`
247
+
223
248
  ## Modification internal codegen structs with NodeJS API:
224
249
 
225
250
  You are able to modify TypeScript internal structs using for generating output with using `generateApi` options `codeGenConstructs` and `primitiveTypeConstructs`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "swagger-typescript-api",
3
- "version": "11.0.0--beta-6",
3
+ "version": "11.0.0",
4
4
  "description": "Generate typescript/javascript api from swagger schema",
5
5
  "scripts": {
6
6
  "cli:json": "node index.js -r -d -p ./swagger-test-cli.json -n swagger-test-cli.ts",
@@ -66,7 +66,7 @@ class TemplatesGenProcess {
66
66
  });
67
67
  }
68
68
  });
69
- this.logger.event(`source templates has been successfully created in "${outputPath}"`);
69
+ this.logger.success(`source templates has been successfully created in "${outputPath}"`);
70
70
  }
71
71
 
72
72
  return {