swagger-typescript-api 13.6.5 → 13.6.7
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 +1 -1
- package/dist/cli.mjs +1 -1
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts +11 -11
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +11 -11
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-9Z1llXJS.mjs → src--O_oZouc.mjs} +65 -15
- package/dist/src--O_oZouc.mjs.map +1 -0
- package/dist/{src-DNKGwk6n.cjs → src-CUhSthD5.cjs} +65 -15
- package/dist/src-CUhSthD5.cjs.map +1 -0
- package/package.json +10 -10
- package/dist/src-9Z1llXJS.mjs.map +0 -1
- package/dist/src-DNKGwk6n.cjs.map +0 -1
|
@@ -182,12 +182,6 @@ var NameResolver = class {
|
|
|
182
182
|
}
|
|
183
183
|
};
|
|
184
184
|
//#endregion
|
|
185
|
-
//#region src/util/random.ts
|
|
186
|
-
const getRandomInt = (min = 0, max = 1) => {
|
|
187
|
-
if (min === max) return min;
|
|
188
|
-
return Math.round(Math.random() * (max - min) + min);
|
|
189
|
-
};
|
|
190
|
-
//#endregion
|
|
191
185
|
//#region src/component-type-name-resolver.ts
|
|
192
186
|
var ComponentTypeNameResolver = class extends NameResolver {
|
|
193
187
|
counter = 1;
|
|
@@ -195,12 +189,12 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
195
189
|
countersByVariant = /* @__PURE__ */ new Map();
|
|
196
190
|
constructor(config, reservedNames) {
|
|
197
191
|
super(config, reservedNames, (variants) => {
|
|
198
|
-
const
|
|
199
|
-
if (
|
|
200
|
-
if (!this.countersByVariant.has(
|
|
201
|
-
const variantCounter = this.countersByVariant.get(
|
|
202
|
-
this.countersByVariant.set(
|
|
203
|
-
const dirtyResolvedName = `${
|
|
192
|
+
const baseVariant = (0, es_toolkit.uniq)((0, es_toolkit.compact)(variants)).sort((a, b) => a.localeCompare(b))[0];
|
|
193
|
+
if (baseVariant) {
|
|
194
|
+
if (!this.countersByVariant.has(baseVariant)) this.countersByVariant.set(baseVariant, 0);
|
|
195
|
+
const variantCounter = this.countersByVariant.get(baseVariant) + 1;
|
|
196
|
+
this.countersByVariant.set(baseVariant, variantCounter);
|
|
197
|
+
const dirtyResolvedName = `${baseVariant}${variantCounter}`;
|
|
204
198
|
consola.consola.debug("generated dirty resolved type name for component - ", dirtyResolvedName);
|
|
205
199
|
return dirtyResolvedName;
|
|
206
200
|
}
|
|
@@ -213,7 +207,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
213
207
|
//#endregion
|
|
214
208
|
//#region package.json
|
|
215
209
|
var name = "swagger-typescript-api";
|
|
216
|
-
var version = "13.6.
|
|
210
|
+
var version = "13.6.7";
|
|
217
211
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
218
212
|
//#endregion
|
|
219
213
|
//#region src/constants.ts
|
|
@@ -2367,6 +2361,61 @@ var SchemaRoutes = class {
|
|
|
2367
2361
|
};
|
|
2368
2362
|
//#endregion
|
|
2369
2363
|
//#region src/util/parse-schema-content.ts
|
|
2364
|
+
/**
|
|
2365
|
+
* Some OpenAPI YAML files use a double-quoted value that spans a newline without
|
|
2366
|
+
* a trailing `\` (invalid YAML 1.2; see acacode/swagger-typescript-api#1433):
|
|
2367
|
+
*
|
|
2368
|
+
* description: "first line
|
|
2369
|
+
* tail"
|
|
2370
|
+
*
|
|
2371
|
+
* `yaml` rejects that with "Missing closing quote". We fold it into one line using
|
|
2372
|
+
* an escaped newline inside the scalar: `"first line\ntail"`.
|
|
2373
|
+
*
|
|
2374
|
+
* If the first line ends with `\`, it is a normal YAML line continuation and is
|
|
2375
|
+
* left for {@link normalizeYamlEscapedLineBreaks}.
|
|
2376
|
+
*/
|
|
2377
|
+
function mergeBrokenDoubleQuotedMapLines(content) {
|
|
2378
|
+
const lines = content.split(/\r?\n|\r/);
|
|
2379
|
+
const result = [];
|
|
2380
|
+
for (let i = 0; i < lines.length; i += 1) {
|
|
2381
|
+
const current = lines[i];
|
|
2382
|
+
if (current === void 0) break;
|
|
2383
|
+
const following = lines[i + 1];
|
|
2384
|
+
const repaired = following === void 0 ? null : tryRepairSplitDoubleQuotedMapValue(current, following);
|
|
2385
|
+
if (repaired) {
|
|
2386
|
+
result.push(repaired);
|
|
2387
|
+
i += 1;
|
|
2388
|
+
continue;
|
|
2389
|
+
}
|
|
2390
|
+
result.push(current);
|
|
2391
|
+
}
|
|
2392
|
+
return result.join("\n");
|
|
2393
|
+
}
|
|
2394
|
+
function tryRepairSplitDoubleQuotedMapValue(line, nextLine) {
|
|
2395
|
+
const unterminated = matchMapKeyOpeningDoubleQuotedScalar(line);
|
|
2396
|
+
if (!unterminated) return null;
|
|
2397
|
+
const closing = matchSingleWordThenClosingQuote(nextLine);
|
|
2398
|
+
if (!closing) return null;
|
|
2399
|
+
const { keyPrefixAndQuote, valueBeforeBreak } = unterminated;
|
|
2400
|
+
const { closingWord } = closing;
|
|
2401
|
+
if (valueBeforeBreak.endsWith("\\")) return null;
|
|
2402
|
+
return `${keyPrefixAndQuote}${valueBeforeBreak}\\n${closingWord}"`;
|
|
2403
|
+
}
|
|
2404
|
+
/** ` foo: "text` with no `"` before end of line (value may be empty). */
|
|
2405
|
+
function matchMapKeyOpeningDoubleQuotedScalar(line) {
|
|
2406
|
+
const match = /^(\s+[A-Za-z_][\w-]*:\s*")([^"]*)$/.exec(line);
|
|
2407
|
+
if (!match?.[1] || match[2] === void 0) return null;
|
|
2408
|
+
return {
|
|
2409
|
+
keyPrefixAndQuote: match[1],
|
|
2410
|
+
valueBeforeBreak: match[2]
|
|
2411
|
+
};
|
|
2412
|
+
}
|
|
2413
|
+
/** ` word"` — only indentation, one identifier, closing quote. */
|
|
2414
|
+
function matchSingleWordThenClosingQuote(line) {
|
|
2415
|
+
const match = /^(\s*)([A-Za-z_][\w-]*)"\s*$/.exec(line);
|
|
2416
|
+
if (!match?.[2]) return null;
|
|
2417
|
+
return { closingWord: match[2] };
|
|
2418
|
+
}
|
|
2370
2419
|
function normalizeYamlEscapedLineBreaks(content) {
|
|
2371
2420
|
let normalized = "";
|
|
2372
2421
|
let inDoubleQuotedScalar = false;
|
|
@@ -2404,7 +2453,8 @@ function parseSchemaContent(content) {
|
|
|
2404
2453
|
try {
|
|
2405
2454
|
return JSON.parse(content);
|
|
2406
2455
|
} catch {
|
|
2407
|
-
|
|
2456
|
+
const merged = mergeBrokenDoubleQuotedMapLines(content);
|
|
2457
|
+
return yaml.parse(normalizeYamlEscapedLineBreaks(merged));
|
|
2408
2458
|
}
|
|
2409
2459
|
}
|
|
2410
2460
|
//#endregion
|
|
@@ -3650,4 +3700,4 @@ Object.defineProperty(exports, "version", {
|
|
|
3650
3700
|
}
|
|
3651
3701
|
});
|
|
3652
3702
|
|
|
3653
|
-
//# sourceMappingURL=src-
|
|
3703
|
+
//# sourceMappingURL=src-CUhSthD5.cjs.map
|