swagger-typescript-api 13.2.3 → 13.2.5

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,17 @@
1
1
  # swagger-typescript-api
2
2
 
3
+ ## 13.2.5
4
+
5
+ ### Patch Changes
6
+
7
+ - [#1302](https://github.com/acacode/swagger-typescript-api/pull/1302) [`790fece`](https://github.com/acacode/swagger-typescript-api/commit/790fecea92920ecc996d90dbad5a984421e16aa8) Thanks [@js2me](https://github.com/js2me)! - added support x-propertyNames, propertyNames for object types
8
+
9
+ ## 13.2.4
10
+
11
+ ### Patch Changes
12
+
13
+ - [#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
14
+
3
15
  ## 13.2.3
4
16
 
5
17
  ### 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-B15eFEWm.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-DW0ilIpJ.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-B15eFEWm.cjs');
2
2
 
3
3
  Object.defineProperty(exports, 'constants', {
4
4
  enumerable: true,
package/dist/lib.d.cts CHANGED
@@ -136,6 +136,8 @@ 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;
140
+ getSchemaPropertyNamesSchema: (schema: any) => any;
139
141
  getSchemaRefType: (schema: any) => SchemaComponent | null;
140
142
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
141
143
  isNullMissingInType: (schema: any, type: any) => any;
@@ -496,6 +498,7 @@ declare class CodeGenProcess {
496
498
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
497
499
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
498
500
  EnumField: (key: unknown, value: unknown) => string;
501
+ EnumFieldDescription: (description: any) => string;
499
502
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
500
503
  ObjectWrapper: (content: unknown) => string;
501
504
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -600,6 +603,7 @@ declare class CodeGenProcess {
600
603
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
601
604
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
602
605
  EnumField: (key: unknown, value: unknown) => string;
606
+ EnumFieldDescription: (description: any) => string;
603
607
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
604
608
  ObjectWrapper: (content: unknown) => string;
605
609
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1394,8 +1398,15 @@ declare class CodeGenConfig {
1394
1398
  */
1395
1399
  EnumField: (key: unknown, value: unknown) => string;
1396
1400
  /**
1401
+ * /\** description \*\/
1402
+ */
1403
+ EnumFieldDescription: (description: any) => string;
1404
+ /**
1405
+ * /\** $A0.description \*\/
1397
1406
  * $A0.key = $A0.value,
1407
+ * /\** $A1.description \*\/
1398
1408
  * $A1.key = $A1.value,
1409
+ * /\** $AN.description \*\/
1399
1410
  * $AN.key = $AN.value,
1400
1411
  */
1401
1412
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
@@ -1545,6 +1556,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1545
1556
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
1546
1557
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1547
1558
  EnumField: (key: unknown, value: unknown) => string;
1559
+ EnumFieldDescription: (description: any) => string;
1548
1560
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1549
1561
  ObjectWrapper: (content: unknown) => string;
1550
1562
  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,8 @@ 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;
139
+ getSchemaPropertyNamesSchema: (schema: any) => any;
138
140
  getSchemaRefType: (schema: any) => SchemaComponent | null;
139
141
  isPropertyRequired: (name: any, propertySchema: any, rootSchema: any) => any;
140
142
  isNullMissingInType: (schema: any, type: any) => any;
@@ -495,6 +497,7 @@ declare class CodeGenProcess {
495
497
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
496
498
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
497
499
  EnumField: (key: unknown, value: unknown) => string;
500
+ EnumFieldDescription: (description: any) => string;
498
501
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
499
502
  ObjectWrapper: (content: unknown) => string;
500
503
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -599,6 +602,7 @@ declare class CodeGenProcess {
599
602
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
600
603
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
601
604
  EnumField: (key: unknown, value: unknown) => string;
605
+ EnumFieldDescription: (description: any) => string;
602
606
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
603
607
  ObjectWrapper: (content: unknown) => string;
604
608
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -911,7 +915,7 @@ type RawRouteInfo = {
911
915
  description?: string;
912
916
  tags?: string[];
913
917
  summary?: string;
914
- responses?: swagger_schema_official17.Spec["responses"];
918
+ responses?: swagger_schema_official16.Spec["responses"];
915
919
  produces?: string[];
916
920
  requestBody?: object;
917
921
  consumes?: string[];
@@ -1144,7 +1148,7 @@ interface GenerateApiConfiguration {
1144
1148
  fmtToJSDocLine: (line: string, params?: {
1145
1149
  eol?: boolean;
1146
1150
  }) => string;
1147
- _: lodash20.LoDashStatic;
1151
+ _: lodash19.LoDashStatic;
1148
1152
  require: (path: string) => unknown;
1149
1153
  };
1150
1154
  }
@@ -1165,7 +1169,7 @@ interface GenerateApiOutput {
1165
1169
  content: string;
1166
1170
  withPrefix: boolean;
1167
1171
  }) => void;
1168
- renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta21.EtaConfig>) => Promise<string> | string;
1172
+ renderTemplate: (templateContent: string, data: Record<string, unknown>, etaOptions?: Partial<eta20.EtaConfig>) => Promise<string> | string;
1169
1173
  getTemplate: (params: {
1170
1174
  fileName?: string;
1171
1175
  name?: string;
@@ -1393,8 +1397,15 @@ declare class CodeGenConfig {
1393
1397
  */
1394
1398
  EnumField: (key: unknown, value: unknown) => string;
1395
1399
  /**
1400
+ * /\** description \*\/
1401
+ */
1402
+ EnumFieldDescription: (description: any) => string;
1403
+ /**
1404
+ * /\** $A0.description \*\/
1396
1405
  * $A0.key = $A0.value,
1406
+ * /\** $A1.description \*\/
1397
1407
  * $A1.key = $A1.value,
1408
+ * /\** $AN.description \*\/
1398
1409
  * $AN.key = $AN.value,
1399
1410
  */
1400
1411
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
@@ -1544,6 +1555,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1544
1555
  InterfaceDynamicField: (key: unknown, value: unknown) => string;
1545
1556
  EnumUsageKey: (enumStruct: unknown, key: unknown) => string;
1546
1557
  EnumField: (key: unknown, value: unknown) => string;
1558
+ EnumFieldDescription: (description: any) => string;
1547
1559
  EnumFieldsWrapper: (contents: Record<string, unknown>[]) => string;
1548
1560
  ObjectWrapper: (content: unknown) => string;
1549
1561
  MultilineComment: (contents: unknown[], formatFn: (arg: unknown) => unknown) => string[];
@@ -1579,7 +1591,7 @@ declare function generateApi(config: Partial<GenerateApiConfiguration["config"]>
1579
1591
  eol?: boolean | undefined;
1580
1592
  }) => string;
1581
1593
  NameResolver: typeof NameResolver;
1582
- _: lodash20.LoDashStatic;
1594
+ _: lodash19.LoDashStatic;
1583
1595
  require: (packageOrPath: string) => Promise<any>;
1584
1596
  };
1585
1597
  };
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-DW0ilIpJ.js";
2
2
 
3
3
  export { constants_exports as constants, generateApi, generateTemplates };
@@ -203,7 +203,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
203
203
  //#endregion
204
204
  //#region package.json
205
205
  var name = "swagger-typescript-api";
206
- var version = "13.2.3";
206
+ var version = "13.2.5";
207
207
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
208
208
  var homepage = "https://github.com/acacode/swagger-typescript-api";
209
209
  var bugs = "https://github.com/acacode/swagger-typescript-api/issues";
@@ -244,7 +244,7 @@ var scripts = {
244
244
  };
245
245
  var dependencies = {
246
246
  "@biomejs/js-api": "1.0.0",
247
- "@biomejs/wasm-nodejs": "2.0.0",
247
+ "@biomejs/wasm-nodejs": "2.0.5",
248
248
  "@types/swagger-schema-official": "^2.0.25",
249
249
  "c12": "^3.0.4",
250
250
  "citty": "^0.1.6",
@@ -258,20 +258,20 @@ var dependencies = {
258
258
  "typescript": "~5.8.3"
259
259
  };
260
260
  var devDependencies = {
261
- "@biomejs/biome": "2.0.0",
261
+ "@biomejs/biome": "2.0.5",
262
262
  "@changesets/changelog-github": "0.5.1",
263
- "@changesets/cli": "2.29.4",
263
+ "@changesets/cli": "2.29.5",
264
264
  "@tsconfig/node18": "18.2.4",
265
265
  "@tsconfig/strictest": "2.0.5",
266
266
  "@types/js-yaml": "4.0.9",
267
- "@types/lodash": "4.17.17",
267
+ "@types/lodash": "4.17.18",
268
268
  "@types/node": "24.0.3",
269
269
  "@types/swagger2openapi": "7.0.4",
270
270
  "axios": "1.10.0",
271
271
  "openapi-types": "12.1.3",
272
272
  "tsdown": "0.12.8",
273
273
  "typedoc": "0.28.5",
274
- "vitest": "3.2.3"
274
+ "vitest": "3.2.4"
275
275
  };
276
276
  var packageManager = "yarn@4.9.2";
277
277
  var engines = { "node": ">=20" };
@@ -601,7 +601,13 @@ var CodeGenConfig = class {
601
601
  InterfaceDynamicField: (key, value) => `[key: ${key}]: ${value}`,
602
602
  EnumUsageKey: (enumStruct, key) => `${enumStruct}.${key}`,
603
603
  EnumField: (key, value) => `${key} = ${value}`,
604
- EnumFieldsWrapper: (contents) => lodash.default.map(contents, ({ key, value }) => ` ${this.Ts.EnumField(key, value)}`).join(",\n"),
604
+ EnumFieldDescription: (description$1) => {
605
+ if (description$1) return ` /** ${description$1} */`;
606
+ else return "";
607
+ },
608
+ EnumFieldsWrapper: (contents) => lodash.default.map(contents, ({ key, value, description: description$1 }) => {
609
+ return [this.Ts.EnumFieldDescription(description$1), ` ${this.Ts.EnumField(key, value)}`].filter(Boolean).join("\n");
610
+ }).join(",\n"),
605
611
  ObjectWrapper: (content) => `{\n${content}\n}`,
606
612
  MultilineComment: (contents, formatFn) => [...contents.length === 1 ? [`/** ${contents[0]} */`] : [
607
613
  "/**",
@@ -1165,6 +1171,7 @@ var EnumSchemaParser = class extends MonoSchemaParser {
1165
1171
  })) }, this.typeName, this.schemaPath);
1166
1172
  const keyType = this.schemaUtils.getSchemaType(this.schema);
1167
1173
  const enumNames = this.schemaUtils.getEnumNames(this.schema);
1174
+ const enumDescriptions = this.schemaUtils.getEnumDescriptions(this.schema);
1168
1175
  let content = null;
1169
1176
  const formatValue = (value) => {
1170
1177
  if (value === null) return this.config.Ts.NullValue(value);
@@ -1181,19 +1188,22 @@ var EnumSchemaParser = class extends MonoSchemaParser {
1181
1188
  if (this.config.enumNamesAsValues || enumValue === void 0) return {
1182
1189
  key: formattedKey,
1183
1190
  type: this.config.Ts.Keyword.String,
1184
- value: this.config.Ts.StringValue(enumName)
1191
+ value: this.config.Ts.StringValue(enumName),
1192
+ description: enumDescriptions?.[index]
1185
1193
  };
1186
1194
  return {
1187
1195
  key: formattedKey,
1188
1196
  type: keyType,
1189
- value: formatValue(enumValue)
1197
+ value: formatValue(enumValue),
1198
+ description: enumDescriptions?.[index]
1190
1199
  };
1191
1200
  });
1192
- else content = this.schema.enum.map((value) => {
1201
+ else content = this.schema.enum.map((value, index) => {
1193
1202
  return {
1194
1203
  key: this.formatEnumKey({ value }),
1195
1204
  type: keyType,
1196
- value: formatValue(value)
1205
+ value: formatValue(value),
1206
+ description: enumDescriptions?.[index]
1197
1207
  };
1198
1208
  });
1199
1209
  return {
@@ -1265,12 +1275,21 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
1265
1275
  })
1266
1276
  };
1267
1277
  });
1268
- if (additionalProperties) propertiesContent.push({
1269
- $$raw: { additionalProperties },
1270
- description: "",
1271
- isRequired: false,
1272
- field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any)
1273
- });
1278
+ if (additionalProperties) {
1279
+ const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(schema);
1280
+ let interfaceKeysContent;
1281
+ if (propertyNamesSchema) interfaceKeysContent = this.schemaParserFabric.createSchemaParser({
1282
+ schema: propertyNamesSchema,
1283
+ schemaPath: this.schemaPath
1284
+ }).getInlineParseContent();
1285
+ else interfaceKeysContent = this.config.Ts.Keyword.String;
1286
+ propertiesContent.push({
1287
+ $$raw: { additionalProperties },
1288
+ description: "",
1289
+ isRequired: false,
1290
+ field: this.config.Ts.InterfaceDynamicField(interfaceKeysContent, this.config.Ts.Keyword.Any)
1291
+ });
1292
+ }
1274
1293
  return propertiesContent;
1275
1294
  };
1276
1295
  };
@@ -1282,11 +1301,20 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
1282
1301
  let contentType = null;
1283
1302
  const { additionalProperties, type: type$1, description: description$1, items } = this.schema || {};
1284
1303
  if (type$1 === this.config.Ts.Keyword.Object && additionalProperties) {
1285
- const fieldType = typeof additionalProperties === "object" ? this.schemaParserFabric.createSchemaParser({
1304
+ const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(this.schema);
1305
+ let recordKeysContent;
1306
+ let recordValuesContent;
1307
+ if (propertyNamesSchema) recordKeysContent = this.schemaParserFabric.createSchemaParser({
1308
+ schema: propertyNamesSchema,
1309
+ schemaPath: this.schemaPath
1310
+ }).getInlineParseContent();
1311
+ else recordKeysContent = this.config.Ts.Keyword.String;
1312
+ if (typeof additionalProperties === "object") recordValuesContent = this.schemaParserFabric.createSchemaParser({
1286
1313
  schema: additionalProperties,
1287
1314
  schemaPath: this.schemaPath
1288
- }).getInlineParseContent() : this.config.Ts.Keyword.Any;
1289
- contentType = this.config.Ts.RecordType(this.config.Ts.Keyword.String, fieldType);
1315
+ }).getInlineParseContent();
1316
+ else recordValuesContent = this.config.Ts.Keyword.Any;
1317
+ contentType = this.config.Ts.RecordType(recordKeysContent, recordValuesContent);
1290
1318
  }
1291
1319
  if (Array.isArray(type$1) && type$1.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
1292
1320
  ...typeof this.schema === "object" ? this.schema : {},
@@ -1524,6 +1552,13 @@ var SchemaUtils = class {
1524
1552
  getEnumNames = (schema) => {
1525
1553
  return schema["x-enumNames"] || schema.xEnumNames || schema["x-enumnames"] || schema["x-enum-varnames"];
1526
1554
  };
1555
+ getEnumDescriptions = (schema) => {
1556
+ return schema["x-enumDescriptions"] || schema.xEnumDescriptions || schema["x-enumdescriptions"] || schema["x-enum-descriptions"];
1557
+ };
1558
+ getSchemaPropertyNamesSchema = (schema) => {
1559
+ if (!schema) return null;
1560
+ return schema.propertyNames || schema["x-propertyNames"] || null;
1561
+ };
1527
1562
  getSchemaRefType = (schema) => {
1528
1563
  if (!this.isRefSchema(schema)) return null;
1529
1564
  return this.schemaComponentsMap.get(schema.$ref);
@@ -3197,4 +3232,4 @@ Object.defineProperty(exports, 'package_default', {
3197
3232
  return package_default;
3198
3233
  }
3199
3234
  });
3200
- //# sourceMappingURL=src-CD5LAKtC.cjs.map
3235
+ //# sourceMappingURL=src-B15eFEWm.cjs.map