swagger-typescript-api 13.2.17 → 13.2.18

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.17";
180
+ var version = "13.2.18";
181
181
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
182
182
 
183
183
  //#endregion
@@ -246,6 +246,17 @@ const SCHEMA_TYPES$1 = {
246
246
  COMPLEX_UNKNOWN: "__unknown"
247
247
  };
248
248
 
249
+ //#endregion
250
+ //#region src/util/object-assign.ts
251
+ const objectAssign = (target, updater) => {
252
+ if (!updater) return;
253
+ const update = typeof updater === "function" ? updater(target) : updater;
254
+ if (!update) return;
255
+ const undefinedKeys = Object.entries(update).filter(([, value]) => value === void 0).map(([key]) => key);
256
+ merge(target, update);
257
+ for (const key of undefinedKeys) target[key] = void 0;
258
+ };
259
+
249
260
  //#endregion
250
261
  //#region src/configuration.ts
251
262
  const TsKeyword = {
@@ -556,8 +567,8 @@ var CodeGenConfig = class {
556
567
  ];
557
568
  templateExtensions = [".eta", ".ejs"];
558
569
  constructor({ codeGenConstructs, primitiveTypeConstructs, constants, templateInfos, hooks, ...otherConfig }) {
559
- Object.assign(this.Ts, codeGenConstructs);
560
- Object.assign(this.primitiveTypes, primitiveTypeConstructs);
570
+ objectAssign(this.Ts, codeGenConstructs);
571
+ objectAssign(this.primitiveTypes, primitiveTypeConstructs);
561
572
  this.defaultResponseType = this.Ts.Keyword.Void;
562
573
  this.update({
563
574
  ...otherConfig,
@@ -577,7 +588,7 @@ var CodeGenConfig = class {
577
588
  this.componentTypeNameResolver = new ComponentTypeNameResolver(this, []);
578
589
  }
579
590
  update = (update) => {
580
- Object.assign(this, update);
591
+ objectAssign(this, update);
581
592
  if (this.enumNamesAsValues) this.extractEnums = true;
582
593
  };
583
594
  };
@@ -657,10 +668,14 @@ var SchemaFormatters = class {
657
668
  $content: parsedSchema.content,
658
669
  content: this.config.Ts.UnionType(parsedSchema.content.map(({ value }) => value))
659
670
  };
671
+ const escapedContent = parsedSchema.content.map((item) => ({
672
+ ...item,
673
+ description: item.description ? this.escapeJSDocContent(item.description) : ""
674
+ }));
660
675
  return {
661
676
  ...parsedSchema,
662
677
  $content: parsedSchema.content,
663
- content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content)
678
+ content: this.config.Ts.EnumFieldsWrapper(escapedContent)
664
679
  };
665
680
  },
666
681
  [SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
@@ -702,11 +717,16 @@ var SchemaFormatters = class {
702
717
  const schemaType = get(parsedSchema, ["schemaType"]) || get(parsedSchema, ["$parsed", "schemaType"]);
703
718
  return get(this, [formatType, schemaType])?.(parsedSchema) || parsedSchema;
704
719
  };
720
+ escapeJSDocContent = (content) => {
721
+ if (content === void 0) return "";
722
+ return (typeof content === "string" ? content : String(content)).replace(/\*\//g, "*\\/");
723
+ };
705
724
  formatDescription = (description, inline) => {
706
725
  if (!description) return "";
707
- if (!description.includes("\n")) return description;
708
- if (inline) return compact(description.split(/\n/g).map((part) => part.trim())).join(" ");
709
- return description.replace(/\n$/g, "");
726
+ const escapedDescription = this.escapeJSDocContent(description);
727
+ if (!escapedDescription.includes("\n")) return escapedDescription;
728
+ if (inline) return compact(escapedDescription.split(/\n/g).map((part) => part.trim())).join(" ");
729
+ return escapedDescription.replace(/\n$/g, "");
710
730
  };
711
731
  formatObjectContent = (content) => {
712
732
  const fields = [];
@@ -1273,7 +1293,7 @@ var SchemaParser = class {
1273
1293
  schemaWalker;
1274
1294
  typeName;
1275
1295
  schema;
1276
- schemaPath = [];
1296
+ schemaPath;
1277
1297
  constructor(schemaParserFabric, { typeName, schema, schemaPath } = {}) {
1278
1298
  this.schemaParserFabric = schemaParserFabric;
1279
1299
  this.config = schemaParserFabric.config;
@@ -2703,6 +2723,7 @@ var CodeGenProcess = class {
2703
2723
  utils: {
2704
2724
  Ts: this.config.Ts,
2705
2725
  formatDescription: this.schemaParserFabric.schemaFormatters.formatDescription,
2726
+ escapeJSDocContent: this.schemaParserFabric.schemaFormatters.escapeJSDocContent,
2706
2727
  internalCase: camelCase,
2707
2728
  classNameCase: pascalCase,
2708
2729
  pascalCase,
@@ -2920,7 +2941,7 @@ var TemplatesGenConfig = class {
2920
2941
  this.update(config);
2921
2942
  }
2922
2943
  update = (update) => {
2923
- Object.assign(this, update);
2944
+ objectAssign(this, update);
2924
2945
  };
2925
2946
  };
2926
2947
 
@@ -3036,4 +3057,4 @@ async function generateTemplates(config) {
3036
3057
 
3037
3058
  //#endregion
3038
3059
  export { CodeGenProcess as a, constants_exports as c, version as d, SCHEMA_TYPES as i, description as l, TemplatesGenConfig as n, CodeGenConfig as o, RequestContentKind as r, HTTP_CLIENT as s, generateTemplates as t, name as u };
3039
- //# sourceMappingURL=generate-templates-BO-5CKCm.mjs.map
3060
+ //# sourceMappingURL=generate-templates-DGQlyLhe.mjs.map