swagger-typescript-api 13.2.3 → 13.2.4

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,11 @@
1
1
  # swagger-typescript-api
2
2
 
3
+ ## 13.2.4
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1299](https://github.com/acacode/swagger-typescript-api/pull/1299) [`9552c0a`](https://github.com/acacode/swagger-typescript-api/commit/9552c0a3341583be69aaa2cdf2b4e830a1919b01) Thanks [@js2me](https://github.com/js2me)! - added support of x-enum-descriptions property
8
+
3
9
  ## 13.2.3
4
10
 
5
11
  ### Patch Changes
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_src = require('./src-CD5LAKtC.cjs');
2
+ const require_src = require('./src-Dti-j_nt.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.js CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-BYbyXNbU.js";
2
+ import { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, generateApi, generateTemplates, package_default } from "./src-Dg3yZCMd.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/lib.cjs CHANGED
@@ -1,4 +1,4 @@
1
- const require_src = require('./src-CD5LAKtC.cjs');
1
+ const require_src = require('./src-Dti-j_nt.cjs');
2
2
 
3
3
  Object.defineProperty(exports, 'constants', {
4
4
  enumerable: true,
package/dist/lib.d.cts CHANGED
@@ -136,6 +136,7 @@ declare class SchemaUtils {
136
136
  getRequiredProperties: (schema: any) => unknown[];
137
137
  isRefSchema: (schema: any) => boolean;
138
138
  getEnumNames: (schema: any) => any;
139
+ getEnumDescriptions: (schema: any) => any;
139
140
  getSchemaRefType: (schema: any) => SchemaComponent | null;
140
141
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
141
142
  isNullMissingInType: (schema: any, type: any) => any;
@@ -496,6 +497,7 @@ declare class CodeGenProcess {
496
497
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
497
498
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
498
499
  EnumField: (key: unknown, value: unknown) => string;
500
+ EnumFieldDescription: (description: any) => string;
499
501
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
500
502
  ObjectWrapper: (content: unknown) => string;
501
503
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -600,6 +602,7 @@ declare class CodeGenProcess {
600
602
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
601
603
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
602
604
  EnumField: (key: unknown, value: unknown) => string;
605
+ EnumFieldDescription: (description: any) => string;
603
606
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
604
607
  ObjectWrapper: (content: unknown) => string;
605
608
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1394,8 +1397,15 @@ declare class CodeGenConfig {
1394
1397
  */
1395
1398
  EnumField: (key: unknown, value: unknown) => string;
1396
1399
  /**
1400
+ * /\** description \*\/
1401
+ */
1402
+ EnumFieldDescription: (description: any) => string;
1403
+ /**
1404
+ * /\** $A0.description \*\/
1397
1405
  * $A0.key = $A0.value,
1406
+ * /\** $A1.description \*\/
1398
1407
  * $A1.key = $A1.value,
1408
+ * /\** $AN.description \*\/
1399
1409
  * $AN.key = $AN.value,
1400
1410
  */
1401
1411
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
@@ -1545,6 +1555,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1545
1555
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
1546
1556
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1547
1557
  EnumField: (key: unknown, value: unknown) => string;
1558
+ EnumFieldDescription: (description: any) => string;
1548
1559
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1549
1560
  ObjectWrapper: (content: unknown) => string;
1550
1561
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
package/dist/lib.d.ts CHANGED
@@ -1,10 +1,10 @@
1
1
  import { __export } from "./chunk-Cl8Af3a2.js";
2
- import * as lodash20 from "lodash";
2
+ import * as lodash19 from "lodash";
3
3
  import lodash from "lodash";
4
4
  import * as typescript from "typescript";
5
- import * as eta21 from "eta";
5
+ import * as eta20 from "eta";
6
6
  import { OpenAPI } from "openapi-types";
7
- import * as swagger_schema_official17 from "swagger-schema-official";
7
+ import * as swagger_schema_official16 from "swagger-schema-official";
8
8
 
9
9
  //#region src/schema-components-map.d.ts
10
10
  declare class SchemaComponentsMap {
@@ -135,6 +135,7 @@ declare class SchemaUtils {
135
135
  getRequiredProperties: (schema: any) => unknown[];
136
136
  isRefSchema: (schema: any) => boolean;
137
137
  getEnumNames: (schema: any) => any;
138
+ getEnumDescriptions: (schema: any) => any;
138
139
  getSchemaRefType: (schema: any) => SchemaComponent | null;
139
140
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
140
141
  isNullMissingInType: (schema: any, type: any) => any;
@@ -495,6 +496,7 @@ declare class CodeGenProcess {
495
496
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
496
497
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
497
498
  EnumField: (key: unknown, value: unknown) => string;
499
+ EnumFieldDescription: (description: any) => string;
498
500
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
499
501
  ObjectWrapper: (content: unknown) => string;
500
502
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -599,6 +601,7 @@ declare class CodeGenProcess {
599
601
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
600
602
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
601
603
  EnumField: (key: unknown, value: unknown) => string;
604
+ EnumFieldDescription: (description: any) => string;
602
605
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
603
606
  ObjectWrapper: (content: unknown) => string;
604
607
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -911,7 +914,7 @@ type RawRouteInfo = {
911
914
  description?: string;
912
915
  tags?: string[];
913
916
  summary?: string;
914
- responses?: swagger_schema_official17.Spec["responses"];
917
+ responses?: swagger_schema_official16.Spec["responses"];
915
918
  produces?: string[];
916
919
  requestBody?: object;
917
920
  consumes?: string[];
@@ -1144,7 +1147,7 @@ interface GenerateApiConfiguration {
1144
1147
  fmtToJSDocLine: (line: string, params?: {
1145
1148
  eol?: boolean;
1146
1149
  }) => string;
1147
- _: lodash20.LoDashStatic;
1150
+ _: lodash19.LoDashStatic;
1148
1151
  require: (path: string) => unknown;
1149
1152
  };
1150
1153
  }
@@ -1165,7 +1168,7 @@ interface GenerateApiOutput {
1165
1168
  content: string;
1166
1169
  withPrefix: boolean;
1167
1170
  }) => void;
1168
- renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta21.EtaConfig>) => Promise<string> | string;
1171
+ renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta20.EtaConfig>) => Promise<string> | string;
1169
1172
  getTemplate: (params: {
1170
1173
  fileName?: string;
1171
1174
  name?: string;
@@ -1393,8 +1396,15 @@ declare class CodeGenConfig {
1393
1396
  */
1394
1397
  EnumField: (key: unknown, value: unknown) => string;
1395
1398
  /**
1399
+ * /\** description \*\/
1400
+ */
1401
+ EnumFieldDescription: (description: any) => string;
1402
+ /**
1403
+ * /\** $A0.description \*\/
1396
1404
  * $A0.key = $A0.value,
1405
+ * /\** $A1.description \*\/
1397
1406
  * $A1.key = $A1.value,
1407
+ * /\** $AN.description \*\/
1398
1408
  * $AN.key = $AN.value,
1399
1409
  */
1400
1410
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
@@ -1544,6 +1554,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1544
1554
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
1545
1555
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1546
1556
  EnumField: (key: unknown, value: unknown) => string;
1557
+ EnumFieldDescription: (description: any) => string;
1547
1558
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1548
1559
  ObjectWrapper: (content: unknown) => string;
1549
1560
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1579,7 +1590,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1579
1590
  eol?: boolean | undefined;
1580
1591
  }) => string;
1581
1592
  NameResolver: typeof NameResolver;
1582
- _: lodash20.LoDashStatic;
1593
+ _: lodash19.LoDashStatic;
1583
1594
  require: (packageOrPath: string) => Promise<any>;
1584
1595
  };
1585
1596
  };
package/dist/lib.js CHANGED
@@ -1,3 +1,3 @@
1
- import { constants_exports, generateApi, generateTemplates } from "./src-BYbyXNbU.js";
1
+ import { constants_exports, generateApi, generateTemplates } from "./src-Dg3yZCMd.js";
2
2
 
3
3
  export { constants_exports as constants, generateApi, generateTemplates };
@@ -177,7 +177,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
177
177
  //#endregion
178
178
  //#region package.json
179
179
  var name = "swagger-typescript-api";
180
- var version = "13.2.3";
180
+ var version = "13.2.4";
181
181
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
182
182
  var homepage = "https://github.com/acacode/swagger-typescript-api";
183
183
  var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
@@ -218,7 +218,7 @@ var scripts = {
218
218
  };
219
219
  var dependencies = {
220
220
  "@biomejs/js-api": "1.0.0",
221
- "@biomejs/wasm-nodejs": "2.0.0",
221
+ "@biomejs/wasm-nodejs": "2.0.4",
222
222
  "@types/swagger-schema-official": "^2.0.25",
223
223
  "c12": "^3.0.4",
224
224
  "citty": "^0.1.6",
@@ -232,20 +232,20 @@ var dependencies = {
232
232
  "typescript": "~5.8.3"
233
233
  };
234
234
  var devDependencies = {
235
- "@biomejs/biome": "2.0.0",
235
+ "@biomejs/biome": "2.0.4",
236
236
  "@changesets/changelog-github": "0.5.1",
237
- "@changesets/cli": "2.29.4",
237
+ "@changesets/cli": "2.29.5",
238
238
  "@tsconfig/node18": "18.2.4",
239
239
  "@tsconfig/strictest": "2.0.5",
240
240
  "@types/js-yaml": "4.0.9",
241
- "@types/lodash": "4.17.17",
241
+ "@types/lodash": "4.17.18",
242
242
  "@types/node": "24.0.3",
243
243
  "@types/swagger2openapi": "7.0.4",
244
244
  "axios": "1.10.0",
245
245
  "openapi-types": "12.1.3",
246
246
  "tsdown": "0.12.8",
247
247
  "typedoc": "0.28.5",
248
- "vitest": "3.2.3"
248
+ "vitest": "3.2.4"
249
249
  };
250
250
  var packageManager = "yarn@4.9.2";
251
251
  var engines = { "node": ">=20" };
@@ -575,7 +575,13 @@ var CodeGenConfig = class {
575
575
  InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
576
576
  EnumUsageKey: (enumStruct, key) => `${enumStruct}.${key}`,
577
577
  EnumField: (key, value) => `${key} = ${value}`,
578
- EnumFieldsWrapper: (contents) => lodash.map(contents, ({ key, value }) => ` ${this.Ts.EnumField(key, value)}`).join(",\n"),
578
+ EnumFieldDescription: (description$1) => {
579
+ if (description$1) return ` /** ${description$1} */`;
580
+ else return "";
581
+ },
582
+ EnumFieldsWrapper: (contents) => lodash.map(contents, ({ key, value, description: description$1 }) => {
583
+ return [this.Ts.EnumFieldDescription(description$1), ` ${this.Ts.EnumField(key, value)}`].filter(Boolean).join("\n");
584
+ }).join(",\n"),
579
585
  ObjectWrapper: (content) => `{\n${content}\n}`,
580
586
  MultilineComment: (contents, formatFn) => [...contents.length === 1 ? [`/** ${contents[0]} */`] : [
581
587
  "/**",
@@ -1139,6 +1145,7 @@ var EnumSchemaParser = class extends MonoSchemaParser {
1139
1145
  })) }, this.typeName, this.schemaPath);
1140
1146
  const keyType = this.schemaUtils.getSchemaType(this.schema);
1141
1147
  const enumNames = this.schemaUtils.getEnumNames(this.schema);
1148
+ const enumDescriptions = this.schemaUtils.getEnumDescriptions(this.schema);
1142
1149
  let content = null;
1143
1150
  const formatValue = (value) => {
1144
1151
  if (value === null) return this.config.Ts.NullValue(value);
@@ -1155,19 +1162,22 @@ var EnumSchemaParser = class extends MonoSchemaParser {
1155
1162
  if (this.config.enumNamesAsValues || enumValue === void 0) return {
1156
1163
  key: formattedKey,
1157
1164
  type: this.config.Ts.Keyword.String,
1158
- value: this.config.Ts.StringValue(enumName)
1165
+ value: this.config.Ts.StringValue(enumName),
1166
+ description: enumDescriptions?.[index]
1159
1167
  };
1160
1168
  return {
1161
1169
  key: formattedKey,
1162
1170
  type: keyType,
1163
- value: formatValue(enumValue)
1171
+ value: formatValue(enumValue),
1172
+ description: enumDescriptions?.[index]
1164
1173
  };
1165
1174
  });
1166
- else content = this.schema.enum.map((value) => {
1175
+ else content = this.schema.enum.map((value, index) => {
1167
1176
  return {
1168
1177
  key: this.formatEnumKey({ value }),
1169
1178
  type: keyType,
1170
- value: formatValue(value)
1179
+ value: formatValue(value),
1180
+ description: enumDescriptions?.[index]
1171
1181
  };
1172
1182
  });
1173
1183
  return {
@@ -1498,6 +1508,9 @@ var SchemaUtils = class {
1498
1508
  getEnumNames = (schema) => {
1499
1509
  return schema["x-enumNames"] || schema.xEnumNames || schema["x-enumnames"] || schema["x-enum-varnames"];
1500
1510
  };
1511
+ getEnumDescriptions = (schema) => {
1512
+ return schema["x-enumDescriptions"] || schema.xEnumDescriptions || schema["x-enumdescriptions"] || schema["x-enum-descriptions"];
1513
+ };
1501
1514
  getSchemaRefType = (schema) => {
1502
1515
  if (!this.isRefSchema(schema)) return null;
1503
1516
  return this.schemaComponentsMap.get(schema.$ref);
@@ -3124,4 +3137,4 @@ async function generateApi(config) {
3124
3137
 
3125
3138
  //#endregion
3126
3139
  export { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, constants_exports, generateApi, generateTemplates, package_default };
3127
- //# sourceMappingURL=src-BYbyXNbU.js.map
3140
+ //# sourceMappingURL=src-Dg3yZCMd.js.map