swagger-typescript-api 13.2.9 → 13.2.11

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
@@ -1,5 +1,21 @@
1
1
  # swagger-typescript-api
2
2
 
3
+ ## 13.2.11
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1390](https://github.com/acacode/swagger-typescript-api/pull/1390) [`5897e4b`](https://github.com/acacode/swagger-typescript-api/commit/5897e4ba1e3d21adf9ccb161bfc6eb0f1dde966c) Thanks [@MatanAvneri](https://github.com/MatanAvneri)! - Fix being able to call getComponentByRef from templates
8
+
9
+ - [#1393](https://github.com/acacode/swagger-typescript-api/pull/1393) [`9a7c788`](https://github.com/acacode/swagger-typescript-api/commit/9a7c788edc8efefbb8412bcc331e909b80ece317) Thanks [@RoCat](https://github.com/RoCat)! - Ensure discriminators are just after enums in components list to avoid cyclic errors
10
+
11
+ - [#1416](https://github.com/acacode/swagger-typescript-api/pull/1416) [`cd127a9`](https://github.com/acacode/swagger-typescript-api/commit/cd127a94e3386ef5eece740ba9335715fb7d13e0) Thanks [@smorimoto](https://github.com/smorimoto)! - Fix fetch client response parsing without re-reading body.
12
+
13
+ ## 13.2.10
14
+
15
+ ### Patch Changes
16
+
17
+ - [`7b7351f`](https://github.com/acacode/swagger-typescript-api/commit/7b7351f90b250f7702cb57976c5c293ede353312) Thanks [@js2me](https://github.com/js2me)! - fix missing exported interfaces and types
18
+
3
19
  ## 13.2.9
4
20
 
5
21
  ### Patch Changes
@@ -1,10 +1,12 @@
1
1
  //#region rolldown:runtime
2
2
  var __defProp = Object.defineProperty;
3
- var __export = (target, all) => {
3
+ var __export = (all) => {
4
+ let target = {};
4
5
  for (var name in all) __defProp(target, name, {
5
6
  get: all[name],
6
7
  enumerable: true
7
8
  });
9
+ return target;
8
10
  };
9
11
 
10
12
  //#endregion
package/dist/cli.cjs CHANGED
@@ -1,8 +1,11 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('./src-B-cU8h_Y.cjs');
3
- const node_path = require_src.__toESM(require("node:path"));
4
- const c12 = require_src.__toESM(require("c12"));
5
- const citty = require_src.__toESM(require("citty"));
2
+ const require_src = require('./src-D2FYrO2h.cjs');
3
+ let node_path = require("node:path");
4
+ node_path = require_src.__toESM(node_path);
5
+ let c12 = require("c12");
6
+ c12 = require_src.__toESM(c12);
7
+ let citty = require("citty");
8
+ citty = require_src.__toESM(citty);
6
9
 
7
10
  //#region index.ts
8
11
  const templateGenBaseConfig = new require_src.TemplatesGenConfig({});
package/dist/cli.cjs.map CHANGED
@@ -1 +1 @@
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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AAK;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"}
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,EAAE,CAAC;AAExD,MAAM,oDAAyC;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;GAChC;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;GAChC;EACD,eAAe;GAC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C,QAAQA,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;GACjB,CAAC;;CAEL,CAAC;AAEF,MAAM,gCAAqB;CACzB,MAAM;EACJ,MAAMF,4BAAY;EAClB,aAAaA,4BAAY;EACzB,SAASA,4BAAY;EACtB;CACD,aAAa;EACX,UAAU;EACV,sBAAsB;EACvB;CACF,CAAC;mBAEM,KAAK"}
package/dist/cli.d.cts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { };
package/dist/cli.d.ts CHANGED
@@ -1,2 +1 @@
1
- #!/usr/bin/env node
2
- export {};
1
+ export { };
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-BGOGeWR6.js";
2
+ import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-BRCAbt5v.js";
3
3
  import * as path$1 from "node:path";
4
4
  import { loadConfig } from "c12";
5
5
  import { defineCommand, runMain } from "citty";
package/dist/cli.js.map CHANGED
@@ -1 +1 @@
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,aAAa,sCAAsC,OAAO,OACxD,aACA;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,QAAM,kBAAkB;GACtB,aAAa,KAAK;GAClB,gBAAgB,KAAK;GACrB,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,OAAO,KAAK;;;;AAKlB,MAAM,oBAAoB,IAAI,cAAc;AAE5C,MAAM,kBAAkB,cAAc;CACpC,MAAM;EACJ,MAAM;EACN,aAAaA,gBAAY;;CAE3B,MAAM;EACJ,gBAAgB;GACd,M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AoB,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,QACxB,YAAY,QACZ,YAAY;GAClB,OAAOC,OAAK,QAAQ,QAAQ,OAAO,KAAK;GACxC,SAAS,KAAK;GACd,oBAAoB,KAAK;GACzB,iBAAiB,CAAC,KAAK,wBAAwB;GAC/C,QAAQA,OAAK,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,OAAO,cAAc;CACzB,MAAM;EACJ,MAAMD,gBAAY;EAClB,aAAaA,gBAAY;EACzB,SAASA,gBAAY;;CAEvB,aAAa;EACX,UAAU;EACV,sBAAsB;;;AAI1B,QAAQ"}
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,EAAE,CAAC;AAExD,MAAM,2BAA2B,cAAc;CAC7C,MAAM;EACJ,MAAM;EACN,aAAa;EACd;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;GAChC;EACD,OAAO;GACL,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;GAChC;EACD,eAAe;GACb,MAAM;GACN,aAAa,sCAAsC,OAAO,OACxD,YACD,CAAC;GACF,SAAS,sBAAsB;GAChC;EACD,SAAS;GACP,MAAM;GACN,aACE;GACF,SAAS,sBAAsB;GAChC;EACD,QAAQ;GACN,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;GAChC;EACD,SAAS;GACP,MAAM;GACN,OAAO;GACP,aAAa;GACb,SAAS,sBAAsB;GAChC;EACD,QAAQ;GACN,MAAM;GACN,aAAa;GACb,SAAS,sBAAsB;GAChC;EACF;CACD,KAAK,OAAO,EAAE,WAAW;AACvB,QAAM,kBAAkB;GACtB,aAAa,KAAK;GAClB,gBAAgB,KAAK;GACrB,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,SAAS,KAAK;GACd,QAAQ,KAAK;GACb,OAAO,KAAK;GACb,CAAC;;CAEL,CAAC;AAEF,MAAM,oBAAoB,IAAI,cAAc,EAAE,CAAC;AAE/C,MAAM,kBAAkB,cAAc;CACpC,MAAM;EACJ,MAAM;EACN,aAAaA,gBAAY;EAC1B;CACD,MAAM;EACJ,gBAAgB;GACd,MAAM;GACN,aAAa;GACb,SAAS,kBAAkB;GAC5B;EACD,sBAAsB;GACpB,MAAM;GACN,a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B,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,QACxB,YAAY,QACZ,YAAY;GAClB,OAAOC,OAAK,QAAQ,QAAQ,KAAK,EAAE,KAAK,KAAe;GACvD,SAAS,KAAK;GACd,oBAAoB,KAAK;GACzB,iBAAiB,CAAC,KAAK,wBAAwB;GAC/C,QAAQA,OAAK,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;GACjB,CAAC;;CAEL,CAAC;AAEF,MAAM,OAAO,cAAc;CACzB,MAAM;EACJ,MAAMD,gBAAY;EAClB,aAAaA,gBAAY;EACzB,SAASA,gBAAY;EACtB;CACD,aAAa;EACX,UAAU;EACV,sBAAsB;EACvB;CACF,CAAC;AAEF,QAAQ,KAAK"}
package/dist/lib.cjs CHANGED
@@ -1,5 +1,7 @@
1
- const require_src = require('./src-B-cU8h_Y.cjs');
1
+ const require_src = require('./src-D2FYrO2h.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
@@ -18,8 +18,9 @@ declare class SchemaComponentsMap {
18
18
  createComponent($ref: string, rawTypeData: SchemaComponent["rawTypeData"]): SchemaComponent;
19
19
  getComponents(): SchemaComponent[];
20
20
  filter(...componentNames: (string[] | string)[]): SchemaComponent[];
21
- get($ref: string): SchemaComponent | null;
21
+ get: ($ref: string) => SchemaComponent | null;
22
22
  enumsFirst(): void;
23
+ discriminatorsFirst(): void;
23
24
  }
24
25
  //#endregion
25
26
  //#region src/util/file-system.d.ts
@@ -532,7 +533,7 @@ declare class CodeGenProcess {
532
533
  };
533
534
  };
534
535
  getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
535
- renderTemplate: (template: string, configuration: object, options?: object) => string;
536
+ renderTemplate: (template: string, configuration: Record<string, unknown>) => string;
536
537
  createFile: ({
537
538
  path: path_,
538
539
  fileName,
@@ -677,7 +678,7 @@ declare class TemplatesWorker {
677
678
  }: CodeGenConfig) => {};
678
679
  findTemplateWithExt: (path: string) => string | undefined;
679
680
  getTemplateContent: (path_: string) => string;
680
- renderTemplate: (template: string, configuration: object, options?: object) => string;
681
+ renderTemplate: (template: string, configuration: Record<string, unknown>) => string;
681
682
  }
682
683
  //#endregion
683
684
  //#region src/schema-parser/schema-parser.d.ts
@@ -822,6 +823,25 @@ type PrimitiveTypeStructValue = string | ((schema: Record<string, unknown>, pars
822
823
  type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", string | ({
823
824
  $default: PrimitiveTypeStructValue;
824
825
  } & Record<string, PrimitiveTypeStructValue>)>;
826
+ interface GenerateApiParamsFromPath extends Partial<GenerateApiConfiguration["config"]> {
827
+ /**
828
+ * path to swagger schema
829
+ */
830
+ input: string;
831
+ }
832
+ interface GenerateApiParamsFromUrl extends Partial<GenerateApiConfiguration["config"]> {
833
+ /**
834
+ * url to swagger schema
835
+ */
836
+ url: string;
837
+ }
838
+ interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfiguration["config"]> {
839
+ /**
840
+ * swagger schema JSON
841
+ */
842
+ spec: swagger_schema_official0.Spec;
843
+ }
844
+ type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
825
845
  type BuildRouteParam = {
826
846
  /** {bar} */
827
847
  $match: string;
@@ -870,6 +890,7 @@ interface Hooks {
870
890
  /** customize name of route (operationId), you can do it with using onCreateRouteName too */
871
891
  onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
872
892
  }
893
+ type RouteNameRouteInfo = Record<string, unknown>;
873
894
  type RouteNameInfo = {
874
895
  usage: string;
875
896
  original: string;
@@ -912,6 +933,12 @@ interface ParsedSchema<C> {
912
933
  isExtractedResponseBody?: boolean;
913
934
  isExtractedResponseError?: boolean;
914
935
  }
936
+ interface PathArgInfo {
937
+ name: string;
938
+ optional: boolean;
939
+ type: string;
940
+ description?: string;
941
+ }
915
942
  interface SchemaComponent {
916
943
  $ref: string;
917
944
  typeName: string;
@@ -1781,7 +1808,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1781
1808
  };
1782
1809
  };
1783
1810
  getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
1784
- renderTemplate: (template: string, configuration: object, options?: object) => string;
1811
+ renderTemplate: (template: string, configuration: Record<string, unknown>) => string;
1785
1812
  createFile: ({
1786
1813
  path: path_,
1787
1814
  fileName,
@@ -1802,5 +1829,5 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1802
1829
  }) => Promise<string>;
1803
1830
  }>;
1804
1831
  //#endregion
1805
- export { constants_d_exports as constants, generateApi, generateTemplates };
1832
+ 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 };
1806
1833
  //# sourceMappingURL=lib.d.cts.map
package/dist/lib.d.ts CHANGED
@@ -16,8 +16,9 @@ declare class SchemaComponentsMap {
16
16
  createComponent($ref: string, rawTypeData: SchemaComponent["rawTypeData"]): SchemaComponent;
17
17
  getComponents(): SchemaComponent[];
18
18
  filter(...componentNames: (string[] | string)[]): SchemaComponent[];
19
- get($ref: string): SchemaComponent | null;
19
+ get: ($ref: string) => SchemaComponent | null;
20
20
  enumsFirst(): void;
21
+ discriminatorsFirst(): void;
21
22
  }
22
23
  //#endregion
23
24
  //#region src/util/file-system.d.ts
@@ -530,7 +531,7 @@ declare class CodeGenProcess {
530
531
  };
531
532
  };
532
533
  getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
533
- renderTemplate: (template: string, configuration: object, options?: object) => string;
534
+ renderTemplate: (template: string, configuration: Record<string, unknown>) => string;
534
535
  createFile: ({
535
536
  path: path_,
536
537
  fileName,
@@ -675,7 +676,7 @@ declare class TemplatesWorker {
675
676
  }: CodeGenConfig) => {};
676
677
  findTemplateWithExt: (path: string) => string | undefined;
677
678
  getTemplateContent: (path_: string) => string;
678
- renderTemplate: (template: string, configuration: object, options?: object) => string;
679
+ renderTemplate: (template: string, configuration: Record<string, unknown>) => string;
679
680
  }
680
681
  //#endregion
681
682
  //#region src/schema-parser/schema-parser.d.ts
@@ -820,6 +821,25 @@ type PrimitiveTypeStructValue = string | ((schema: Record<string, unknown>, pars
820
821
  type PrimitiveTypeStruct = Record<"integer" | "number" | "boolean" | "object" | "file" | "string" | "array", string | ({
821
822
  $default: PrimitiveTypeStructValue;
822
823
  } & Record<string, PrimitiveTypeStructValue>)>;
824
+ interface GenerateApiParamsFromPath extends Partial<GenerateApiConfiguration["config"]> {
825
+ /**
826
+ * path to swagger schema
827
+ */
828
+ input: string;
829
+ }
830
+ interface GenerateApiParamsFromUrl extends Partial<GenerateApiConfiguration["config"]> {
831
+ /**
832
+ * url to swagger schema
833
+ */
834
+ url: string;
835
+ }
836
+ interface GenerateApiParamsFromSpecLiteral extends Partial<GenerateApiConfiguration["config"]> {
837
+ /**
838
+ * swagger schema JSON
839
+ */
840
+ spec: swagger_schema_official0.Spec;
841
+ }
842
+ type GenerateApiParams = GenerateApiParamsFromPath | GenerateApiParamsFromUrl | GenerateApiParamsFromSpecLiteral;
823
843
  type BuildRouteParam = {
824
844
  /** {bar} */
825
845
  $match: string;
@@ -868,6 +888,7 @@ interface Hooks {
868
888
  /** customize name of route (operationId), you can do it with using onCreateRouteName too */
869
889
  onFormatRouteName?: (routeInfo: RawRouteInfo, templateRouteName: string) => string | undefined;
870
890
  }
891
+ type RouteNameRouteInfo = Record<string, unknown>;
871
892
  type RouteNameInfo = {
872
893
  usage: string;
873
894
  original: string;
@@ -910,6 +931,12 @@ interface ParsedSchema<C> {
910
931
  isExtractedResponseBody?: boolean;
911
932
  isExtractedResponseError?: boolean;
912
933
  }
934
+ interface PathArgInfo {
935
+ name: string;
936
+ optional: boolean;
937
+ type: string;
938
+ description?: string;
939
+ }
913
940
  interface SchemaComponent {
914
941
  $ref: string;
915
942
  typeName: string;
@@ -1779,7 +1806,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1779
1806
  };
1780
1807
  };
1781
1808
  getTemplate: (name: string, fileName: string, path?: string) => string | undefined;
1782
- renderTemplate: (template: string, configuration: object, options?: object) => string;
1809
+ renderTemplate: (template: string, configuration: Record<string, unknown>) => string;
1783
1810
  createFile: ({
1784
1811
  path: path_,
1785
1812
  fileName,
@@ -1800,5 +1827,5 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1800
1827
  }) => Promise<string>;
1801
1828
  }>;
1802
1829
  //#endregion
1803
- export { constants_d_exports as constants, generateApi, generateTemplates };
1830
+ 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 };
1804
1831
  //# sourceMappingURL=lib.d.ts.map
package/dist/lib.js CHANGED
@@ -1,3 +1,3 @@
1
- import { constants_exports, generateApi, generateTemplates } from "./src-BGOGeWR6.js";
1
+ import { RequestContentKind, SCHEMA_TYPES, constants_exports, generateApi, generateTemplates } from "./src-BRCAbt5v.js";
2
2
 
3
- export { constants_exports as constants, generateApi, generateTemplates };
3
+ export { RequestContentKind, SCHEMA_TYPES, constants_exports as constants, generateApi, generateTemplates };