swagger-typescript-api 13.12.3 → 13.12.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.
@@ -212,7 +212,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
212
212
  //#endregion
213
213
  //#region package.json
214
214
  var name = "swagger-typescript-api";
215
- var version = "13.12.3";
215
+ var version = "13.12.5";
216
216
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
217
217
  //#endregion
218
218
  //#region src/constants.ts
@@ -302,6 +302,7 @@ const TsKeyword = {
302
302
  String: "string",
303
303
  Boolean: "boolean",
304
304
  Any: "any",
305
+ Never: "never",
305
306
  Void: "void",
306
307
  Unknown: "unknown",
307
308
  Null: "null",
@@ -1083,6 +1084,7 @@ var ArraySchemaParser = class extends MonoSchemaParser {
1083
1084
  var ComplexSchemaParser = class extends MonoSchemaParser {
1084
1085
  parse() {
1085
1086
  const complexType = this.schemaUtils.getComplexType(this.schema);
1087
+ const complexSchemaItems = Array.isArray(this.schema[complexType]) ? this.schema[complexType] : [];
1086
1088
  const simpleSchema = (0, es_toolkit.omit)(this.schema, Object.keys(this.schemaParser._complexSchemaParsers));
1087
1089
  const complexSchemaContent = this.schemaParser._complexSchemaParsers[complexType](this.schema);
1088
1090
  return {
@@ -1093,7 +1095,7 @@ var ComplexSchemaParser = class extends MonoSchemaParser {
1093
1095
  type: SCHEMA_TYPES$1.PRIMITIVE,
1094
1096
  typeIdentifier: this.config.Ts.Keyword.Type,
1095
1097
  name: this.typeName,
1096
- description: this.schemaFormatters.formatDescription(this.schema.description || (0, es_toolkit.compact)((this.schema[complexType] || []).map((item) => item?.description))[0] || ""),
1098
+ description: this.schemaFormatters.formatDescription(this.schema.description || (0, es_toolkit.compact)(complexSchemaItems.map((item) => item.description))[0] || ""),
1097
1099
  content: this.config.Ts.IntersectionType((0, es_toolkit.compact)([this.config.Ts.ExpressionGroup(complexSchemaContent), this.schemaUtils.getInternalSchemaType(simpleSchema) === SCHEMA_TYPES$1.OBJECT && this.config.Ts.ExpressionGroup(this.schemaParserFabric.createSchemaParser({
1098
1100
  schema: simpleSchema,
1099
1101
  schemaPath: this.schemaPath
@@ -1415,11 +1417,13 @@ var ObjectSchemaParser = class extends MonoSchemaParser {
1415
1417
  const readOnly = property.readOnly;
1416
1418
  const complexType = this.schemaUtils.getComplexType(property);
1417
1419
  const rawDataComplexType = this.schemaUtils.getComplexType(rawTypeData);
1420
+ const propertyComplexSchemaItems = Array.isArray(property[complexType]) ? property[complexType] : [];
1421
+ const rawDataComplexSchemaItems = Array.isArray(rawTypeData[rawDataComplexType]) ? rawTypeData[rawDataComplexType] : [];
1418
1422
  propertiesContent.push({
1419
1423
  ...property,
1420
1424
  $$raw: property,
1421
1425
  title: property.title,
1422
- description: property.description || (0, es_toolkit.compact)((property[complexType] || []).map((item) => item?.description))[0] || rawTypeData.description || (0, es_toolkit.compact)((rawTypeData[rawDataComplexType] || []).map((item) => item?.description))[0] || "",
1426
+ description: property.description || (0, es_toolkit.compact)(propertyComplexSchemaItems.map((item) => item?.description))[0] || rawTypeData.description || (0, es_toolkit.compact)(rawDataComplexSchemaItems.map((item) => item?.description))[0] || "",
1423
1427
  isRequired: required,
1424
1428
  isNullable: nullable,
1425
1429
  name: fieldName,
@@ -1599,6 +1603,7 @@ var SchemaParser = class {
1599
1603
  }
1600
1604
  };
1601
1605
  parseSchema = () => {
1606
+ if (typeof this.schema === "boolean") return this._baseSchemaParsers[SCHEMA_TYPES$1.PRIMITIVE]({ type: this.schema ? this.config.Ts.Keyword.Any : this.config.Ts.Keyword.Never }, this.typeName);
1602
1607
  if (!this.schema) return this._baseSchemaParsers[SCHEMA_TYPES$1.PRIMITIVE](null, this.typeName);
1603
1608
  let schemaType = null;
1604
1609
  let parsedSchema = null;
@@ -3325,14 +3330,23 @@ var Request = class {
3325
3330
  }
3326
3331
  async download({ url, authToken, ...options }) {
3327
3332
  const requestOptions = {};
3328
- if (authToken) requestOptions.headers = { Authorization: authToken };
3333
+ if (authToken && isSameHttpOrigin(url, this.config.url)) requestOptions.headers = { Authorization: authToken };
3329
3334
  (0, es_toolkit.merge)((0, es_toolkit.merge)(requestOptions, options), this.config.requestOptions || {});
3335
+ const response = await fetchRemoteSchemaResponse(url, requestOptions, {
3336
+ specSourceUrl: this.config.url || void 0,
3337
+ allowExplicitSpecUrl: true
3338
+ });
3339
+ if (!response) {
3340
+ const message = `URL "${url}" is not allowed for fetching`;
3341
+ consola.consola.error(message);
3342
+ throw new Error(message);
3343
+ }
3330
3344
  try {
3331
- return await (await fetch(url, requestOptions)).text();
3345
+ return await response.text();
3332
3346
  } catch (error) {
3333
3347
  const message = `error while fetching data from URL "${url}"`;
3334
3348
  consola.consola.error(message, error);
3335
- return message;
3349
+ throw new Error(message);
3336
3350
  }
3337
3351
  }
3338
3352
  };
@@ -4323,4 +4337,4 @@ Object.defineProperty(exports, "version", {
4323
4337
  }
4324
4338
  });
4325
4339
 
4326
- //# sourceMappingURL=src-Dqk6KdDX.cjs.map
4340
+ //# sourceMappingURL=src-COCr3_qu.cjs.map