swagger-typescript-api 13.6.3 → 13.6.4
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 +2 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +2 -1
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/{src-DqcUpLvd.cjs → src-NoDGo0Mg.cjs} +51 -24
- package/dist/src-NoDGo0Mg.cjs.map +1 -0
- package/dist/{src-Cs2Ms4ew.mjs → src-eiRlSfN6.mjs} +50 -23
- package/dist/src-eiRlSfN6.mjs.map +1 -0
- package/package.json +6 -6
- package/dist/src-Cs2Ms4ew.mjs.map +0 -1
- package/dist/src-DqcUpLvd.cjs.map +0 -1
|
@@ -13,9 +13,9 @@ import * as nanoid from "nanoid";
|
|
|
13
13
|
import { typeGuard } from "yummies/type-guard";
|
|
14
14
|
import * as crypto from "node:crypto";
|
|
15
15
|
import * as swagger2openapi from "swagger2openapi";
|
|
16
|
-
import * as YAML from "yaml";
|
|
17
16
|
import * as fs from "node:fs";
|
|
18
17
|
import SwaggerParser from "@apidevtools/swagger-parser";
|
|
18
|
+
import * as YAML from "yaml";
|
|
19
19
|
import * as url$1 from "node:url";
|
|
20
20
|
import url from "node:url";
|
|
21
21
|
import { Eta } from "eta";
|
|
@@ -174,7 +174,7 @@ var ComponentTypeNameResolver = class extends NameResolver {
|
|
|
174
174
|
//#endregion
|
|
175
175
|
//#region package.json
|
|
176
176
|
var name = "swagger-typescript-api";
|
|
177
|
-
var version = "13.6.
|
|
177
|
+
var version = "13.6.4";
|
|
178
178
|
var description = "Generate the API client for Fetch or Axios from an OpenAPI Specification";
|
|
179
179
|
//#endregion
|
|
180
180
|
//#region src/constants.ts
|
|
@@ -2327,6 +2327,48 @@ var SchemaRoutes = class {
|
|
|
2327
2327
|
};
|
|
2328
2328
|
};
|
|
2329
2329
|
//#endregion
|
|
2330
|
+
//#region src/util/parse-schema-content.ts
|
|
2331
|
+
function normalizeYamlEscapedLineBreaks(content) {
|
|
2332
|
+
let normalized = "";
|
|
2333
|
+
let inDoubleQuotedScalar = false;
|
|
2334
|
+
let escaped = false;
|
|
2335
|
+
for (let index = 0; index < content.length; index += 1) {
|
|
2336
|
+
const currentChar = content[index];
|
|
2337
|
+
if (!inDoubleQuotedScalar) {
|
|
2338
|
+
if (currentChar === "\"") inDoubleQuotedScalar = true;
|
|
2339
|
+
normalized += currentChar;
|
|
2340
|
+
continue;
|
|
2341
|
+
}
|
|
2342
|
+
if (escaped) {
|
|
2343
|
+
normalized += currentChar;
|
|
2344
|
+
escaped = false;
|
|
2345
|
+
continue;
|
|
2346
|
+
}
|
|
2347
|
+
if (currentChar === "\\") {
|
|
2348
|
+
const nextChar = content[index + 1];
|
|
2349
|
+
if (nextChar === "\n" || nextChar === "\r") {
|
|
2350
|
+
index += 1;
|
|
2351
|
+
if (nextChar === "\r" && content[index + 1] === "\n") index += 1;
|
|
2352
|
+
while (content[index + 1] === " " || content[index + 1] === " ") index += 1;
|
|
2353
|
+
continue;
|
|
2354
|
+
}
|
|
2355
|
+
normalized += currentChar;
|
|
2356
|
+
escaped = true;
|
|
2357
|
+
continue;
|
|
2358
|
+
}
|
|
2359
|
+
if (currentChar === "\"") inDoubleQuotedScalar = false;
|
|
2360
|
+
normalized += currentChar;
|
|
2361
|
+
}
|
|
2362
|
+
return normalized;
|
|
2363
|
+
}
|
|
2364
|
+
function parseSchemaContent(content) {
|
|
2365
|
+
try {
|
|
2366
|
+
return JSON.parse(content);
|
|
2367
|
+
} catch {
|
|
2368
|
+
return YAML.parse(normalizeYamlEscapedLineBreaks(content));
|
|
2369
|
+
}
|
|
2370
|
+
}
|
|
2371
|
+
//#endregion
|
|
2330
2372
|
//#region src/resolved-swagger-schema.ts
|
|
2331
2373
|
var ResolvedSwaggerSchema = class ResolvedSwaggerSchema {
|
|
2332
2374
|
parsedRefsCache = /* @__PURE__ */ new Map();
|
|
@@ -2392,11 +2434,10 @@ var ResolvedSwaggerSchema = class ResolvedSwaggerSchema {
|
|
|
2392
2434
|
if (!response.ok) return null;
|
|
2393
2435
|
const content = await response.text();
|
|
2394
2436
|
try {
|
|
2395
|
-
const parsed =
|
|
2437
|
+
const parsed = parseSchemaContent(content);
|
|
2396
2438
|
if (parsed && typeof parsed === "object") return parsed;
|
|
2397
2439
|
} catch {
|
|
2398
|
-
|
|
2399
|
-
if (parsed && typeof parsed === "object") return parsed;
|
|
2440
|
+
return null;
|
|
2400
2441
|
}
|
|
2401
2442
|
} catch (e) {
|
|
2402
2443
|
consola.debug(e);
|
|
@@ -2559,21 +2600,11 @@ var ResolvedSwaggerSchema = class ResolvedSwaggerSchema {
|
|
|
2559
2600
|
if (this.externalSchemaCache.has(filePath)) return this.externalSchemaCache.get(filePath) || null;
|
|
2560
2601
|
if (!fs.existsSync(filePath)) return null;
|
|
2561
2602
|
try {
|
|
2562
|
-
const
|
|
2563
|
-
const parsed = JSON.parse(content);
|
|
2603
|
+
const parsed = parseSchemaContent(fs.readFileSync(filePath, "utf8"));
|
|
2564
2604
|
this.externalSchemaCache.set(filePath, parsed);
|
|
2565
2605
|
return parsed;
|
|
2566
2606
|
} catch {
|
|
2567
|
-
|
|
2568
|
-
const content = fs.readFileSync(filePath, "utf8");
|
|
2569
|
-
const parsed = YAML.parse(content);
|
|
2570
|
-
if (parsed && typeof parsed === "object") {
|
|
2571
|
-
this.externalSchemaCache.set(filePath, parsed);
|
|
2572
|
-
return parsed;
|
|
2573
|
-
}
|
|
2574
|
-
} catch (e) {
|
|
2575
|
-
consola.debug(e);
|
|
2576
|
-
}
|
|
2607
|
+
consola.debug("Failed to parse external schema", filePath);
|
|
2577
2608
|
}
|
|
2578
2609
|
return null;
|
|
2579
2610
|
}
|
|
@@ -2770,11 +2801,7 @@ var SwaggerSchemaResolver = class {
|
|
|
2770
2801
|
}
|
|
2771
2802
|
processSwaggerSchemaFile(file) {
|
|
2772
2803
|
if (typeof file !== "string") return file;
|
|
2773
|
-
|
|
2774
|
-
return JSON.parse(file);
|
|
2775
|
-
} catch {
|
|
2776
|
-
return YAML.parse(file);
|
|
2777
|
-
}
|
|
2804
|
+
return parseSchemaContent(file);
|
|
2778
2805
|
}
|
|
2779
2806
|
normalizeRefValue(ref) {
|
|
2780
2807
|
const refWithoutSlashBeforeHash = ref.split("/#/").join("#/");
|
|
@@ -3513,4 +3540,4 @@ async function generateApi(config) {
|
|
|
3513
3540
|
//#endregion
|
|
3514
3541
|
export { SCHEMA_TYPES as a, constants_exports as c, version as d, RequestContentKind as i, description as l, generateTemplates as n, CodeGenConfig as o, TemplatesGenConfig as r, HTTP_CLIENT as s, generateApi as t, name as u };
|
|
3515
3542
|
|
|
3516
|
-
//# sourceMappingURL=src-
|
|
3543
|
+
//# sourceMappingURL=src-eiRlSfN6.mjs.map
|