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.
package/dist/cli.cjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- const require_generate_templates = require('./generate-templates-wjE78AWV.cjs');
2
+ const require_generate_templates = require('./generate-templates-C4JBmSNw.cjs');
3
3
  const require_index = require('./index.cjs');
4
4
  let node_path = require("node:path");
5
5
  node_path = require_generate_templates.__toESM(node_path);
package/dist/cli.mjs CHANGED
@@ -1,5 +1,5 @@
1
1
  #!/usr/bin/env node
2
- import { d as version, l as description, n as TemplatesGenConfig, o as CodeGenConfig, s as HTTP_CLIENT, t as generateTemplates, u as name } from "./generate-templates-BO-5CKCm.mjs";
2
+ import { d as version, l as description, n as TemplatesGenConfig, o as CodeGenConfig, s as HTTP_CLIENT, t as generateTemplates, u as name } from "./generate-templates-DGQlyLhe.mjs";
3
3
  import { generateApi } from "./index.mjs";
4
4
  import * as path$1 from "node:path";
5
5
  import { loadConfig } from "c12";
@@ -223,7 +223,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
223
223
  //#endregion
224
224
  //#region package.json
225
225
  var name = "swagger-typescript-api";
226
- var version = "13.2.17";
226
+ var version = "13.2.18";
227
227
  var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
228
228
 
229
229
  //#endregion
@@ -292,6 +292,17 @@ const SCHEMA_TYPES$1 = {
292
292
  COMPLEX_UNKNOWN: "__unknown"
293
293
  };
294
294
 
295
+ //#endregion
296
+ //#region src/util/object-assign.ts
297
+ const objectAssign = (target, updater) => {
298
+ if (!updater) return;
299
+ const update = typeof updater === "function" ? updater(target) : updater;
300
+ if (!update) return;
301
+ const undefinedKeys = Object.entries(update).filter(([, value]) => value === void 0).map(([key]) => key);
302
+ (0, es_toolkit.merge)(target, update);
303
+ for (const key of undefinedKeys) target[key] = void 0;
304
+ };
305
+
295
306
  //#endregion
296
307
  //#region src/configuration.ts
297
308
  const TsKeyword = {
@@ -602,8 +613,8 @@ var CodeGenConfig = class {
602
613
  ];
603
614
  templateExtensions = [".eta", ".ejs"];
604
615
  constructor({ codeGenConstructs, primitiveTypeConstructs, constants, templateInfos, hooks, ...otherConfig }) {
605
- Object.assign(this.Ts, codeGenConstructs);
606
- Object.assign(this.primitiveTypes, primitiveTypeConstructs);
616
+ objectAssign(this.Ts, codeGenConstructs);
617
+ objectAssign(this.primitiveTypes, primitiveTypeConstructs);
607
618
  this.defaultResponseType = this.Ts.Keyword.Void;
608
619
  this.update({
609
620
  ...otherConfig,
@@ -623,7 +634,7 @@ var CodeGenConfig = class {
623
634
  this.componentTypeNameResolver = new ComponentTypeNameResolver(this, []);
624
635
  }
625
636
  update = (update) => {
626
- Object.assign(this, update);
637
+ objectAssign(this, update);
627
638
  if (this.enumNamesAsValues) this.extractEnums = true;
628
639
  };
629
640
  };
@@ -703,10 +714,14 @@ var SchemaFormatters = class {
703
714
  $content: parsedSchema.content,
704
715
  content: this.config.Ts.UnionType(parsedSchema.content.map(({ value }) => value))
705
716
  };
717
+ const escapedContent = parsedSchema.content.map((item) => ({
718
+ ...item,
719
+ description: item.description ? this.escapeJSDocContent(item.description) : ""
720
+ }));
706
721
  return {
707
722
  ...parsedSchema,
708
723
  $content: parsedSchema.content,
709
- content: this.config.Ts.EnumFieldsWrapper(parsedSchema.content)
724
+ content: this.config.Ts.EnumFieldsWrapper(escapedContent)
710
725
  };
711
726
  },
712
727
  [SCHEMA_TYPES$1.OBJECT]: (parsedSchema) => {
@@ -748,11 +763,16 @@ var SchemaFormatters = class {
748
763
  const schemaType = (0, es_toolkit_compat.get)(parsedSchema, ["schemaType"]) || (0, es_toolkit_compat.get)(parsedSchema, ["$parsed", "schemaType"]);
749
764
  return (0, es_toolkit_compat.get)(this, [formatType, schemaType])?.(parsedSchema) || parsedSchema;
750
765
  };
766
+ escapeJSDocContent = (content) => {
767
+ if (content === void 0) return "";
768
+ return (typeof content === "string" ? content : String(content)).replace(/\*\//g, "*\\/");
769
+ };
751
770
  formatDescription = (description, inline) => {
752
771
  if (!description) return "";
753
- if (!description.includes("\n")) return description;
754
- if (inline) return (0, es_toolkit.compact)(description.split(/\n/g).map((part) => part.trim())).join(" ");
755
- return description.replace(/\n$/g, "");
772
+ const escapedDescription = this.escapeJSDocContent(description);
773
+ if (!escapedDescription.includes("\n")) return escapedDescription;
774
+ if (inline) return (0, es_toolkit.compact)(escapedDescription.split(/\n/g).map((part) => part.trim())).join(" ");
775
+ return escapedDescription.replace(/\n$/g, "");
756
776
  };
757
777
  formatObjectContent = (content) => {
758
778
  const fields = [];
@@ -1319,7 +1339,7 @@ var SchemaParser = class {
1319
1339
  schemaWalker;
1320
1340
  typeName;
1321
1341
  schema;
1322
- schemaPath = [];
1342
+ schemaPath;
1323
1343
  constructor(schemaParserFabric, { typeName, schema, schemaPath } = {}) {
1324
1344
  this.schemaParserFabric = schemaParserFabric;
1325
1345
  this.config = schemaParserFabric.config;
@@ -2749,6 +2769,7 @@ var CodeGenProcess = class {
2749
2769
  utils: {
2750
2770
  Ts: this.config.Ts,
2751
2771
  formatDescription: this.schemaParserFabric.schemaFormatters.formatDescription,
2772
+ escapeJSDocContent: this.schemaParserFabric.schemaFormatters.escapeJSDocContent,
2752
2773
  internalCase: es_toolkit_compat.camelCase,
2753
2774
  classNameCase: pascalCase,
2754
2775
  pascalCase,
@@ -2966,7 +2987,7 @@ var TemplatesGenConfig = class {
2966
2987
  this.update(config);
2967
2988
  }
2968
2989
  update = (update) => {
2969
- Object.assign(this, update);
2990
+ objectAssign(this, update);
2970
2991
  };
2971
2992
  };
2972
2993
 
@@ -3153,4 +3174,4 @@ Object.defineProperty(exports, 'version', {
3153
3174
  return version;
3154
3175
  }
3155
3176
  });
3156
- //# sourceMappingURL=generate-templates-wjE78AWV.cjs.map
3177
+ //# sourceMappingURL=generate-templates-C4JBmSNw.cjs.map