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.
@@ -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.5";
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.5",
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.5",
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 {
@@ -1239,12 +1249,21 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
1239
1249
  })
1240
1250
  };
1241
1251
  });
1242
- if (additionalProperties) propertiesContent.push({
1243
- $$raw: { additionalProperties },
1244
- description: "",
1245
- isRequired: false,
1246
- field: this.config.Ts.InterfaceDynamicField(this.config.Ts.Keyword.String, this.config.Ts.Keyword.Any)
1247
- });
1252
+ if (additionalProperties) {
1253
+ const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(schema);
1254
+ let interfaceKeysContent;
1255
+ if (propertyNamesSchema) interfaceKeysContent = this.schemaParserFabric.createSchemaParser({
1256
+ schema: propertyNamesSchema,
1257
+ schemaPath: this.schemaPath
1258
+ }).getInlineParseContent();
1259
+ else interfaceKeysContent = this.config.Ts.Keyword.String;
1260
+ propertiesContent.push({
1261
+ $$raw: { additionalProperties },
1262
+ description: "",
1263
+ isRequired: false,
1264
+ field: this.config.Ts.InterfaceDynamicField(interfaceKeysContent, this.config.Ts.Keyword.Any)
1265
+ });
1266
+ }
1248
1267
  return propertiesContent;
1249
1268
  };
1250
1269
  };
@@ -1256,11 +1275,20 @@ var PrimitiveSchemaParser = class extends MonoSchemaParser {
1256
1275
  let contentType = null;
1257
1276
  const { additionalProperties, type: type$1, description: description$1, items } = this.schema || {};
1258
1277
  if (type$1 === this.config.Ts.Keyword.Object && additionalProperties) {
1259
- const fieldType = typeof additionalProperties === "object" ? this.schemaParserFabric.createSchemaParser({
1278
+ const propertyNamesSchema = this.schemaUtils.getSchemaPropertyNamesSchema(this.schema);
1279
+ let recordKeysContent;
1280
+ let recordValuesContent;
1281
+ if (propertyNamesSchema) recordKeysContent = this.schemaParserFabric.createSchemaParser({
1282
+ schema: propertyNamesSchema,
1283
+ schemaPath: this.schemaPath
1284
+ }).getInlineParseContent();
1285
+ else recordKeysContent = this.config.Ts.Keyword.String;
1286
+ if (typeof additionalProperties === "object") recordValuesContent = this.schemaParserFabric.createSchemaParser({
1260
1287
  schema: additionalProperties,
1261
1288
  schemaPath: this.schemaPath
1262
- }).getInlineParseContent() : this.config.Ts.Keyword.Any;
1263
- contentType = this.config.Ts.RecordType(this.config.Ts.Keyword.String, fieldType);
1289
+ }).getInlineParseContent();
1290
+ else recordValuesContent = this.config.Ts.Keyword.Any;
1291
+ contentType = this.config.Ts.RecordType(recordKeysContent, recordValuesContent);
1264
1292
  }
1265
1293
  if (Array.isArray(type$1) && type$1.length) contentType = this.schemaParser._complexSchemaParsers.oneOf({
1266
1294
  ...typeof this.schema === "object" ? this.schema : {},
@@ -1498,6 +1526,13 @@ var SchemaUtils = class {
1498
1526
  getEnumNames = (schema) => {
1499
1527
  return schema["x-enumNames"] || schema.xEnumNames || schema["x-enumnames"] || schema["x-enum-varnames"];
1500
1528
  };
1529
+ getEnumDescriptions = (schema) => {
1530
+ return schema["x-enumDescriptions"] || schema.xEnumDescriptions || schema["x-enumdescriptions"] || schema["x-enum-descriptions"];
1531
+ };
1532
+ getSchemaPropertyNamesSchema = (schema) => {
1533
+ if (!schema) return null;
1534
+ return schema.propertyNames || schema["x-propertyNames"] || null;
1535
+ };
1501
1536
  getSchemaRefType = (schema) => {
1502
1537
  if (!this.isRefSchema(schema)) return null;
1503
1538
  return this.schemaComponentsMap.get(schema.$ref);
@@ -3124,4 +3159,4 @@ async function generateApi(config) {
3124
3159
 
3125
3160
  //#endregion
3126
3161
  export { CodeGenConfig, HTTP_CLIENT, TemplatesGenConfig, constants_exports, generateApi, generateTemplates, package_default };
3127
- //# sourceMappingURL=src-BYbyXNbU.js.map
3162
+ //# sourceMappingURL=src-DW0ilIpJ.js.map