swagger-typescript-api 13.2.8 → 13.2.10
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 +30 -0
- package/dist/cli.cjs +1 -1
- package/dist/cli.cjs.map +1 -1
- package/dist/cli.js +2 -1
- package/dist/cli.js.map +1 -1
- package/dist/lib.cjs +3 -1
- package/dist/lib.d.cts +226 -11
- package/dist/lib.d.ts +226 -11
- package/dist/lib.js +2 -2
- package/dist/{src-BtVFSrff.cjs → src-C5bMYV9w.cjs} +130 -80
- package/dist/src-C5bMYV9w.cjs.map +1 -0
- package/dist/{src-4gUT3jPg.js → src-s8addnrG.js} +183 -152
- package/dist/src-s8addnrG.js.map +1 -0
- package/package.json +12 -12
- package/templates/base/http-clients/fetch-http-client.ejs +1 -1
- package/dist/src-4gUT3jPg.js.map +0 -1
- package/dist/src-BtVFSrff.cjs.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,35 @@
|
|
|
1
1
|
# swagger-typescript-api
|
|
2
2
|
|
|
3
|
+
## 13.2.10
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`7b7351f`](https://github.com/acacode/swagger-typescript-api/commit/7b7351f90b250f7702cb57976c5c293ede353312) Thanks [@js2me](https://github.com/js2me)! - fix missing exported interfaces and types
|
|
8
|
+
|
|
9
|
+
## 13.2.9
|
|
10
|
+
|
|
11
|
+
### Patch Changes
|
|
12
|
+
|
|
13
|
+
- [#1384](https://github.com/acacode/swagger-typescript-api/pull/1384) [`0caea2c`](https://github.com/acacode/swagger-typescript-api/commit/0caea2c9c1132b2ba5e74ec51d9cb12b73e32f5e) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix enum const parsing for substrings of primitive types.
|
|
14
|
+
|
|
15
|
+
- [#1381](https://github.com/acacode/swagger-typescript-api/pull/1381) [`ba052f4`](https://github.com/acacode/swagger-typescript-api/commit/ba052f4038b53358381caa0a20d1edc07a59e7bd) Thanks [@smorimoto](https://github.com/smorimoto)! - Support extracting request parameters for routes that only declare path parameters, such as `DELETE` methods.
|
|
16
|
+
|
|
17
|
+
- [#1382](https://github.com/acacode/swagger-typescript-api/pull/1382) [`792e96c`](https://github.com/acacode/swagger-typescript-api/commit/792e96c44255bd5e2f26a5043959a9e1693df896) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix enum string value quoting when schema type mismatches.
|
|
18
|
+
|
|
19
|
+
- [#1385](https://github.com/acacode/swagger-typescript-api/pull/1385) [`859fc64`](https://github.com/acacode/swagger-typescript-api/commit/859fc64aa4fd58f024d17d516cb82c916abacfe6) Thanks [@smorimoto](https://github.com/smorimoto)! - Avoid response cloning in fetch HTTP client to prevent memory leaks (#779).
|
|
20
|
+
|
|
21
|
+
- [#1383](https://github.com/acacode/swagger-typescript-api/pull/1383) [`8191970`](https://github.com/acacode/swagger-typescript-api/commit/8191970c479d24236c80b5068bcab2f5f10597cd) Thanks [@smorimoto](https://github.com/smorimoto)! - Automatically extract enums when using enum names as values.
|
|
22
|
+
|
|
23
|
+
- [#1376](https://github.com/acacode/swagger-typescript-api/pull/1376) [`bec35e8`](https://github.com/acacode/swagger-typescript-api/commit/bec35e8b885a6b69dceec06487690f1ea81dbea0) Thanks [@smorimoto](https://github.com/smorimoto)! - Merge `GenerateApiParamsBase` into `GenerateApiConfiguration` to remove duplicated type definitions and expose missing configuration fields. Document configuration defaults with JSDoc tags.
|
|
24
|
+
|
|
25
|
+
- [#1378](https://github.com/acacode/swagger-typescript-api/pull/1378) [`912e521`](https://github.com/acacode/swagger-typescript-api/commit/912e5217868973943197b03dd67b26108e430c6f) Thanks [@smorimoto](https://github.com/smorimoto)! - Allow partial `extractingOptions` in `generateApi` configuration.
|
|
26
|
+
|
|
27
|
+
- [#1380](https://github.com/acacode/swagger-typescript-api/pull/1380) [`fec0a09`](https://github.com/acacode/swagger-typescript-api/commit/fec0a09774512d7254bbc5bbebee22858812adb8) Thanks [@smorimoto](https://github.com/smorimoto)! - Add test verifying primitive + object `anyOf` unions.
|
|
28
|
+
|
|
29
|
+
- [#1376](https://github.com/acacode/swagger-typescript-api/pull/1376) [`bec35e8`](https://github.com/acacode/swagger-typescript-api/commit/bec35e8b885a6b69dceec06487690f1ea81dbea0) Thanks [@smorimoto](https://github.com/smorimoto)! - Restore `modular` option typing in `generateApi` parameters.
|
|
30
|
+
|
|
31
|
+
- [#1379](https://github.com/acacode/swagger-typescript-api/pull/1379) [`339a167`](https://github.com/acacode/swagger-typescript-api/commit/339a167d5dc46e128d8e960490c701fb85aa4cef) Thanks [@smorimoto](https://github.com/smorimoto)! - Support synchronous `require` in templates using Node's `createRequire`.
|
|
32
|
+
|
|
3
33
|
## 13.2.8
|
|
4
34
|
|
|
5
35
|
### Patch Changes
|
package/dist/cli.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
const require_src = require('./src-
|
|
2
|
+
const require_src = require('./src-C5bMYV9w.cjs');
|
|
3
3
|
const node_path = require_src.__toESM(require("node:path"));
|
|
4
4
|
const c12 = require_src.__toESM(require("c12"));
|
|
5
5
|
const citty = require_src.__toESM(require("citty"));
|
package/dist/cli.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.cjs","names":["TemplatesGenConfig","HTTP_CLIENT","CodeGenConfig","packageJson"],"sources":["../index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { defineCommand, runMain } from \"citty\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { GenerateApiParams, HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n client: {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-request-params\": {\n type: \"boolean\",\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n \"generate-union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger schema\",\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n },\n run: async ({ args }) => {\n const customConfig = await loadConfig<GenerateApiParams>({\n name: \"swagger-typescript-api\",\n configFile: args[\"custom-config\"],\n });\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: args.client,\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"generate-union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig.config,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB,IAAIA,+BAAmB,CAAE;AAEvD,MAAM,2BAA2B,yBAAc;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;CACd;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;EAChC;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;EAChC;EACD,eAAe;GACb,MAAM;GACN,cAAc,qCAAqC,OAAO,OACxDC,wBACD,CAAC;GACF,SAAS,sBAAsB;EAChC;EACD,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;EAChC;EACD,QAAQ;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;EAChC;EACD,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;EAChC;EACD,QAAQ;GACN,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;EAChC;CACF;CACD,KAAK,OAAO,EAAE,MAAM,KAAK;AACvB,QAAM,8BAAkB;GACtB,aAAa,KAAK;GAClB,gBAAgB,KAAK;GACrB,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,OAAO,KAAK;EACb,EAAC;CACH;AACF,EAAC;AAEF,MAAM,oBAAoB,IAAIC,0BAAc,CAAE;AAE9C,MAAM,kBAAkB,yBAAc;CACpC,MAAM;EACJ,MAAM;EACN,aAAaC,4BAAY;CAC1B;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aAAa;GACb,SAAS,kBAAkB;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ClB,OAAO,KAAK;GACZ,0BAA0B,KAAK;GAC/B,qBAAqB,KAAK;GAC1B,qBAAqB,KAAK;GAC1B,mBAAmB,KAAK;GACxB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GACzB,sBAAsB,KAAK;GAC3B,qBAAqB,KAAK;GAC1B,sBAAsB,KAAK;GAC3B,kBAAkB,KAAK;GACvB,UAAU,KAAK;GACf,gBAAgB,KAAK;GACrB,mBAAmB,KAAK;GACxB,oBAAoB,KAAK;GACzB,oBAAoB,KAAK;GACzB,gBACE,KAAK,kBAAkB,KAAK,QACxBA,wBAAY,QACZA,wBAAY;GAClB,OAAO,UAAK,QAAQ,QAAQ,KAAK,EAAE,KAAK,KAAe;GACvD,SAAS,KAAK;GACd,oBAAoB,KAAK;GACzB,kBAAkB,KAAK,wBAAwB;GAC/C,QAAQ,UAAK,QAAQ,QAAQ,KAAK,EAAG,KAAK,UAAqB,IAAI;GACnE,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,kBAAkB,KAAK;GACvB,YAAY,KAAK;GACjB,WAAW,KAAK;GAChB,WAAW,KAAK;GAChB,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,YAAY,KAAK;GACjB,oBAAoB,KAAK;GACzB,KAAK,KAAK;GACV,GAAG,aAAa;EACjB,EAAC;CACH;AACF,EAAC;AAEF,MAAM,OAAO,yBAAc;CACzB,MAAM;EACJ,MAAME,4BAAY;EAClB,aAAaA,4BAAY;EACzB,SAASA,4BAAY;CACtB;CACD,aAAa;EACX,UAAU;EACV,sBAAsB;CACvB;AACF,EAAC;AAEF,mBAAQ,KAAK"}
|
|
1
|
+
{"version":3,"file":"cli.cjs","names":["TemplatesGenConfig","HTTP_CLIENT","generateTemplates","CodeGenConfig","packageJson","generateApi","path"],"sources":["../index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { defineCommand, runMain } from \"citty\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { GenerateApiParams, HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n client: {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-request-params\": {\n type: \"boolean\",\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n \"generate-union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger schema\",\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n },\n run: async ({ args }) => {\n const customConfig = await loadConfig<GenerateApiParams>({\n name: \"swagger-typescript-api\",\n configFile: args[\"custom-config\"],\n });\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: args.client,\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"generate-union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig.config,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB,IAAIA,+BAAmB;AAErD,MAAM,oDAAyC;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;;CAEf,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;;EAEjC,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;;EAEjC,eAAe;GACb,MAAM;GACN,aAAa,sCAAsC,OAAO,OACxDC,yBACA;GACF,SAAS,sBAAsB;;EAEjC,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;;EAEjC,QAAQ;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;;EAEjC,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;;EAEjC,QAAQ;GACN,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;;;CAGnC,KAAK,OAAO,EAAE,WAAW;AACvB,QAAMC,8BAAkB;GACtB,aAAa,KAAK;GAClB,gBAAgB,KAAK;GACrB,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,OAAO,KAAK;;;;AAKlB,MAAM,oBAAoB,IAAIC,0BAAc;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,KAAK;GAC/B,qBAAqB,KAAK;GAC1B,qBAAqB,KAAK;GAC1B,mBAAmB,KAAK;GACxB,cAAc,KAAK;GACnB,oBAAoB,KAAK;GACzB,sBAAsB,KAAK;GAC3B,qBAAqB,KAAK;GAC1B,sBAAsB,KAAK;GAC3B,kBAAkB,KAAK;GACvB,UAAU,KAAK;GACf,gBAAgB,KAAK;GACrB,mBAAmB,KAAK;GACxB,oBAAoB,KAAK;GACzB,oBAAoB,KAAK;GACzB,gBACE,KAAK,kBAAkB,KAAK,QACxBJ,wBAAY,QACZA,wBAAY;GAClB,OAAOK,UAAK,QAAQ,QAAQ,OAAO,KAAK;GACxC,SAAS,KAAK;GACd,oBAAoB,KAAK;GACzB,iBAAiB,CAAC,KAAK,wBAAwB;GAC/C,QAAQA,UAAK,QAAQ,QAAQ,OAAQ,KAAK,UAAqB;GAC/D,OAAO,KAAK;GACZ,QAAQ,KAAK;GACb,kBAAkB,KAAK;GACvB,YAAY,KAAK;GACjB,WAAW,KAAK;GAChB,WAAW,KAAK;GAChB,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,YAAY,KAAK;GACjB,oBAAoB,KAAK;GACzB,KAAK,KAAK;GACV,GAAG,aAAa;;;;AAKtB,MAAM,gCAAqB;CACzB,MAAM;EACJ,MAAMF,4BAAY;EAClB,aAAaA,4BAAY;EACzB,SAASA,4BAAY;;CAEvB,aAAa;EACX,UAAU;EACV,sBAAsB;;;mBAIlB"}
|
package/dist/cli.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-
|
|
2
|
+
import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-s8addnrG.js";
|
|
3
3
|
import * as path$1 from "node:path";
|
|
4
4
|
import { loadConfig } from "c12";
|
|
5
5
|
import { defineCommand, runMain } from "citty";
|
|
@@ -323,4 +323,5 @@ const main = defineCommand({
|
|
|
323
323
|
runMain(main);
|
|
324
324
|
|
|
325
325
|
//#endregion
|
|
326
|
+
export { };
|
|
326
327
|
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"cli.js","names":["packageJson"],"sources":["../index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { defineCommand, runMain } from \"citty\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { GenerateApiParams, HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n client: {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-request-params\": {\n type: \"boolean\",\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n \"generate-union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger schema\",\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n },\n run: async ({ args }) => {\n const customConfig = await loadConfig<GenerateApiParams>({\n name: \"swagger-typescript-api\",\n configFile: args[\"custom-config\"],\n });\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: args.client,\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"generate-union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig.config,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB,IAAI,mBAAmB,CAAE;AAEvD,MAAM,2BAA2B,cAAc;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;CACd;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;EAChC;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;EAChC;EACD,eAAe;GACb,MAAM;GACN,cAAc,qCAAqC,OAAO,OACxD,YACD,CAAC;GACF,SAAS,sBAAsB;EAChC;EACD,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;EAChC;EACD,QAAQ;GACN,MA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AChB,WAAW,KAAK;GAChB,MAAM,KAAK;GACX,YAAY,KAAK;GACjB,YAAY,KAAK;GACjB,oBAAoB,KAAK;GACzB,KAAK,KAAK;GACV,GAAG,aAAa;EACjB,EAAC;CACH;AACF,EAAC;AAEF,MAAM,OAAO,cAAc;CACzB,MAAM;EACJ,MAAMA,gBAAY;EAClB,aAAaA,gBAAY;EACzB,SAASA,gBAAY;CACtB;CACD,aAAa;EACX,UAAU;EACV,sBAAsB;CACvB;AACF,EAAC;AAEF,QAAQ,KAAK"}
|
|
1
|
+
{"version":3,"file":"cli.js","names":["packageJson","path"],"sources":["../index.ts"],"sourcesContent":["#!/usr/bin/env node\n\nimport * as path from \"node:path\";\nimport { loadConfig } from \"c12\";\nimport { defineCommand, runMain } from \"citty\";\nimport packageJson from \"./package.json\" with { type: \"json\" };\nimport { TemplatesGenConfig } from \"./src/commands/generate-templates/configuration.js\";\nimport { CodeGenConfig } from \"./src/configuration.js\";\nimport { HTTP_CLIENT } from \"./src/constants.js\";\nimport { generateApi, generateTemplates } from \"./src/index.js\";\nimport type { GenerateApiParams, HttpClientType } from \"./types/index.js\";\n\nconst templateGenBaseConfig = new TemplatesGenConfig({});\n\nconst generateTemplatesCommand = defineCommand({\n meta: {\n name: \"generate-templates\",\n description: 'Generate \".ejs\" templates needed for generate api',\n },\n args: {\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate template. WARNING: May cause data loss\",\n default: templateGenBaseConfig.cleanOutput,\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: templateGenBaseConfig.debug,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n default: templateGenBaseConfig.httpClientType,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate templates needed to separate files for http client, data contracts, and routes\",\n default: templateGenBaseConfig.modular,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of generated templates\",\n default: templateGenBaseConfig.output,\n },\n rewrite: {\n type: \"boolean\",\n alias: \"r\",\n description: \"rewrite content in existing templates\",\n default: templateGenBaseConfig.rewrite,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: templateGenBaseConfig.silent,\n },\n },\n run: async ({ args }) => {\n await generateTemplates({\n cleanOutput: args[\"clean-output\"],\n httpClientType: args[\"http-client\"] as HttpClientType,\n modular: args.modular,\n output: args.output,\n rewrite: args.rewrite,\n silent: args.silent,\n debug: args.debug,\n });\n },\n});\n\nconst codeGenBaseConfig = new CodeGenConfig({});\n\nconst generateCommand = defineCommand({\n meta: {\n name: \"generate\",\n description: packageJson.description,\n },\n args: {\n \"add-readonly\": {\n type: \"boolean\",\n description: \"generate readonly properties\",\n default: codeGenBaseConfig.addReadonly,\n },\n \"another-array-type\": {\n type: \"boolean\",\n description: \"generate array types as Array<Type> (by default Type[])\",\n default: codeGenBaseConfig.anotherArrayType,\n },\n \"api-class-name\": {\n type: \"string\",\n description: \"name of the api class\",\n default: codeGenBaseConfig.apiClassName,\n },\n axios: {\n type: \"boolean\",\n description: \"generate axios http client\",\n default: false,\n },\n \"clean-output\": {\n type: \"boolean\",\n description:\n \"clean output folder before generate api. WARNING: May cause data loss\",\n default: codeGenBaseConfig.cleanOutput,\n },\n client: {\n type: \"boolean\",\n description: \"do not generate an API class\",\n default: codeGenBaseConfig.generateClient,\n },\n \"custom-config\": {\n type: \"string\",\n description: \"custom config: primitiveTypeConstructs, hooks, ... \",\n },\n debug: {\n type: \"boolean\",\n description: \"additional information about processes inside this tool\",\n default: codeGenBaseConfig.debug,\n },\n \"default-as-success\": {\n type: \"boolean\",\n alias: \"d\",\n description:\n 'use \"default\" response status code as success response too. some swagger schemas use \"default\" response status code as success response type by default.',\n default: codeGenBaseConfig.defaultResponseAsSuccess,\n },\n \"default-response\": {\n type: \"string\",\n description: \"default type for empty response schema\",\n default: codeGenBaseConfig.defaultResponseType,\n },\n \"disable-throw-on-error\": {\n type: \"boolean\",\n description: \"Do not throw an error when response.ok is not true\",\n default: codeGenBaseConfig.disableThrowOnError,\n },\n \"enum-names-as-values\": {\n type: \"boolean\",\n description:\n \"use values in 'x-enumNames' as enum values (not only as keys)\",\n default: codeGenBaseConfig.enumNamesAsValues,\n },\n \"extract-enums\": {\n type: \"boolean\",\n description:\n \"extract all enums from inline interface/type content to typescript enum construction\",\n default: codeGenBaseConfig.extractEnums,\n },\n \"extract-request-body\": {\n type: \"boolean\",\n description: \"extract request body type to data contract\",\n default: codeGenBaseConfig.extractRequestBody,\n },\n \"extract-request-params\": {\n type: \"boolean\",\n description:\n \"extract request params to data contract (Also combine path params and query params into one object)\",\n default: codeGenBaseConfig.extractRequestParams,\n },\n \"extract-response-body\": {\n type: \"boolean\",\n description: \"extract response body type to data contract\",\n default: codeGenBaseConfig.extractResponseBody,\n },\n \"extract-response-error\": {\n type: \"boolean\",\n description: \"extract response error type to data contract\",\n default: codeGenBaseConfig.extractResponseError,\n },\n \"extract-responses\": {\n type: \"boolean\",\n description: \"extract all responses described in /components/responses\",\n default: codeGenBaseConfig.extractResponses,\n },\n \"generate-union-enums\": {\n type: \"boolean\",\n description: 'generate all \"enum\" types as union types (T1 | T2 | TN)',\n default: codeGenBaseConfig.generateUnionEnums,\n },\n \"http-client\": {\n type: \"string\",\n description: `http client type (possible values: ${Object.values(\n HTTP_CLIENT,\n )})`,\n },\n js: {\n type: \"boolean\",\n description: \"generate js api module with declaration file\",\n default: codeGenBaseConfig.toJS,\n },\n modular: {\n type: \"boolean\",\n description:\n \"generate separated files for http client, data contracts, and routes\",\n default: codeGenBaseConfig.modular,\n },\n \"module-name-first-tag\": {\n type: \"boolean\",\n description: \"splits routes based on the first tag\",\n default: codeGenBaseConfig.moduleNameFirstTag,\n },\n \"module-name-index\": {\n type: \"string\",\n description:\n \"determines which path index should be used for routes separation (example: GET:/fruits/getFruit -> index:0 -> moduleName -> fruits)\",\n default: codeGenBaseConfig.moduleNameIndex.toString(),\n },\n name: {\n type: \"string\",\n alias: \"n\",\n description: \"name of output typescript api file\",\n default: codeGenBaseConfig.fileName,\n },\n output: {\n type: \"string\",\n alias: \"o\",\n description: \"output path of typescript api file\",\n default: \"./\",\n },\n patch: {\n type: \"boolean\",\n description: \"fix up small errors in the swagger source definition\",\n default: codeGenBaseConfig.patch,\n },\n path: {\n type: \"string\",\n alias: \"p\",\n description: \"path/url to swagger schema\",\n },\n responses: {\n type: \"boolean\",\n alias: \"r\",\n description:\n \"generate additional information about request responses also add typings for bad responses\",\n default: codeGenBaseConfig.generateResponses,\n },\n \"route-types\": {\n type: \"boolean\",\n description: \"generate type definitions for API routes\",\n default: codeGenBaseConfig.generateRouteTypes,\n },\n silent: {\n type: \"boolean\",\n description: \"Output only errors to console\",\n default: codeGenBaseConfig.silent,\n },\n \"single-http-client\": {\n type: \"boolean\",\n description: \"Ability to send HttpClient instance to Api constructor\",\n default: codeGenBaseConfig.singleHttpClient,\n },\n \"sort-routes\": {\n type: \"boolean\",\n description: \"sort routes in alphabetical order\",\n default: codeGenBaseConfig.sortRoutes,\n },\n \"sort-types\": {\n type: \"boolean\",\n description: \"sort fields and types\",\n default: codeGenBaseConfig.sortTypes,\n },\n templates: {\n type: \"string\",\n alias: \"t\",\n description: \"path to folder containing templates\",\n },\n \"type-prefix\": {\n type: \"string\",\n description: \"data contract name prefix\",\n default: codeGenBaseConfig.typePrefix,\n },\n \"type-suffix\": {\n type: \"string\",\n description: \"data contract name suffix\",\n default: codeGenBaseConfig.typeSuffix,\n },\n \"unwrap-response-data\": {\n type: \"boolean\",\n description: \"unwrap the data item from the response\",\n default: codeGenBaseConfig.unwrapResponseData,\n },\n },\n run: async ({ args }) => {\n const customConfig = await loadConfig<GenerateApiParams>({\n name: \"swagger-typescript-api\",\n configFile: args[\"custom-config\"],\n });\n\n await generateApi({\n addReadonly: args[\"add-readonly\"],\n anotherArrayType: args[\"another-array-type\"],\n apiClassName: args[\"api-class-name\"],\n cleanOutput: args[\"clean-output\"],\n debug: args.debug,\n defaultResponseAsSuccess: args[\"default-as-success\"],\n defaultResponseType: args[\"default-response\"],\n disableThrowOnError: args[\"disable-throw-on-error\"],\n enumNamesAsValues: args[\"enum-names-as-values\"],\n extractEnums: args[\"extract-enums\"],\n extractRequestBody: args[\"extract-request-body\"],\n extractRequestParams: args[\"extract-request-params\"],\n extractResponseBody: args[\"extract-response-body\"],\n extractResponseError: args[\"extract-response-error\"],\n extractResponses: args[\"extract-responses\"],\n fileName: args.name,\n generateClient: args.client,\n generateResponses: args.responses,\n generateRouteTypes: args[\"route-types\"],\n generateUnionEnums: args[\"generate-union-enums\"],\n httpClientType:\n args[\"http-client\"] || args.axios\n ? HTTP_CLIENT.AXIOS\n : HTTP_CLIENT.FETCH,\n input: path.resolve(process.cwd(), args.path as string),\n modular: args.modular,\n moduleNameFirstTag: args[\"module-name-first-tag\"],\n moduleNameIndex: +args[\"module-name-index\"] || 0,\n output: path.resolve(process.cwd(), (args.output as string) || \".\"),\n patch: args.patch,\n silent: args.silent,\n singleHttpClient: args[\"single-http-client\"],\n sortRoutes: args[\"sort-routes\"],\n sortTypes: args[\"sort-types\"],\n templates: args.templates,\n toJS: args.js,\n typePrefix: args[\"type-prefix\"],\n typeSuffix: args[\"type-suffix\"],\n unwrapResponseData: args[\"unwrap-response-data\"],\n url: args.path,\n ...customConfig.config,\n });\n },\n});\n\nconst main = defineCommand({\n meta: {\n name: packageJson.name,\n description: packageJson.description,\n version: packageJson.version,\n },\n subCommands: {\n generate: generateCommand,\n \"generate-templates\": generateTemplatesCommand,\n },\n});\n\nrunMain(main);\n"],"mappings":";;;;;;;AAYA,MAAM,wBAAwB,IAAI,mBAAmB;AAErD,MAAM,2BAA2B,cAAc;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;;CAEf,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;;EAEjC,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;;EAEjC,eAAe;GACb,MAAM;GACN,aAA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AAK,KAAK;GACV,GAAG,aAAa;;;;AAKtB,MAAM,OAAO,cAAc;CACzB,MAAM;EACJ,MAAMD,gBAAY;EAClB,aAAaA,gBAAY;EACzB,SAASA,gBAAY;;CAEvB,aAAa;EACX,UAAU;EACV,sBAAsB;;;AAI1B,QAAQ"}
|
package/dist/lib.cjs
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
|
-
const require_src = require('./src-
|
|
1
|
+
const require_src = require('./src-C5bMYV9w.cjs');
|
|
2
2
|
|
|
3
|
+
exports.RequestContentKind = require_src.RequestContentKind;
|
|
4
|
+
exports.SCHEMA_TYPES = require_src.SCHEMA_TYPES;
|
|
3
5
|
Object.defineProperty(exports, 'constants', {
|
|
4
6
|
enumerable: true,
|
|
5
7
|
get: function () {
|
package/dist/lib.d.cts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
1
|
import { OpenAPI } from "openapi-types";
|
|
2
|
-
import * as typescript$1 from "typescript";
|
|
3
2
|
import * as typescript from "typescript";
|
|
4
|
-
import * as lodash0$1 from "lodash";
|
|
5
3
|
import * as lodash0 from "lodash";
|
|
6
4
|
import lodash from "lodash";
|
|
7
5
|
import * as swagger_schema_official0 from "swagger-schema-official";
|
|
@@ -381,7 +379,7 @@ declare class JavascriptTranslator extends Translator {
|
|
|
381
379
|
compileTSCode: (input: TranslatorIO) => Record<string, string>;
|
|
382
380
|
translate: (input: any) => Promise<{
|
|
383
381
|
fileName: any;
|
|
384
|
-
fileExtension: typescript
|
|
382
|
+
fileExtension: typescript.Extension;
|
|
385
383
|
fileContent: string;
|
|
386
384
|
}[]>;
|
|
387
385
|
}
|
|
@@ -530,7 +528,7 @@ declare class CodeGenProcess {
|
|
|
530
528
|
}) => string;
|
|
531
529
|
NameResolver: typeof NameResolver;
|
|
532
530
|
_: lodash.LoDashStatic;
|
|
533
|
-
require: (packageOrPath: string) =>
|
|
531
|
+
require: (packageOrPath: string) => any;
|
|
534
532
|
};
|
|
535
533
|
};
|
|
536
534
|
getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
|
|
@@ -635,7 +633,7 @@ declare class CodeGenProcess {
|
|
|
635
633
|
}) => string;
|
|
636
634
|
NameResolver: typeof NameResolver;
|
|
637
635
|
_: lodash.LoDashStatic;
|
|
638
|
-
require: (packageOrPath: string) =>
|
|
636
|
+
require: (packageOrPath: string) => any;
|
|
639
637
|
};
|
|
640
638
|
config: CodeGenConfig;
|
|
641
639
|
};
|
|
@@ -672,7 +670,7 @@ declare class TemplatesWorker {
|
|
|
672
670
|
getTemplatePaths: (config: CodeGenConfig) => CodeGenConfig["templatePaths"];
|
|
673
671
|
cropExtension: (path: string) => string;
|
|
674
672
|
getTemplateFullPath: (path_: string, fileName: string) => string | undefined;
|
|
675
|
-
requireFnFromTemplate: (packageOrPath: string) =>
|
|
673
|
+
requireFnFromTemplate: (packageOrPath: string) => any;
|
|
676
674
|
getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
|
|
677
675
|
getTemplates: ({
|
|
678
676
|
templatePaths
|
|
@@ -776,6 +774,73 @@ declare class MonoSchemaParser {
|
|
|
776
774
|
//#endregion
|
|
777
775
|
//#region types/index.d.ts
|
|
778
776
|
type HttpClientType = (typeof HTTP_CLIENT)[keyof typeof HTTP_CLIENT];
|
|
777
|
+
type CodeGenConstruct = {
|
|
778
|
+
Keyword: {
|
|
779
|
+
Number: string;
|
|
780
|
+
String: string;
|
|
781
|
+
Boolean: string;
|
|
782
|
+
Any: string;
|
|
783
|
+
Void: string;
|
|
784
|
+
Unknown: string;
|
|
785
|
+
Null: string;
|
|
786
|
+
Undefined: string;
|
|
787
|
+
Object: string;
|
|
788
|
+
File: string;
|
|
789
|
+
Date: string;
|
|
790
|
+
Type: string;
|
|
791
|
+
Enum: string;
|
|
792
|
+
Interface: string;
|
|
793
|
+
Array: string;
|
|
794
|
+
Record: string;
|
|
795
|
+
Intersection: string;
|
|
796
|
+
Union: string;
|
|
797
|
+
};
|
|
798
|
+
CodeGenKeyword: {
|
|
799
|
+
UtilRequiredKeys: string;
|
|
800
|
+
};
|
|
801
|
+
ArrayType: (content: unknown) => string;
|
|
802
|
+
StringValue: (content: unknown) => string;
|
|
803
|
+
BooleanValue: (content: unknown) => string;
|
|
804
|
+
NumberValue: (content: unknown) => string;
|
|
805
|
+
NullValue: (content: unknown) => string;
|
|
806
|
+
UnionType: (content: unknown) => string;
|
|
807
|
+
ExpressionGroup: (content: unknown) => string;
|
|
808
|
+
IntersectionType: (content: unknown) => string;
|
|
809
|
+
RecordType: (content: unknown) => string;
|
|
810
|
+
TypeField: (content: unknown) => string;
|
|
811
|
+
InterfaceDynamicField: (content: unknown) => string;
|
|
812
|
+
EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
|
|
813
|
+
EnumField: (content: unknown) => string;
|
|
814
|
+
EnumFieldDescription: (content: unknown) => string;
|
|
815
|
+
EnumFieldsWrapper: (content: unknown) => string;
|
|
816
|
+
ObjectWrapper: (content: unknown) => string;
|
|
817
|
+
MultilineComment: (content: unknown) => string;
|
|
818
|
+
TypeWithGeneric: (content: unknown) => string;
|
|
819
|
+
Tuple: (content: unknown) => string;
|
|
820
|
+
};
|
|
821
|
+
type PrimitiveTypeStructValue = string | ((schema: Record<string, unknown>, parser: SchemaParser) => string);
|
|
822
|
+
type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", string | ({
|
|
823
|
+
$default: PrimitiveTypeStructValue;
|
|
824
|
+
} & Record<string, PrimitiveTypeStructValue>)>;
|
|
825
|
+
interface GenerateApiParamsFromPath extends Partial<GenerateApiConfiguration["config"]> {
|
|
826
|
+
/**
|
|
827
|
+
* path to swagger schema
|
|
828
|
+
*/
|
|
829
|
+
input: string;
|
|
830
|
+
}
|
|
831
|
+
interface GenerateApiParamsFromUrl extends Partial<GenerateApiConfiguration["config"]> {
|
|
832
|
+
/**
|
|
833
|
+
* url to swagger schema
|
|
834
|
+
*/
|
|
835
|
+
url: string;
|
|
836
|
+
}
|
|
837
|
+
interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfiguration["config"]> {
|
|
838
|
+
/**
|
|
839
|
+
* swagger schema JSON
|
|
840
|
+
*/
|
|
841
|
+
spec: swagger_schema_official0.Spec;
|
|
842
|
+
}
|
|
843
|
+
type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
|
|
779
844
|
type BuildRouteParam = {
|
|
780
845
|
/** {bar} */
|
|
781
846
|
$match: string;
|
|
@@ -824,6 +889,7 @@ interface Hooks {
|
|
|
824
889
|
/** customize name of route (operationId), you can do it with using onCreateRouteName too */
|
|
825
890
|
onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
|
|
826
891
|
}
|
|
892
|
+
type RouteNameRouteInfo = Record<string, unknown>;
|
|
827
893
|
type RouteNameInfo = {
|
|
828
894
|
usage: string;
|
|
829
895
|
original: string;
|
|
@@ -866,6 +932,12 @@ interface ParsedSchema<C> {
|
|
|
866
932
|
isExtractedResponseBody?: boolean;
|
|
867
933
|
isExtractedResponseError?: boolean;
|
|
868
934
|
}
|
|
935
|
+
interface PathArgInfo {
|
|
936
|
+
name: string;
|
|
937
|
+
optional: boolean;
|
|
938
|
+
type: string;
|
|
939
|
+
description?: string;
|
|
940
|
+
}
|
|
869
941
|
interface SchemaComponent {
|
|
870
942
|
$ref: string;
|
|
871
943
|
typeName: string;
|
|
@@ -1014,18 +1086,45 @@ type ExtractingOptions = {
|
|
|
1014
1086
|
};
|
|
1015
1087
|
interface GenerateApiConfiguration {
|
|
1016
1088
|
apiConfig: {
|
|
1089
|
+
/** base url from schema */
|
|
1017
1090
|
baseUrl: string;
|
|
1091
|
+
/** document title */
|
|
1018
1092
|
title: string;
|
|
1093
|
+
/** document version */
|
|
1019
1094
|
version: string;
|
|
1095
|
+
/** description split into lines */
|
|
1020
1096
|
description: string[];
|
|
1097
|
+
/** flag that description is present */
|
|
1021
1098
|
hasDescription: boolean;
|
|
1022
1099
|
};
|
|
1023
1100
|
config: {
|
|
1101
|
+
/** path to swagger schema */
|
|
1024
1102
|
input: string;
|
|
1103
|
+
/**
|
|
1104
|
+
* generate separated files for http client, data contracts, and routes
|
|
1105
|
+
* @default false
|
|
1106
|
+
*/
|
|
1107
|
+
modular: boolean;
|
|
1108
|
+
/**
|
|
1109
|
+
* path to folder where the created api module will be placed.
|
|
1110
|
+
* may be set to `false` to skip writing content to disk; in this case
|
|
1111
|
+
* the `files` array on the return value will contain the generated contents.
|
|
1112
|
+
*/
|
|
1025
1113
|
output: string | false;
|
|
1114
|
+
/** url to swagger schema */
|
|
1026
1115
|
url: string;
|
|
1116
|
+
/** swagger schema JSON */
|
|
1027
1117
|
spec: unknown;
|
|
1118
|
+
/**
|
|
1119
|
+
* file name for the generated API module
|
|
1120
|
+
* @default 'Api.ts'
|
|
1121
|
+
*/
|
|
1028
1122
|
fileName: string;
|
|
1123
|
+
/**
|
|
1124
|
+
* path to folder containing custom templates
|
|
1125
|
+
* @default ""
|
|
1126
|
+
*/
|
|
1127
|
+
templates: string;
|
|
1029
1128
|
templatePaths: {
|
|
1030
1129
|
/** `templates/base` */
|
|
1031
1130
|
base: string;
|
|
@@ -1038,66 +1137,176 @@ interface GenerateApiConfiguration {
|
|
|
1038
1137
|
/** custom path to templates (`--templates`) */
|
|
1039
1138
|
custom: string | null;
|
|
1040
1139
|
};
|
|
1140
|
+
/** authorisation token for private swagger schema access */
|
|
1041
1141
|
authorizationToken?: string;
|
|
1142
|
+
/** generate additional information about request responses and error typings */
|
|
1042
1143
|
generateResponses: boolean;
|
|
1144
|
+
/**
|
|
1145
|
+
* use "default" response status code as success response.
|
|
1146
|
+
* some swagger schemas treat "default" as a successful response.
|
|
1147
|
+
*/
|
|
1043
1148
|
defaultResponseAsSuccess: boolean;
|
|
1149
|
+
/** generate type definitions for API routes */
|
|
1044
1150
|
generateRouteTypes: boolean;
|
|
1151
|
+
/** generate an API client */
|
|
1045
1152
|
generateClient: boolean;
|
|
1153
|
+
/** generate all "enum" types as union types (T1 | T2 | TN) */
|
|
1046
1154
|
generateUnionEnums: boolean;
|
|
1155
|
+
/** parsed swagger schema */
|
|
1047
1156
|
swaggerSchema: object;
|
|
1157
|
+
/** original swagger schema */
|
|
1048
1158
|
originalSchema: object;
|
|
1159
|
+
/** map of schema component references */
|
|
1049
1160
|
componentsMap: Record<string, SchemaComponent>;
|
|
1161
|
+
/** flag indicating the schema was converted from Swagger 2.0 */
|
|
1050
1162
|
convertedFromSwagger2: boolean;
|
|
1163
|
+
/** determines which path index should be used for routes separation */
|
|
1051
1164
|
moduleNameIndex: number;
|
|
1165
|
+
/** use the first tag for the module name */
|
|
1052
1166
|
moduleNameFirstTag: boolean;
|
|
1167
|
+
/** extra templates */
|
|
1053
1168
|
extraTemplates: {
|
|
1054
1169
|
name: string;
|
|
1055
1170
|
path: string;
|
|
1056
1171
|
}[];
|
|
1172
|
+
/** extract request params to data contract */
|
|
1057
1173
|
extractRequestParams: boolean;
|
|
1174
|
+
/** unwrap the data item from the response */
|
|
1058
1175
|
unwrapResponseData: boolean;
|
|
1176
|
+
/** sort data contracts in alphabetical order */
|
|
1059
1177
|
sortTypes: boolean;
|
|
1178
|
+
/** sort routes in alphabetical order */
|
|
1060
1179
|
sortRoutes: boolean;
|
|
1180
|
+
/** ability to send HttpClient instance to Api constructor */
|
|
1061
1181
|
singleHttpClient: boolean;
|
|
1182
|
+
/** prefix string value for type names */
|
|
1062
1183
|
typePrefix: string;
|
|
1184
|
+
/** suffix string value for type names */
|
|
1063
1185
|
typeSuffix: string;
|
|
1186
|
+
/** prefix string value for enum keys */
|
|
1064
1187
|
enumKeyPrefix: string;
|
|
1188
|
+
/** suffix string value for enum keys */
|
|
1065
1189
|
enumKeySuffix: string;
|
|
1190
|
+
/** fix up small errors in the swagger source definition */
|
|
1066
1191
|
patch: boolean;
|
|
1192
|
+
/** remove output directory before generating */
|
|
1067
1193
|
cleanOutput: boolean;
|
|
1194
|
+
/** output debug messages */
|
|
1068
1195
|
debug: boolean;
|
|
1196
|
+
/**
|
|
1197
|
+
* generate array types as Array<Type>
|
|
1198
|
+
* @default false
|
|
1199
|
+
*/
|
|
1069
1200
|
anotherArrayType: boolean;
|
|
1201
|
+
/** extract request body type to data contract */
|
|
1070
1202
|
extractRequestBody: boolean;
|
|
1203
|
+
/** generated http client type */
|
|
1071
1204
|
httpClientType: "axios" | "fetch";
|
|
1205
|
+
/** generate readonly properties */
|
|
1072
1206
|
addReadonly: boolean;
|
|
1207
|
+
/** customise primitive type mappings */
|
|
1208
|
+
primitiveTypeConstructs?: (struct: PrimitiveTypeStruct) => Partial<PrimitiveTypeStruct>;
|
|
1209
|
+
/** customise code generation constructs */
|
|
1210
|
+
codeGenConstructs?: (struct: CodeGenConstruct) => Partial<CodeGenConstruct>;
|
|
1211
|
+
/** extract response body type to data contract */
|
|
1073
1212
|
extractResponseBody: boolean;
|
|
1213
|
+
/** extract response error type to data contract */
|
|
1074
1214
|
extractResponseError: boolean;
|
|
1215
|
+
/** extract all enums from nested types/interfaces to `enum` construction */
|
|
1075
1216
|
extractEnums: boolean;
|
|
1217
|
+
/** extract all enums from inline interface/type content to typescript enum construction */
|
|
1076
1218
|
extractResponses: boolean;
|
|
1219
|
+
/**
|
|
1220
|
+
* prefix string value needed to fix invalid type names
|
|
1221
|
+
* @default "Type"
|
|
1222
|
+
*/
|
|
1077
1223
|
fixInvalidTypeNamePrefix: string;
|
|
1224
|
+
/**
|
|
1225
|
+
* prefix string value needed to fix invalid enum keys
|
|
1226
|
+
* @default "Value"
|
|
1227
|
+
*/
|
|
1078
1228
|
fixInvalidEnumKeyPrefix: string;
|
|
1229
|
+
/**
|
|
1230
|
+
* default type for empty response schema
|
|
1231
|
+
* @default "void"
|
|
1232
|
+
*/
|
|
1079
1233
|
defaultResponseType: string;
|
|
1234
|
+
/**
|
|
1235
|
+
* generate js api module with declaration file
|
|
1236
|
+
* @default false
|
|
1237
|
+
*/
|
|
1080
1238
|
toJS: boolean;
|
|
1239
|
+
/** disable throwing on a non-successful response */
|
|
1081
1240
|
disableThrowOnError: boolean;
|
|
1241
|
+
/**
|
|
1242
|
+
* output only errors to console
|
|
1243
|
+
* @default false
|
|
1244
|
+
*/
|
|
1082
1245
|
silent: boolean;
|
|
1246
|
+
/** hooks for customising the generation process */
|
|
1083
1247
|
hooks: Partial<Hooks>;
|
|
1248
|
+
/** use enum names as values */
|
|
1084
1249
|
enumNamesAsValues: boolean;
|
|
1250
|
+
/** package version */
|
|
1085
1251
|
version: string;
|
|
1252
|
+
/** ts compiler configuration object (for --to-js option) */
|
|
1086
1253
|
compilerTsConfig: Record<string, unknown>;
|
|
1254
|
+
/** enum key resolver name */
|
|
1087
1255
|
enumKeyResolverName: string;
|
|
1256
|
+
/** type name resolver name */
|
|
1088
1257
|
typeNameResolverName: string;
|
|
1258
|
+
/** specific argument name resolver name */
|
|
1089
1259
|
specificArgNameResolverName: string;
|
|
1260
|
+
/**
|
|
1261
|
+
* custom ts->* translator
|
|
1262
|
+
* do not use constructor args, just send class reference
|
|
1263
|
+
*/
|
|
1090
1264
|
customTranslator?: new () => Translator;
|
|
1265
|
+
/** internal constants */
|
|
1266
|
+
constants: typeof constants_d_exports;
|
|
1267
|
+
/** code generation constructs for TypeScript */
|
|
1268
|
+
Ts: CodeGenConstruct;
|
|
1269
|
+
/**
|
|
1270
|
+
* swagger schema type -> typescript type
|
|
1271
|
+
* https://json-schema.org/understanding-json-schema/reference/string.html#dates-and-times
|
|
1272
|
+
*/
|
|
1273
|
+
primitiveTypes: PrimitiveTypeStruct;
|
|
1274
|
+
/** built-in template info */
|
|
1275
|
+
templateInfos: {
|
|
1276
|
+
name: string;
|
|
1277
|
+
fileName: string;
|
|
1278
|
+
}[];
|
|
1279
|
+
/** supported template file extensions */
|
|
1280
|
+
templateExtensions: string[];
|
|
1281
|
+
/** range of HTTP status codes treated as success */
|
|
1282
|
+
successResponseStatusRange: [number, number];
|
|
1283
|
+
/** custom schema parsers */
|
|
1284
|
+
schemaParsers?: {
|
|
1285
|
+
complexOneOf?: MonoSchemaParser;
|
|
1286
|
+
complexAllOf?: MonoSchemaParser;
|
|
1287
|
+
complexAnyOf?: MonoSchemaParser;
|
|
1288
|
+
complexNot?: MonoSchemaParser;
|
|
1289
|
+
enum?: MonoSchemaParser;
|
|
1290
|
+
object?: MonoSchemaParser;
|
|
1291
|
+
complex?: MonoSchemaParser;
|
|
1292
|
+
primitive?: MonoSchemaParser;
|
|
1293
|
+
discriminator?: MonoSchemaParser;
|
|
1294
|
+
array?: MonoSchemaParser;
|
|
1295
|
+
};
|
|
1296
|
+
/** internal options for templates */
|
|
1091
1297
|
internalTemplateOptions: {
|
|
1092
1298
|
addUtilRequiredKeysType: boolean;
|
|
1093
1299
|
};
|
|
1300
|
+
/** resolver for component type names */
|
|
1094
1301
|
componentTypeNameResolver: ComponentTypeNameResolver;
|
|
1302
|
+
/** generated file names */
|
|
1095
1303
|
fileNames: {
|
|
1096
1304
|
dataContracts: string;
|
|
1097
1305
|
routeTypes: string;
|
|
1098
1306
|
httpClient: string;
|
|
1099
1307
|
outOfModuleApi: string;
|
|
1100
1308
|
};
|
|
1309
|
+
/** Record<templateName, templateContent> */
|
|
1101
1310
|
templatesToRender: {
|
|
1102
1311
|
api: string;
|
|
1103
1312
|
dataContracts: string;
|
|
@@ -1110,10 +1319,16 @@ interface GenerateApiConfiguration {
|
|
|
1110
1319
|
enumDataContract: string;
|
|
1111
1320
|
objectFieldJsDoc: string;
|
|
1112
1321
|
};
|
|
1322
|
+
/** map of duplicate route names */
|
|
1113
1323
|
routeNameDuplicatesMap: Map<string, string>;
|
|
1324
|
+
/** name of the main exported class */
|
|
1114
1325
|
apiClassName: string;
|
|
1115
|
-
|
|
1116
|
-
|
|
1326
|
+
/** configuration for fetching swagger schema requests */
|
|
1327
|
+
requestOptions?: Partial<RequestInit>;
|
|
1328
|
+
/** extra configuration for extracting type names operations */
|
|
1329
|
+
extractingOptions: Partial<ExtractingOptions>;
|
|
1330
|
+
/** update configuration object during generation */
|
|
1331
|
+
update: (update: Partial<GenerateApiConfiguration["config"]>) => void;
|
|
1117
1332
|
};
|
|
1118
1333
|
modelTypes: ModelType[];
|
|
1119
1334
|
hasFormDataRoutes: boolean;
|
|
@@ -1144,7 +1359,7 @@ interface GenerateApiConfiguration {
|
|
|
1144
1359
|
fmtToJSDocLine: (line: string, params?: {
|
|
1145
1360
|
eol?: boolean;
|
|
1146
1361
|
}) => string;
|
|
1147
|
-
_: lodash0
|
|
1362
|
+
_: lodash0.LoDashStatic;
|
|
1148
1363
|
require: (path: string) => unknown;
|
|
1149
1364
|
};
|
|
1150
1365
|
}
|
|
@@ -1588,7 +1803,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1588
1803
|
}) => string;
|
|
1589
1804
|
NameResolver: typeof NameResolver;
|
|
1590
1805
|
_: lodash0.LoDashStatic;
|
|
1591
|
-
require: (packageOrPath: string) =>
|
|
1806
|
+
require: (packageOrPath: string) => any;
|
|
1592
1807
|
};
|
|
1593
1808
|
};
|
|
1594
1809
|
getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
|
|
@@ -1613,5 +1828,5 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
|
|
|
1613
1828
|
}) => Promise<string>;
|
|
1614
1829
|
}>;
|
|
1615
1830
|
//#endregion
|
|
1616
|
-
export { constants_d_exports as constants, generateApi, generateTemplates };
|
|
1831
|
+
export { ExtractingOptions, GenerateApiConfiguration, GenerateApiOutput, GenerateApiParams, GenerateTemplatesOutput, GenerateTemplatesParams, Hooks, HttpClientType, ModelType, ParsedRoute, ParsedRouteRequest, ParsedRouteResponse, ParsedSchema, PathArgInfo, RawRouteInfo, RequestContentKind, RequestResponseInfo, RouteNameInfo, RouteNameRouteInfo, SCHEMA_TYPES, SchemaComponent, SchemaTypeEnumContent, SchemaTypeObjectContent, SchemaTypePrimitiveContent, constants_d_exports as constants, generateApi, generateTemplates };
|
|
1617
1832
|
//# sourceMappingURL=lib.d.cts.map
|