@hey-api/shared 0.2.6 → 0.4.0
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/index.d.mts +110 -9
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +315 -297
- package/dist/index.mjs.map +1 -1
- package/package.json +12 -13
package/dist/index.mjs
CHANGED
|
@@ -7,7 +7,6 @@ import * as semver from "semver";
|
|
|
7
7
|
import { getResolvedInput, sendRequest } from "@hey-api/json-schema-ref-parser";
|
|
8
8
|
import { fromRef, ref } from "@hey-api/codegen-core";
|
|
9
9
|
import { EOL } from "node:os";
|
|
10
|
-
|
|
11
10
|
//#region src/tsConfig.ts
|
|
12
11
|
function findPackageJson(initialDir) {
|
|
13
12
|
let dir = initialDir;
|
|
@@ -54,7 +53,6 @@ function findTsConfigPath(baseDir, tsConfigPath) {
|
|
|
54
53
|
}
|
|
55
54
|
return null;
|
|
56
55
|
}
|
|
57
|
-
|
|
58
56
|
//#endregion
|
|
59
57
|
//#region src/cli.ts
|
|
60
58
|
const textAscii = `
|
|
@@ -103,13 +101,11 @@ function printCliIntro(initialDir, showLogo = false) {
|
|
|
103
101
|
}
|
|
104
102
|
console.log("");
|
|
105
103
|
}
|
|
106
|
-
|
|
107
104
|
//#endregion
|
|
108
105
|
//#region src/fs.ts
|
|
109
106
|
function ensureDirSync(path) {
|
|
110
107
|
if (!fs.existsSync(path)) fs.mkdirSync(path, { recursive: true });
|
|
111
108
|
}
|
|
112
|
-
|
|
113
109
|
//#endregion
|
|
114
110
|
//#region src/error.ts
|
|
115
111
|
/**
|
|
@@ -135,6 +131,19 @@ var ConfigValidationError = class extends Error {
|
|
|
135
131
|
}
|
|
136
132
|
};
|
|
137
133
|
/**
|
|
134
|
+
* Represents an error caused by invalid or inaccessible input.
|
|
135
|
+
*
|
|
136
|
+
* Used for errors like file not found, URL not reachable, etc.
|
|
137
|
+
*/
|
|
138
|
+
var InputError = class extends Error {
|
|
139
|
+
originalError;
|
|
140
|
+
constructor(message, originalError) {
|
|
141
|
+
super(message);
|
|
142
|
+
this.name = "InputError";
|
|
143
|
+
this.originalError = originalError;
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
/**
|
|
138
147
|
* Represents a runtime error originating from a specific job.
|
|
139
148
|
*
|
|
140
149
|
* Used for reporting job-level failures that are not config validation errors.
|
|
@@ -163,7 +172,7 @@ var HeyApiError = class extends Error {
|
|
|
163
172
|
}
|
|
164
173
|
};
|
|
165
174
|
function logCrashReport(error, logsDir) {
|
|
166
|
-
if (error instanceof ConfigError || error instanceof ConfigValidationError) return;
|
|
175
|
+
if (error instanceof ConfigError || error instanceof ConfigValidationError || error instanceof InputError) return;
|
|
167
176
|
if (error instanceof JobError) error = error.originalError.error;
|
|
168
177
|
const logName = `openapi-ts-error-${Date.now()}.log`;
|
|
169
178
|
const fullDir = path.resolve(process.cwd(), logsDir);
|
|
@@ -203,6 +212,10 @@ async function openGitHubIssueWithCrashReport(error, initialDir) {
|
|
|
203
212
|
});
|
|
204
213
|
await open(`${packageJson.bugs.url}new?${search.toString()}`);
|
|
205
214
|
}
|
|
215
|
+
function getInputError(error) {
|
|
216
|
+
if (error instanceof InputError) return error;
|
|
217
|
+
if (error instanceof JobError && error.originalError.error instanceof InputError) return error.originalError.error;
|
|
218
|
+
}
|
|
206
219
|
function printCrashReport({ error, logPath }) {
|
|
207
220
|
if (error instanceof ConfigValidationError && error.errors.length) {
|
|
208
221
|
const groupByJob = /* @__PURE__ */ new Map();
|
|
@@ -227,6 +240,26 @@ function printCrashReport({ error, logPath }) {
|
|
|
227
240
|
jobPrefix = colors.gray(`[Job ${error.originalError.jobIndex + 1}] `);
|
|
228
241
|
error = error.originalError.error;
|
|
229
242
|
}
|
|
243
|
+
if (error instanceof InputError) {
|
|
244
|
+
const source = error.originalError.source;
|
|
245
|
+
const itemPrefixStr = ` `;
|
|
246
|
+
if (error.message.startsWith("Input request failed")) {
|
|
247
|
+
console.error(`${jobPrefix}${colors.red(`❌ ${error.message}`)}`);
|
|
248
|
+
if (source) console.error(colors.gray(source));
|
|
249
|
+
console.error(colors.gray("\nPlease verify that:"));
|
|
250
|
+
console.error(colors.gray(`${itemPrefixStr}• The URL is correct`));
|
|
251
|
+
console.error(colors.gray(`${itemPrefixStr}• Your API key is valid`));
|
|
252
|
+
console.error(colors.gray(`${itemPrefixStr}• You have network access`));
|
|
253
|
+
return;
|
|
254
|
+
}
|
|
255
|
+
console.error(`${jobPrefix}${colors.red("❌ Input file not found:")}`);
|
|
256
|
+
if (source) console.error(colors.gray(source));
|
|
257
|
+
console.error(colors.gray("\nPlease verify that:"));
|
|
258
|
+
console.error(colors.gray(`${itemPrefixStr}• The file exists`));
|
|
259
|
+
console.error(colors.gray(`${itemPrefixStr}• The path is correct`));
|
|
260
|
+
console.error(colors.gray(`${itemPrefixStr}• You have read permissions`));
|
|
261
|
+
return;
|
|
262
|
+
}
|
|
230
263
|
const baseString = colors.red("Failed with the message:");
|
|
231
264
|
console.error(`${jobPrefix}❌ ${baseString}`);
|
|
232
265
|
const itemPrefix = colors.red(` `);
|
|
@@ -238,7 +271,7 @@ function printCrashReport({ error, logPath }) {
|
|
|
238
271
|
}
|
|
239
272
|
}
|
|
240
273
|
async function shouldReportCrash({ error, isInteractive }) {
|
|
241
|
-
if (!isInteractive || error instanceof ConfigError || error instanceof ConfigValidationError) return false;
|
|
274
|
+
if (!isInteractive || error instanceof ConfigError || error instanceof ConfigValidationError || error instanceof InputError) return false;
|
|
242
275
|
return new Promise((resolve) => {
|
|
243
276
|
const jobPrefix = colors.gray("[root] ");
|
|
244
277
|
console.log(`${jobPrefix}${colors.yellow("📢 Open a GitHub issue with crash details? (y/N):")}`);
|
|
@@ -248,7 +281,6 @@ async function shouldReportCrash({ error, isInteractive }) {
|
|
|
248
281
|
});
|
|
249
282
|
});
|
|
250
283
|
}
|
|
251
|
-
|
|
252
284
|
//#endregion
|
|
253
285
|
//#region src/config/engine.ts
|
|
254
286
|
function checkNodeVersion() {
|
|
@@ -260,7 +292,6 @@ function checkNodeVersion() {
|
|
|
260
292
|
if (major < 20) throw new ConfigError(`Unsupported Node version ${process.versions.node}. Please use Node 20 or newer.`);
|
|
261
293
|
}
|
|
262
294
|
}
|
|
263
|
-
|
|
264
295
|
//#endregion
|
|
265
296
|
//#region src/utils/input/heyApi.ts
|
|
266
297
|
const registryRegExp$2 = /^([\w-]+)\/([\w-]+)(?:\?([\w=&.-]*))?$/;
|
|
@@ -315,7 +346,6 @@ function inputToHeyApiPath(input) {
|
|
|
315
346
|
registry: "hey-api"
|
|
316
347
|
};
|
|
317
348
|
}
|
|
318
|
-
|
|
319
349
|
//#endregion
|
|
320
350
|
//#region src/utils/input/readme.ts
|
|
321
351
|
const registryRegExp$1 = /^(@([\w-]+)\/([\w\-.]+)#)?([\w-]+)$/;
|
|
@@ -361,7 +391,6 @@ function inputToReadmePath(input) {
|
|
|
361
391
|
registry: "readme"
|
|
362
392
|
};
|
|
363
393
|
}
|
|
364
|
-
|
|
365
394
|
//#endregion
|
|
366
395
|
//#region src/utils/input/scalar.ts
|
|
367
396
|
const registryRegExp = /^(@[\w-]+)\/([\w.-]+)$/;
|
|
@@ -408,7 +437,6 @@ function inputToScalarPath(input) {
|
|
|
408
437
|
registry: "scalar"
|
|
409
438
|
};
|
|
410
439
|
}
|
|
411
|
-
|
|
412
440
|
//#endregion
|
|
413
441
|
//#region src/utils/input/index.ts
|
|
414
442
|
function inputToApiRegistry(input) {
|
|
@@ -422,7 +450,7 @@ function inputToApiRegistry(input) {
|
|
|
422
450
|
}
|
|
423
451
|
if (input.path.startsWith(".")) return;
|
|
424
452
|
if (input.path.startsWith("https://get.heyapi.dev")) {
|
|
425
|
-
input.path = input.path.slice(
|
|
453
|
+
input.path = input.path.slice(23);
|
|
426
454
|
Object.assign(input, inputToHeyApiPath(input));
|
|
427
455
|
return;
|
|
428
456
|
}
|
|
@@ -432,7 +460,6 @@ function inputToApiRegistry(input) {
|
|
|
432
460
|
return;
|
|
433
461
|
}
|
|
434
462
|
}
|
|
435
|
-
|
|
436
463
|
//#endregion
|
|
437
464
|
//#region src/config/input/input.ts
|
|
438
465
|
const defaultWatch = {
|
|
@@ -482,7 +509,6 @@ function getInput(userConfig) {
|
|
|
482
509
|
}
|
|
483
510
|
return inputs;
|
|
484
511
|
}
|
|
485
|
-
|
|
486
512
|
//#endregion
|
|
487
513
|
//#region src/config/input/path.ts
|
|
488
514
|
function compileInputPath(input) {
|
|
@@ -584,7 +610,6 @@ function logInputPaths(inputPaths, jobIndex) {
|
|
|
584
610
|
});
|
|
585
611
|
for (const line of lines) console.log(line);
|
|
586
612
|
}
|
|
587
|
-
|
|
588
613
|
//#endregion
|
|
589
614
|
//#region src/config/logs.ts
|
|
590
615
|
function getLogs(userLogs) {
|
|
@@ -600,7 +625,6 @@ function getLogs(userLogs) {
|
|
|
600
625
|
};
|
|
601
626
|
return logs;
|
|
602
627
|
}
|
|
603
|
-
|
|
604
628
|
//#endregion
|
|
605
629
|
//#region src/config/output/postprocess.ts
|
|
606
630
|
function postprocessOutput(config, postProcessors, jobPrefix) {
|
|
@@ -613,7 +637,6 @@ function postprocessOutput(config, postProcessors, jobPrefix) {
|
|
|
613
637
|
sync(resolved.command, args);
|
|
614
638
|
}
|
|
615
639
|
}
|
|
616
|
-
|
|
617
640
|
//#endregion
|
|
618
641
|
//#region src/config/utils/config.ts
|
|
619
642
|
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && typeof value !== "function";
|
|
@@ -657,7 +680,6 @@ const valueToObject = ({ defaultValue, mappers, value }) => {
|
|
|
657
680
|
}
|
|
658
681
|
return result;
|
|
659
682
|
};
|
|
660
|
-
|
|
661
683
|
//#endregion
|
|
662
684
|
//#region src/config/output/source/config.ts
|
|
663
685
|
function resolveSource(config) {
|
|
@@ -675,7 +697,6 @@ function resolveSource(config) {
|
|
|
675
697
|
else if (source.path === false) source.path = null;
|
|
676
698
|
return source;
|
|
677
699
|
}
|
|
678
|
-
|
|
679
700
|
//#endregion
|
|
680
701
|
//#region src/config/parser/config.ts
|
|
681
702
|
const defaultPaginationKeywords = [
|
|
@@ -774,7 +795,6 @@ function getParser(userConfig) {
|
|
|
774
795
|
value: userConfig.parser
|
|
775
796
|
});
|
|
776
797
|
}
|
|
777
|
-
|
|
778
798
|
//#endregion
|
|
779
799
|
//#region src/config/utils/dependencies.ts
|
|
780
800
|
const satisfies = (...args) => semver.satisfies(...args);
|
|
@@ -799,7 +819,6 @@ function dependencyFactory(dependencies) {
|
|
|
799
819
|
}
|
|
800
820
|
};
|
|
801
821
|
}
|
|
802
|
-
|
|
803
822
|
//#endregion
|
|
804
823
|
//#region src/debug/graph.ts
|
|
805
824
|
const analyzeStructure = (graph) => {
|
|
@@ -836,7 +855,6 @@ const graph = {
|
|
|
836
855
|
analyzeStructure,
|
|
837
856
|
exportForVisualization
|
|
838
857
|
};
|
|
839
|
-
|
|
840
858
|
//#endregion
|
|
841
859
|
//#region src/ir/parameter.ts
|
|
842
860
|
const getPaginationSchema = ({ context, parameter }) => {
|
|
@@ -905,7 +923,6 @@ const parameterWithPagination = ({ context, parameters }) => {
|
|
|
905
923
|
};
|
|
906
924
|
}
|
|
907
925
|
};
|
|
908
|
-
|
|
909
926
|
//#endregion
|
|
910
927
|
//#region src/ir/schema.ts
|
|
911
928
|
/**
|
|
@@ -957,7 +974,6 @@ function deduplicateSchema({ detectFormat = true, schema }) {
|
|
|
957
974
|
if (result.type === "unknown") return {};
|
|
958
975
|
return result;
|
|
959
976
|
}
|
|
960
|
-
|
|
961
977
|
//#endregion
|
|
962
978
|
//#region src/ir/utils.ts
|
|
963
979
|
/**
|
|
@@ -985,7 +1001,6 @@ function addItemsToSchema({ items, logicalOperator = "or", mutateSchemaOneItem =
|
|
|
985
1001
|
schema.items = items;
|
|
986
1002
|
return schema;
|
|
987
1003
|
}
|
|
988
|
-
|
|
989
1004
|
//#endregion
|
|
990
1005
|
//#region src/ir/operation.ts
|
|
991
1006
|
const hasOperationDataRequired = (operation) => {
|
|
@@ -1102,7 +1117,6 @@ const operationResponsesMap = (operation) => {
|
|
|
1102
1117
|
}
|
|
1103
1118
|
return result;
|
|
1104
1119
|
};
|
|
1105
|
-
|
|
1106
1120
|
//#endregion
|
|
1107
1121
|
//#region src/utils/naming/naming.ts
|
|
1108
1122
|
const uppercaseRegExp = /[\p{Lu}]/u;
|
|
@@ -1220,7 +1234,6 @@ function applyNaming(value, config) {
|
|
|
1220
1234
|
}
|
|
1221
1235
|
return toCase(result, casing);
|
|
1222
1236
|
}
|
|
1223
|
-
|
|
1224
1237
|
//#endregion
|
|
1225
1238
|
//#region src/openApi/shared/utils/operation.ts
|
|
1226
1239
|
const httpMethods = [
|
|
@@ -1278,7 +1291,6 @@ function operationToId({ context, count = 1, id, method, path, state }) {
|
|
|
1278
1291
|
}));
|
|
1279
1292
|
return result;
|
|
1280
1293
|
}
|
|
1281
|
-
|
|
1282
1294
|
//#endregion
|
|
1283
1295
|
//#region src/debug/ir.ts
|
|
1284
1296
|
const indent = (level) => " ".repeat(level);
|
|
@@ -1331,15 +1343,12 @@ const print = (ir, options = {}) => {
|
|
|
1331
1343
|
}
|
|
1332
1344
|
}
|
|
1333
1345
|
};
|
|
1334
|
-
const ir = { print };
|
|
1335
|
-
|
|
1336
1346
|
//#endregion
|
|
1337
1347
|
//#region src/debug/index.ts
|
|
1338
1348
|
const debugTools = {
|
|
1339
1349
|
graph,
|
|
1340
|
-
ir
|
|
1350
|
+
ir: { print }
|
|
1341
1351
|
};
|
|
1342
|
-
|
|
1343
1352
|
//#endregion
|
|
1344
1353
|
//#region src/getSpec.ts
|
|
1345
1354
|
const headersEntries = (headers) => {
|
|
@@ -1462,7 +1471,6 @@ async function getSpec({ fetchOptions, inputPath, timeout, watch }) {
|
|
|
1462
1471
|
resolvedInput
|
|
1463
1472
|
};
|
|
1464
1473
|
}
|
|
1465
|
-
|
|
1466
1474
|
//#endregion
|
|
1467
1475
|
//#region src/utils/minHeap.ts
|
|
1468
1476
|
var MinHeap = class {
|
|
@@ -1523,7 +1531,6 @@ var MinHeap = class {
|
|
|
1523
1531
|
}
|
|
1524
1532
|
}
|
|
1525
1533
|
};
|
|
1526
|
-
|
|
1527
1534
|
//#endregion
|
|
1528
1535
|
//#region src/graph/walk.ts
|
|
1529
1536
|
/**
|
|
@@ -1648,7 +1655,6 @@ const walk = (graph, callback, options) => {
|
|
|
1648
1655
|
if (options?.order === "topological") return walkTopological(graph, callback, options);
|
|
1649
1656
|
return walkDeclarations(graph, callback, options);
|
|
1650
1657
|
};
|
|
1651
|
-
|
|
1652
1658
|
//#endregion
|
|
1653
1659
|
//#region src/ir/graph.ts
|
|
1654
1660
|
const irTopLevelKinds = [
|
|
@@ -1711,7 +1717,6 @@ const getIrPointerPriority = (pointer) => {
|
|
|
1711
1717
|
if (result.matched) return kindPriority[result.kind] ?? defaultPriority;
|
|
1712
1718
|
return defaultPriority;
|
|
1713
1719
|
};
|
|
1714
|
-
|
|
1715
1720
|
//#endregion
|
|
1716
1721
|
//#region src/utils/ref.ts
|
|
1717
1722
|
const jsonPointerSlash = /~1/g;
|
|
@@ -1814,7 +1819,6 @@ function resolveRef({ $ref, spec }) {
|
|
|
1814
1819
|
}
|
|
1815
1820
|
return current;
|
|
1816
1821
|
}
|
|
1817
|
-
|
|
1818
1822
|
//#endregion
|
|
1819
1823
|
//#region src/plugins/shared/utils/instance.ts
|
|
1820
1824
|
const defaultGetFilePath = (symbol) => {
|
|
@@ -1982,9 +1986,6 @@ var PluginInstance = class {
|
|
|
1982
1986
|
if (!plugin) throw new Error(`plugin not found ${name}`);
|
|
1983
1987
|
return plugin;
|
|
1984
1988
|
}
|
|
1985
|
-
getSymbol(identifier) {
|
|
1986
|
-
return this.gen.symbols.get(identifier);
|
|
1987
|
-
}
|
|
1988
1989
|
hooks = { operation: {
|
|
1989
1990
|
isMutation: (operation) => this.isOperationKind(operation, "mutation"),
|
|
1990
1991
|
isQuery: (operation) => this.isOperationKind(operation, "query")
|
|
@@ -2148,7 +2149,6 @@ var PluginInstance = class {
|
|
|
2148
2149
|
return false;
|
|
2149
2150
|
}
|
|
2150
2151
|
};
|
|
2151
|
-
|
|
2152
2152
|
//#endregion
|
|
2153
2153
|
//#region src/ir/context.ts
|
|
2154
2154
|
var Context = class {
|
|
@@ -2259,7 +2259,6 @@ var Context = class {
|
|
|
2259
2259
|
});
|
|
2260
2260
|
}
|
|
2261
2261
|
};
|
|
2262
|
-
|
|
2263
2262
|
//#endregion
|
|
2264
2263
|
//#region src/ir/intents.ts
|
|
2265
2264
|
var IntentContext = class {
|
|
@@ -2279,7 +2278,6 @@ var IntentContext = class {
|
|
|
2279
2278
|
source["x-codeSamples"].push(example);
|
|
2280
2279
|
}
|
|
2281
2280
|
};
|
|
2282
|
-
|
|
2283
2281
|
//#endregion
|
|
2284
2282
|
//#region src/ir/schema-processor.ts
|
|
2285
2283
|
function createSchemaProcessor() {
|
|
@@ -2316,7 +2314,6 @@ function createSchemaProcessor() {
|
|
|
2316
2314
|
}
|
|
2317
2315
|
};
|
|
2318
2316
|
}
|
|
2319
|
-
|
|
2320
2317
|
//#endregion
|
|
2321
2318
|
//#region src/ir/schema-walker.ts
|
|
2322
2319
|
/**
|
|
@@ -2385,24 +2382,25 @@ function childContext(ctx, ...segments) {
|
|
|
2385
2382
|
path: ref([...fromRef(ctx.path), ...segments])
|
|
2386
2383
|
};
|
|
2387
2384
|
}
|
|
2388
|
-
|
|
2389
2385
|
//#endregion
|
|
2390
2386
|
//#region src/openApi/shared/utils/filter.ts
|
|
2391
2387
|
const namespaceNeedle = "/";
|
|
2392
|
-
|
|
2393
|
-
|
|
2388
|
+
function addNamespace(namespace, value = "") {
|
|
2389
|
+
return `${namespace}${namespaceNeedle}${value}`;
|
|
2390
|
+
}
|
|
2391
|
+
function removeNamespace(key) {
|
|
2394
2392
|
const index = key.indexOf(namespaceNeedle);
|
|
2395
2393
|
return {
|
|
2396
2394
|
name: key.slice(index + 1),
|
|
2397
2395
|
namespace: key.slice(0, index)
|
|
2398
2396
|
};
|
|
2399
|
-
}
|
|
2397
|
+
}
|
|
2400
2398
|
/**
|
|
2401
2399
|
* Converts reference strings from OpenAPI $ref keywords into namespaces.
|
|
2402
2400
|
*
|
|
2403
2401
|
* @example '#/components/schemas/Foo' -> 'schema'
|
|
2404
2402
|
*/
|
|
2405
|
-
|
|
2403
|
+
function stringToNamespace(value) {
|
|
2406
2404
|
switch (value) {
|
|
2407
2405
|
case "parameters": return "parameter";
|
|
2408
2406
|
case "requestBodies": return "body";
|
|
@@ -2411,8 +2409,16 @@ const stringToNamespace = (value) => {
|
|
|
2411
2409
|
case "schemas": return "schema";
|
|
2412
2410
|
default: return "unknown";
|
|
2413
2411
|
}
|
|
2414
|
-
}
|
|
2415
|
-
|
|
2412
|
+
}
|
|
2413
|
+
function getResourceDependencies(key, resourceMetadata) {
|
|
2414
|
+
const { namespace } = removeNamespace(key);
|
|
2415
|
+
if (namespace === "body") return resourceMetadata.requestBodies.get(key)?.dependencies;
|
|
2416
|
+
if (namespace === "operation") return resourceMetadata.operations.get(key)?.dependencies;
|
|
2417
|
+
if (namespace === "parameter") return resourceMetadata.parameters.get(key)?.dependencies;
|
|
2418
|
+
if (namespace === "response") return resourceMetadata.responses.get(key)?.dependencies;
|
|
2419
|
+
if (namespace === "schema") return resourceMetadata.schemas.get(key)?.dependencies;
|
|
2420
|
+
}
|
|
2421
|
+
function createFiltersSetAndRegExps(type, filters) {
|
|
2416
2422
|
const keys = [];
|
|
2417
2423
|
const regexps = [];
|
|
2418
2424
|
if (filters) for (const value of filters) if (value.startsWith("/") && value.endsWith("/")) regexps.push(new RegExp(value.slice(1, value.length - 1)));
|
|
@@ -2421,8 +2427,8 @@ const createFiltersSetAndRegExps = (type, filters) => {
|
|
|
2421
2427
|
regexps,
|
|
2422
2428
|
set: new Set(keys)
|
|
2423
2429
|
};
|
|
2424
|
-
}
|
|
2425
|
-
|
|
2430
|
+
}
|
|
2431
|
+
function collectFiltersSetFromRegExpsOpenApiV2({ excludeOperations, excludeSchemas, includeOperations, includeSchemas, spec }) {
|
|
2426
2432
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2427
2433
|
const path = entry[0];
|
|
2428
2434
|
const pathItem = entry[1];
|
|
@@ -2442,8 +2448,8 @@ const collectFiltersSetFromRegExpsOpenApiV2 = ({ excludeOperations, excludeSchem
|
|
|
2442
2448
|
if (includeSchemas.regexps.some((regexp) => regexp.test(key))) includeSchemas.set.add(addNamespace("schema", key));
|
|
2443
2449
|
}
|
|
2444
2450
|
}
|
|
2445
|
-
}
|
|
2446
|
-
|
|
2451
|
+
}
|
|
2452
|
+
function collectFiltersSetFromRegExpsOpenApiV3({ excludeOperations, excludeParameters, excludeRequestBodies, excludeResponses, excludeSchemas, includeOperations, includeParameters, includeRequestBodies, includeResponses, includeSchemas, spec }) {
|
|
2447
2453
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2448
2454
|
const path = entry[0];
|
|
2449
2455
|
const pathItem = entry[1];
|
|
@@ -2475,8 +2481,8 @@ const collectFiltersSetFromRegExpsOpenApiV3 = ({ excludeOperations, excludeParam
|
|
|
2475
2481
|
if (includeSchemas.regexps.some((regexp) => regexp.test(key))) includeSchemas.set.add(addNamespace("schema", key));
|
|
2476
2482
|
}
|
|
2477
2483
|
}
|
|
2478
|
-
}
|
|
2479
|
-
|
|
2484
|
+
}
|
|
2485
|
+
function collectFiltersSetFromRegExps({ spec, ...filters }) {
|
|
2480
2486
|
if ("swagger" in spec) collectFiltersSetFromRegExpsOpenApiV2({
|
|
2481
2487
|
...filters,
|
|
2482
2488
|
spec
|
|
@@ -2485,8 +2491,8 @@ const collectFiltersSetFromRegExps = ({ spec, ...filters }) => {
|
|
|
2485
2491
|
...filters,
|
|
2486
2492
|
spec
|
|
2487
2493
|
});
|
|
2488
|
-
}
|
|
2489
|
-
|
|
2494
|
+
}
|
|
2495
|
+
function createFilters(config, spec, logger) {
|
|
2490
2496
|
const eventCreateFilters = logger.timeEvent("create-filters");
|
|
2491
2497
|
const excludeOperations = createFiltersSetAndRegExps("operation", config?.operations?.exclude);
|
|
2492
2498
|
const includeOperations = createFiltersSetAndRegExps("operation", config?.operations?.include);
|
|
@@ -2542,16 +2548,18 @@ const createFilters = (config, spec, logger) => {
|
|
|
2542
2548
|
};
|
|
2543
2549
|
eventCreateFilters.timeEnd();
|
|
2544
2550
|
return filters;
|
|
2545
|
-
}
|
|
2546
|
-
|
|
2551
|
+
}
|
|
2552
|
+
function hasFilters(config) {
|
|
2547
2553
|
if (!config) return false;
|
|
2548
2554
|
if (config.orphans === false || config.deprecated === false) return true;
|
|
2549
2555
|
return Boolean(config.operations?.exclude?.length || config.operations?.include?.length || config.parameters?.exclude?.length || config.parameters?.include?.length || config.requestBodies?.exclude?.length || config.requestBodies?.include?.length || config.responses?.exclude?.length || config.responses?.include?.length || config.schemas?.exclude?.length || config.schemas?.include?.length || config.tags?.exclude?.length || config.tags?.include?.length);
|
|
2550
|
-
}
|
|
2556
|
+
}
|
|
2551
2557
|
/**
|
|
2552
2558
|
* Collect operations that satisfy the include/exclude filters and schema dependencies.
|
|
2559
|
+
*
|
|
2560
|
+
* Must be called after dropping components.
|
|
2553
2561
|
*/
|
|
2554
|
-
|
|
2562
|
+
function collectOperations({ filters, parameters, requestBodies, resourceMetadata, responses, schemas }) {
|
|
2555
2563
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2556
2564
|
const stack = [...filters.operations.include.size ? filters.operations.include : new Set(resourceMetadata.operations.keys())];
|
|
2557
2565
|
while (stack.length) {
|
|
@@ -2575,11 +2583,11 @@ const collectOperations = ({ filters, parameters, requestBodies, resourceMetadat
|
|
|
2575
2583
|
finalSet.add(key);
|
|
2576
2584
|
}
|
|
2577
2585
|
return { operations: finalSet };
|
|
2578
|
-
}
|
|
2586
|
+
}
|
|
2579
2587
|
/**
|
|
2580
2588
|
* Collect parameters that satisfy the include/exclude filters and schema dependencies.
|
|
2581
2589
|
*/
|
|
2582
|
-
|
|
2590
|
+
function collectParameters({ filters, resourceMetadata, schemas }) {
|
|
2583
2591
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2584
2592
|
const stack = [...filters.parameters.include.size ? filters.parameters.include : new Set(resourceMetadata.parameters.keys())];
|
|
2585
2593
|
while (stack.length) {
|
|
@@ -2605,11 +2613,11 @@ const collectParameters = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2605
2613
|
}
|
|
2606
2614
|
}
|
|
2607
2615
|
return { parameters: finalSet };
|
|
2608
|
-
}
|
|
2616
|
+
}
|
|
2609
2617
|
/**
|
|
2610
2618
|
* Collect request bodies that satisfy the include/exclude filters and schema dependencies.
|
|
2611
2619
|
*/
|
|
2612
|
-
|
|
2620
|
+
function collectRequestBodies({ filters, resourceMetadata, schemas }) {
|
|
2613
2621
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2614
2622
|
const stack = [...filters.requestBodies.include.size ? filters.requestBodies.include : new Set(resourceMetadata.requestBodies.keys())];
|
|
2615
2623
|
while (stack.length) {
|
|
@@ -2635,11 +2643,11 @@ const collectRequestBodies = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2635
2643
|
}
|
|
2636
2644
|
}
|
|
2637
2645
|
return { requestBodies: finalSet };
|
|
2638
|
-
}
|
|
2646
|
+
}
|
|
2639
2647
|
/**
|
|
2640
2648
|
* Collect responses that satisfy the include/exclude filters and schema dependencies.
|
|
2641
2649
|
*/
|
|
2642
|
-
|
|
2650
|
+
function collectResponses({ filters, resourceMetadata, schemas }) {
|
|
2643
2651
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2644
2652
|
const stack = [...filters.responses.include.size ? filters.responses.include : new Set(resourceMetadata.responses.keys())];
|
|
2645
2653
|
while (stack.length) {
|
|
@@ -2665,11 +2673,11 @@ const collectResponses = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2665
2673
|
}
|
|
2666
2674
|
}
|
|
2667
2675
|
return { responses: finalSet };
|
|
2668
|
-
}
|
|
2676
|
+
}
|
|
2669
2677
|
/**
|
|
2670
2678
|
* Collect schemas that satisfy the include/exclude filters.
|
|
2671
2679
|
*/
|
|
2672
|
-
|
|
2680
|
+
function collectSchemas({ filters, resourceMetadata }) {
|
|
2673
2681
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2674
2682
|
const stack = [...filters.schemas.include.size ? filters.schemas.include : new Set(resourceMetadata.schemas.keys())];
|
|
2675
2683
|
while (stack.length) {
|
|
@@ -2690,11 +2698,11 @@ const collectSchemas = ({ filters, resourceMetadata }) => {
|
|
|
2690
2698
|
}
|
|
2691
2699
|
}
|
|
2692
2700
|
return { schemas: finalSet };
|
|
2693
|
-
}
|
|
2701
|
+
}
|
|
2694
2702
|
/**
|
|
2695
2703
|
* Drop parameters that depend on already excluded parameters.
|
|
2696
2704
|
*/
|
|
2697
|
-
|
|
2705
|
+
function dropExcludedParameters({ filters, parameters, resourceMetadata }) {
|
|
2698
2706
|
if (!filters.parameters.exclude.size) return;
|
|
2699
2707
|
for (const key of parameters) {
|
|
2700
2708
|
const node = resourceMetadata.parameters.get(key);
|
|
@@ -2704,11 +2712,11 @@ const dropExcludedParameters = ({ filters, parameters, resourceMetadata }) => {
|
|
|
2704
2712
|
break;
|
|
2705
2713
|
}
|
|
2706
2714
|
}
|
|
2707
|
-
}
|
|
2715
|
+
}
|
|
2708
2716
|
/**
|
|
2709
2717
|
* Drop request bodies that depend on already excluded request bodies.
|
|
2710
2718
|
*/
|
|
2711
|
-
|
|
2719
|
+
function dropExcludedRequestBodies({ filters, requestBodies, resourceMetadata }) {
|
|
2712
2720
|
if (!filters.requestBodies.exclude.size) return;
|
|
2713
2721
|
for (const key of requestBodies) {
|
|
2714
2722
|
const node = resourceMetadata.requestBodies.get(key);
|
|
@@ -2718,11 +2726,11 @@ const dropExcludedRequestBodies = ({ filters, requestBodies, resourceMetadata })
|
|
|
2718
2726
|
break;
|
|
2719
2727
|
}
|
|
2720
2728
|
}
|
|
2721
|
-
}
|
|
2729
|
+
}
|
|
2722
2730
|
/**
|
|
2723
2731
|
* Drop responses that depend on already excluded responses.
|
|
2724
2732
|
*/
|
|
2725
|
-
|
|
2733
|
+
function dropExcludedResponses({ filters, resourceMetadata, responses }) {
|
|
2726
2734
|
if (!filters.responses.exclude.size) return;
|
|
2727
2735
|
for (const key of responses) {
|
|
2728
2736
|
const node = resourceMetadata.responses.get(key);
|
|
@@ -2732,11 +2740,11 @@ const dropExcludedResponses = ({ filters, resourceMetadata, responses }) => {
|
|
|
2732
2740
|
break;
|
|
2733
2741
|
}
|
|
2734
2742
|
}
|
|
2735
|
-
}
|
|
2743
|
+
}
|
|
2736
2744
|
/**
|
|
2737
2745
|
* Drop schemas that depend on already excluded schemas.
|
|
2738
2746
|
*/
|
|
2739
|
-
|
|
2747
|
+
function dropExcludedSchemas({ filters, resourceMetadata, schemas }) {
|
|
2740
2748
|
if (!filters.schemas.exclude.size) return;
|
|
2741
2749
|
for (const key of schemas) {
|
|
2742
2750
|
const node = resourceMetadata.schemas.get(key);
|
|
@@ -2746,33 +2754,56 @@ const dropExcludedSchemas = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2746
2754
|
break;
|
|
2747
2755
|
}
|
|
2748
2756
|
}
|
|
2749
|
-
}
|
|
2750
|
-
|
|
2751
|
-
for (const key of schemas) if (!operationDependencies.has(key)) schemas.delete(key);
|
|
2752
|
-
for (const key of parameters) if (!operationDependencies.has(key)) parameters.delete(key);
|
|
2753
|
-
for (const key of requestBodies) if (!operationDependencies.has(key)) requestBodies.delete(key);
|
|
2754
|
-
for (const key of responses) if (!operationDependencies.has(key)) responses.delete(key);
|
|
2755
|
-
}
|
|
2756
|
-
|
|
2757
|
+
}
|
|
2758
|
+
function dropOrphans({ includedDependencies, operationDependencies, parameters, requestBodies, responses, schemas }) {
|
|
2759
|
+
for (const key of schemas) if (!operationDependencies.has(key) && !includedDependencies.has(key)) schemas.delete(key);
|
|
2760
|
+
for (const key of parameters) if (!operationDependencies.has(key) && !includedDependencies.has(key)) parameters.delete(key);
|
|
2761
|
+
for (const key of requestBodies) if (!operationDependencies.has(key) && !includedDependencies.has(key)) requestBodies.delete(key);
|
|
2762
|
+
for (const key of responses) if (!operationDependencies.has(key) && !includedDependencies.has(key)) responses.delete(key);
|
|
2763
|
+
}
|
|
2764
|
+
function collectDependencies({ resourceMetadata, seeds }) {
|
|
2757
2765
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2758
|
-
const stack = [...
|
|
2766
|
+
const stack = [...seeds];
|
|
2759
2767
|
while (stack.length) {
|
|
2760
2768
|
const key = stack.pop();
|
|
2761
2769
|
if (finalSet.has(key)) continue;
|
|
2762
2770
|
finalSet.add(key);
|
|
2771
|
+
const dependencies = getResourceDependencies(key, resourceMetadata);
|
|
2772
|
+
if (!dependencies?.size) continue;
|
|
2773
|
+
for (const dependency of dependencies) if (!finalSet.has(dependency)) stack.push(dependency);
|
|
2774
|
+
}
|
|
2775
|
+
return { dependencies: finalSet };
|
|
2776
|
+
}
|
|
2777
|
+
function collectExplicitDependencies({ filters, resourceMetadata }) {
|
|
2778
|
+
const seeds = /* @__PURE__ */ new Set();
|
|
2779
|
+
for (const key of filters.parameters.include) if (!filters.parameters.exclude.has(key)) seeds.add(key);
|
|
2780
|
+
for (const key of filters.requestBodies.include) if (!filters.requestBodies.exclude.has(key)) seeds.add(key);
|
|
2781
|
+
for (const key of filters.responses.include) if (!filters.responses.exclude.has(key)) seeds.add(key);
|
|
2782
|
+
for (const key of filters.schemas.include) if (!filters.schemas.exclude.has(key)) seeds.add(key);
|
|
2783
|
+
const { dependencies } = collectDependencies({
|
|
2784
|
+
resourceMetadata,
|
|
2785
|
+
seeds
|
|
2786
|
+
});
|
|
2787
|
+
for (const key of dependencies) {
|
|
2763
2788
|
const { namespace } = removeNamespace(key);
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2767
|
-
|
|
2768
|
-
|
|
2769
|
-
|
|
2789
|
+
if (namespace === "body" && filters.requestBodies.exclude.has(key) || namespace === "parameter" && filters.parameters.exclude.has(key) || namespace === "response" && filters.responses.exclude.has(key) || namespace === "schema" && filters.schemas.exclude.has(key)) dependencies.delete(key);
|
|
2790
|
+
}
|
|
2791
|
+
return { explicitDependencies: dependencies };
|
|
2792
|
+
}
|
|
2793
|
+
function collectOperationDependencies({ operations, resourceMetadata }) {
|
|
2794
|
+
const finalSet = /* @__PURE__ */ new Set();
|
|
2795
|
+
const stack = [...new Set([...operations].flatMap((key) => [...resourceMetadata.operations.get(key)?.dependencies ?? []]))];
|
|
2796
|
+
while (stack.length) {
|
|
2797
|
+
const key = stack.pop();
|
|
2798
|
+
if (finalSet.has(key)) continue;
|
|
2799
|
+
finalSet.add(key);
|
|
2800
|
+
const dependencies = getResourceDependencies(key, resourceMetadata);
|
|
2770
2801
|
if (!dependencies?.size) continue;
|
|
2771
2802
|
for (const dependency of dependencies) if (!finalSet.has(dependency)) stack.push(dependency);
|
|
2772
2803
|
}
|
|
2773
2804
|
return { operationDependencies: finalSet };
|
|
2774
|
-
}
|
|
2775
|
-
|
|
2805
|
+
}
|
|
2806
|
+
function createFilteredDependencies({ filters, logger, resourceMetadata }) {
|
|
2776
2807
|
const eventCreateFilteredDependencies = logger.timeEvent("create-filtered-dependencies");
|
|
2777
2808
|
const { schemas } = collectSchemas({
|
|
2778
2809
|
filters,
|
|
@@ -2826,7 +2857,12 @@ const createFilteredDependencies = ({ filters, logger, resourceMetadata }) => {
|
|
|
2826
2857
|
operations,
|
|
2827
2858
|
resourceMetadata
|
|
2828
2859
|
});
|
|
2860
|
+
const { explicitDependencies } = collectExplicitDependencies({
|
|
2861
|
+
filters,
|
|
2862
|
+
resourceMetadata
|
|
2863
|
+
});
|
|
2829
2864
|
dropOrphans({
|
|
2865
|
+
includedDependencies: explicitDependencies,
|
|
2830
2866
|
operationDependencies,
|
|
2831
2867
|
parameters,
|
|
2832
2868
|
requestBodies,
|
|
@@ -2842,8 +2878,7 @@ const createFilteredDependencies = ({ filters, logger, resourceMetadata }) => {
|
|
|
2842
2878
|
responses,
|
|
2843
2879
|
schemas
|
|
2844
2880
|
};
|
|
2845
|
-
}
|
|
2846
|
-
|
|
2881
|
+
}
|
|
2847
2882
|
//#endregion
|
|
2848
2883
|
//#region src/openApi/shared/graph/meta.ts
|
|
2849
2884
|
/**
|
|
@@ -2935,11 +2970,9 @@ const buildResourceMetadata = (graph, logger) => {
|
|
|
2935
2970
|
eventBuildResourceMetadata.timeEnd();
|
|
2936
2971
|
return { resourceMetadata };
|
|
2937
2972
|
};
|
|
2938
|
-
|
|
2939
2973
|
//#endregion
|
|
2940
2974
|
//#region src/openApi/shared/utils/schema.ts
|
|
2941
2975
|
const deepClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
2942
|
-
|
|
2943
2976
|
//#endregion
|
|
2944
2977
|
//#region src/openApi/shared/utils/schemaChildRelationships.ts
|
|
2945
2978
|
const childSchemaRelationships = [
|
|
@@ -2958,7 +2991,6 @@ const childSchemaRelationships = [
|
|
|
2958
2991
|
["then", "single"],
|
|
2959
2992
|
["unevaluatedProperties", "single"]
|
|
2960
2993
|
];
|
|
2961
|
-
|
|
2962
2994
|
//#endregion
|
|
2963
2995
|
//#region src/openApi/shared/utils/transforms.ts
|
|
2964
2996
|
const getSchemasObject = (spec) => {
|
|
@@ -2975,7 +3007,6 @@ const hasComponentsSchemasObject = (spec) => typeof spec === "object" && spec !=
|
|
|
2975
3007
|
* Returns true if present, false otherwise.
|
|
2976
3008
|
*/
|
|
2977
3009
|
const hasDefinitionsObject = (spec) => typeof spec === "object" && spec !== null && "definitions" in spec && typeof spec.definitions === "object" && spec.definitions !== null;
|
|
2978
|
-
|
|
2979
3010
|
//#endregion
|
|
2980
3011
|
//#region src/openApi/shared/transforms/utils.ts
|
|
2981
3012
|
const hasName = (obj, value) => {
|
|
@@ -3000,7 +3031,6 @@ const specToSchemasPointerNamespace = (spec) => {
|
|
|
3000
3031
|
}
|
|
3001
3032
|
return "";
|
|
3002
3033
|
};
|
|
3003
|
-
|
|
3004
3034
|
//#endregion
|
|
3005
3035
|
//#region src/openApi/shared/transforms/enums.ts
|
|
3006
3036
|
/**
|
|
@@ -3139,7 +3169,7 @@ const rootMode = ({ config, spec }) => {
|
|
|
3139
3169
|
const schemasPointerNamespace = specToSchemasPointerNamespace(spec);
|
|
3140
3170
|
for (const { key, parent, signature } of inlineEnums) {
|
|
3141
3171
|
const name = signatureToName[signature];
|
|
3142
|
-
if (name && key
|
|
3172
|
+
if (name && key !== null && parent && typeof parent === "object") parent[key] = { $ref: `${schemasPointerNamespace}${name}` };
|
|
3143
3173
|
}
|
|
3144
3174
|
};
|
|
3145
3175
|
/**
|
|
@@ -3164,7 +3194,6 @@ const enumsTransform = ({ config, spec }) => {
|
|
|
3164
3194
|
return;
|
|
3165
3195
|
}
|
|
3166
3196
|
};
|
|
3167
|
-
|
|
3168
3197
|
//#endregion
|
|
3169
3198
|
//#region src/openApi/shared/transforms/propertiesRequiredByDefault.ts
|
|
3170
3199
|
/**
|
|
@@ -3224,7 +3253,6 @@ const propertiesRequiredByDefaultTransform = ({ spec }) => {
|
|
|
3224
3253
|
}
|
|
3225
3254
|
});
|
|
3226
3255
|
};
|
|
3227
|
-
|
|
3228
3256
|
//#endregion
|
|
3229
3257
|
//#region src/openApi/shared/utils/deepEqual.ts
|
|
3230
3258
|
/**
|
|
@@ -3252,7 +3280,6 @@ const deepEqual = (a, b) => {
|
|
|
3252
3280
|
for (const key of keysA) if (!deepEqual(objA[key], objB[key])) return false;
|
|
3253
3281
|
return true;
|
|
3254
3282
|
};
|
|
3255
|
-
|
|
3256
3283
|
//#endregion
|
|
3257
3284
|
//#region src/openApi/shared/utils/graph.ts
|
|
3258
3285
|
/**
|
|
@@ -3546,7 +3573,6 @@ function buildGraph(root, logger) {
|
|
|
3546
3573
|
eventBuildGraph.timeEnd();
|
|
3547
3574
|
return { graph };
|
|
3548
3575
|
}
|
|
3549
|
-
|
|
3550
3576
|
//#endregion
|
|
3551
3577
|
//#region src/openApi/shared/transforms/readWrite.ts
|
|
3552
3578
|
const schemaKeys = new Set([
|
|
@@ -4075,7 +4101,6 @@ const readWriteTransform = ({ config, logger, spec }) => {
|
|
|
4075
4101
|
split
|
|
4076
4102
|
});
|
|
4077
4103
|
};
|
|
4078
|
-
|
|
4079
4104
|
//#endregion
|
|
4080
4105
|
//#region src/openApi/shared/transforms/schemas.ts
|
|
4081
4106
|
/**
|
|
@@ -4116,7 +4141,6 @@ const schemaNameTransform = ({ config, spec }) => {
|
|
|
4116
4141
|
}
|
|
4117
4142
|
if (Object.keys(renameMap).length) rewriteRefs(spec, renameMap);
|
|
4118
4143
|
};
|
|
4119
|
-
|
|
4120
4144
|
//#endregion
|
|
4121
4145
|
//#region src/openApi/shared/transforms/index.ts
|
|
4122
4146
|
const transformOpenApiSpec = ({ context }) => {
|
|
@@ -4138,7 +4162,6 @@ const transformOpenApiSpec = ({ context }) => {
|
|
|
4138
4162
|
});
|
|
4139
4163
|
eventTransformOpenApiSpec.timeEnd();
|
|
4140
4164
|
};
|
|
4141
|
-
|
|
4142
4165
|
//#endregion
|
|
4143
4166
|
//#region src/openApi/shared/utils/parameter.ts
|
|
4144
4167
|
const mergeParametersObjects = ({ source, target }) => {
|
|
@@ -4168,7 +4191,6 @@ const mergeParametersObjects = ({ source, target }) => {
|
|
|
4168
4191
|
if (!Object.keys(result).length) return;
|
|
4169
4192
|
return result;
|
|
4170
4193
|
};
|
|
4171
|
-
|
|
4172
4194
|
//#endregion
|
|
4173
4195
|
//#region src/openApi/shared/utils/validator.ts
|
|
4174
4196
|
const isSimpleKey = (key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
|
|
@@ -4195,7 +4217,6 @@ const handleValidatorResult = ({ context, result }) => {
|
|
|
4195
4217
|
})) console.log(formatValidatorIssue(issue));
|
|
4196
4218
|
if (!result.valid) process.exit(1);
|
|
4197
4219
|
};
|
|
4198
|
-
|
|
4199
4220
|
//#endregion
|
|
4200
4221
|
//#region src/openApi/2.0.x/parser/filter.ts
|
|
4201
4222
|
/**
|
|
@@ -4229,7 +4250,6 @@ const filterSpec$2 = ({ logger, operations, preserveOrder, schemas, spec }) => {
|
|
|
4229
4250
|
}
|
|
4230
4251
|
eventFilterSpec.timeEnd();
|
|
4231
4252
|
};
|
|
4232
|
-
|
|
4233
4253
|
//#endregion
|
|
4234
4254
|
//#region src/ir/mediaType.ts
|
|
4235
4255
|
const fileLikeRegExp = /^(application\/(pdf|rtf|msword|vnd\.(ms-|openxmlformats-officedocument\.)|zip|x-(7z|tar|rar|zip|iso)|octet-stream|gzip|x-msdownload|json\+download|xml|x-yaml|x-7z-compressed|x-tar)|text\/(yaml|css|javascript)|audio\/(mpeg|wav)|video\/(mp4|x-matroska)|image\/(vnd\.adobe\.photoshop|svg\+xml))(; ?charset=[^;]+)?$/i;
|
|
@@ -4254,7 +4274,6 @@ const mediaTypeToIrMediaType = ({ mediaType }) => {
|
|
|
4254
4274
|
octetStreamMimeRegExp.lastIndex = 0;
|
|
4255
4275
|
if (octetStreamMimeRegExp.test(mediaType)) return "octet-stream";
|
|
4256
4276
|
};
|
|
4257
|
-
|
|
4258
4277
|
//#endregion
|
|
4259
4278
|
//#region src/openApi/2.0.x/parser/mediaType.ts
|
|
4260
4279
|
const contentToSchema$2 = ({ content }) => {
|
|
@@ -4282,14 +4301,12 @@ const mediaTypeObjects$2 = ({ mimeTypes, response }) => {
|
|
|
4282
4301
|
});
|
|
4283
4302
|
return objects;
|
|
4284
4303
|
};
|
|
4285
|
-
|
|
4286
4304
|
//#endregion
|
|
4287
4305
|
//#region src/ir/pagination.ts
|
|
4288
4306
|
function getPaginationKeywordsRegExp(pagination) {
|
|
4289
4307
|
const pattern = `^(${pagination.keywords.join("|")})$`;
|
|
4290
4308
|
return new RegExp(pattern);
|
|
4291
4309
|
}
|
|
4292
|
-
|
|
4293
4310
|
//#endregion
|
|
4294
4311
|
//#region src/openApi/shared/utils/discriminator.ts
|
|
4295
4312
|
/**
|
|
@@ -4356,19 +4373,18 @@ const discriminatorValues = ($ref, mapping, shouldUseRefAsValue) => {
|
|
|
4356
4373
|
if (!values.length && (!shouldUseRefAsValue || shouldUseRefAsValue())) return [refToName($ref)];
|
|
4357
4374
|
return values;
|
|
4358
4375
|
};
|
|
4359
|
-
|
|
4360
4376
|
//#endregion
|
|
4361
4377
|
//#region src/openApi/2.0.x/parser/schema.ts
|
|
4362
|
-
|
|
4378
|
+
function getSchemaType$1({ schema }) {
|
|
4363
4379
|
if (schema.type) return schema.type;
|
|
4364
4380
|
if (schema.properties) return "object";
|
|
4365
|
-
}
|
|
4366
|
-
|
|
4381
|
+
}
|
|
4382
|
+
function parseSchemaJsDoc$2({ irSchema, schema }) {
|
|
4367
4383
|
if (schema.example) irSchema.example = schema.example;
|
|
4368
4384
|
if (schema.description) irSchema.description = schema.description;
|
|
4369
4385
|
if (schema.title) irSchema.title = schema.title;
|
|
4370
|
-
}
|
|
4371
|
-
|
|
4386
|
+
}
|
|
4387
|
+
function parseSchemaMeta$2({ irSchema, schema }) {
|
|
4372
4388
|
if (schema.default !== void 0) irSchema.default = schema.default;
|
|
4373
4389
|
if (schema.exclusiveMaximum) {
|
|
4374
4390
|
if (schema.maximum !== void 0) irSchema.exclusiveMaximum = schema.maximum;
|
|
@@ -4383,8 +4399,8 @@ const parseSchemaMeta$2 = ({ irSchema, schema }) => {
|
|
|
4383
4399
|
if (schema.minLength !== void 0) irSchema.minLength = schema.minLength;
|
|
4384
4400
|
if (schema.pattern) irSchema.pattern = schema.pattern;
|
|
4385
4401
|
if (schema.readOnly) irSchema.accessScope = "read";
|
|
4386
|
-
}
|
|
4387
|
-
|
|
4402
|
+
}
|
|
4403
|
+
function parseArray$2({ context, irSchema = {}, schema, state }) {
|
|
4388
4404
|
if (schema.maxItems && schema.maxItems === schema.minItems) irSchema.type = "tuple";
|
|
4389
4405
|
else irSchema.type = "array";
|
|
4390
4406
|
let schemaItems = [];
|
|
@@ -4410,16 +4426,16 @@ const parseArray$2 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
4410
4426
|
schema: irSchema
|
|
4411
4427
|
});
|
|
4412
4428
|
return irSchema;
|
|
4413
|
-
}
|
|
4414
|
-
|
|
4429
|
+
}
|
|
4430
|
+
function parseBoolean$2({ irSchema = {} }) {
|
|
4415
4431
|
irSchema.type = "boolean";
|
|
4416
4432
|
return irSchema;
|
|
4417
|
-
}
|
|
4418
|
-
|
|
4433
|
+
}
|
|
4434
|
+
function parseNumber$2({ irSchema = {}, schema }) {
|
|
4419
4435
|
irSchema.type = schema.type;
|
|
4420
4436
|
return irSchema;
|
|
4421
|
-
}
|
|
4422
|
-
|
|
4437
|
+
}
|
|
4438
|
+
function parseObject$2({ context, irSchema = {}, schema, state }) {
|
|
4423
4439
|
irSchema.type = "object";
|
|
4424
4440
|
const schemaProperties = {};
|
|
4425
4441
|
for (const name in schema.properties) {
|
|
@@ -4442,15 +4458,15 @@ const parseObject$2 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
4442
4458
|
});
|
|
4443
4459
|
if (schema.required) irSchema.required = schema.required;
|
|
4444
4460
|
return irSchema;
|
|
4445
|
-
}
|
|
4446
|
-
|
|
4461
|
+
}
|
|
4462
|
+
function parseString$2({ irSchema = {} }) {
|
|
4447
4463
|
irSchema.type = "string";
|
|
4448
4464
|
return irSchema;
|
|
4449
|
-
}
|
|
4450
|
-
|
|
4465
|
+
}
|
|
4466
|
+
function parseExtensions$2({ source, target }) {
|
|
4451
4467
|
for (const key in source) if (key.startsWith("x-")) target[key] = source[key];
|
|
4452
|
-
}
|
|
4453
|
-
|
|
4468
|
+
}
|
|
4469
|
+
function initIrSchema$2({ schema }) {
|
|
4454
4470
|
const irSchema = {};
|
|
4455
4471
|
parseSchemaJsDoc$2({
|
|
4456
4472
|
irSchema,
|
|
@@ -4461,8 +4477,8 @@ const initIrSchema$2 = ({ schema }) => {
|
|
|
4461
4477
|
target: irSchema
|
|
4462
4478
|
});
|
|
4463
4479
|
return irSchema;
|
|
4464
|
-
}
|
|
4465
|
-
|
|
4480
|
+
}
|
|
4481
|
+
function parseAllOf$2({ context, schema, state }) {
|
|
4466
4482
|
let irSchema = initIrSchema$2({ schema });
|
|
4467
4483
|
const schemaItems = [];
|
|
4468
4484
|
const schemaType = getSchemaType$1({ schema });
|
|
@@ -4546,9 +4562,13 @@ const parseAllOf$2 = ({ context, schema, state }) => {
|
|
|
4546
4562
|
if (nestedItems[0].description) irSchema.description = nestedItems[0].description;
|
|
4547
4563
|
}
|
|
4548
4564
|
return irSchema;
|
|
4549
|
-
}
|
|
4550
|
-
|
|
4565
|
+
}
|
|
4566
|
+
function parseEnum$2({ context, schema, state }) {
|
|
4551
4567
|
let irSchema = initIrSchema$2({ schema });
|
|
4568
|
+
parseSchemaMeta$2({
|
|
4569
|
+
irSchema,
|
|
4570
|
+
schema
|
|
4571
|
+
});
|
|
4552
4572
|
irSchema.type = "enum";
|
|
4553
4573
|
const schemaItems = [];
|
|
4554
4574
|
for (const [index, enumValue] of schema.enum.entries()) {
|
|
@@ -4579,8 +4599,8 @@ const parseEnum$2 = ({ context, schema, state }) => {
|
|
|
4579
4599
|
schema: irSchema
|
|
4580
4600
|
});
|
|
4581
4601
|
return irSchema;
|
|
4582
|
-
}
|
|
4583
|
-
|
|
4602
|
+
}
|
|
4603
|
+
function parseRef$2({ context, schema, state }) {
|
|
4584
4604
|
const irSchema = {};
|
|
4585
4605
|
if (!isTopLevelComponent(schema.$ref)) {
|
|
4586
4606
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
@@ -4610,8 +4630,8 @@ const parseRef$2 = ({ context, schema, state }) => {
|
|
|
4610
4630
|
state.$ref = originalRef;
|
|
4611
4631
|
}
|
|
4612
4632
|
return irSchema;
|
|
4613
|
-
}
|
|
4614
|
-
|
|
4633
|
+
}
|
|
4634
|
+
function parseNullableType$1({ context, irSchema, schema, state }) {
|
|
4615
4635
|
if (!irSchema) irSchema = initIrSchema$2({ schema });
|
|
4616
4636
|
const typeIrSchema = {};
|
|
4617
4637
|
parseSchemaMeta$2({
|
|
@@ -4629,8 +4649,8 @@ const parseNullableType$1 = ({ context, irSchema, schema, state }) => {
|
|
|
4629
4649
|
schema: irSchema
|
|
4630
4650
|
});
|
|
4631
4651
|
return irSchema;
|
|
4632
|
-
}
|
|
4633
|
-
|
|
4652
|
+
}
|
|
4653
|
+
function parseType$2({ context, schema, state }) {
|
|
4634
4654
|
const irSchema = initIrSchema$2({ schema });
|
|
4635
4655
|
parseSchemaMeta$2({
|
|
4636
4656
|
irSchema,
|
|
@@ -4656,8 +4676,8 @@ const parseType$2 = ({ context, schema, state }) => {
|
|
|
4656
4676
|
},
|
|
4657
4677
|
state
|
|
4658
4678
|
});
|
|
4659
|
-
}
|
|
4660
|
-
|
|
4679
|
+
}
|
|
4680
|
+
function parseOneType$2({ context, irSchema, schema, state }) {
|
|
4661
4681
|
if (!irSchema) {
|
|
4662
4682
|
irSchema = initIrSchema$2({ schema });
|
|
4663
4683
|
parseSchemaMeta$2({
|
|
@@ -4703,8 +4723,8 @@ const parseOneType$2 = ({ context, irSchema, schema, state }) => {
|
|
|
4703
4723
|
schema
|
|
4704
4724
|
});
|
|
4705
4725
|
}
|
|
4706
|
-
}
|
|
4707
|
-
|
|
4726
|
+
}
|
|
4727
|
+
function parseUnknown$2({ irSchema, schema }) {
|
|
4708
4728
|
if (!irSchema) irSchema = initIrSchema$2({ schema });
|
|
4709
4729
|
irSchema.type = "unknown";
|
|
4710
4730
|
parseSchemaMeta$2({
|
|
@@ -4712,8 +4732,8 @@ const parseUnknown$2 = ({ irSchema, schema }) => {
|
|
|
4712
4732
|
schema
|
|
4713
4733
|
});
|
|
4714
4734
|
return irSchema;
|
|
4715
|
-
}
|
|
4716
|
-
|
|
4735
|
+
}
|
|
4736
|
+
function schemaToIrSchema$2({ context, schema, state }) {
|
|
4717
4737
|
if (!state) state = { circularReferenceTracker: /* @__PURE__ */ new Set() };
|
|
4718
4738
|
if (state.$ref) state.circularReferenceTracker.add(state.$ref);
|
|
4719
4739
|
if (schema.$ref) return parseRef$2({
|
|
@@ -4740,8 +4760,8 @@ const schemaToIrSchema$2 = ({ context, schema, state }) => {
|
|
|
4740
4760
|
context,
|
|
4741
4761
|
schema
|
|
4742
4762
|
});
|
|
4743
|
-
}
|
|
4744
|
-
|
|
4763
|
+
}
|
|
4764
|
+
function parseSchema$2({ $ref, context, schema }) {
|
|
4745
4765
|
if (!context.ir.components) context.ir.components = {};
|
|
4746
4766
|
if (!context.ir.components.schemas) context.ir.components.schemas = {};
|
|
4747
4767
|
context.ir.components.schemas[refToName($ref)] = schemaToIrSchema$2({
|
|
@@ -4752,8 +4772,7 @@ const parseSchema$2 = ({ $ref, context, schema }) => {
|
|
|
4752
4772
|
circularReferenceTracker: /* @__PURE__ */ new Set()
|
|
4753
4773
|
}
|
|
4754
4774
|
});
|
|
4755
|
-
}
|
|
4756
|
-
|
|
4775
|
+
}
|
|
4757
4776
|
//#endregion
|
|
4758
4777
|
//#region src/openApi/2.0.x/parser/pagination.ts
|
|
4759
4778
|
const isPaginationType$2 = (schemaType) => schemaType === "boolean" || schemaType === "integer" || schemaType === "number" || schemaType === "string";
|
|
@@ -4802,7 +4821,6 @@ const paginationField$2 = ({ context, name, schema }) => {
|
|
|
4802
4821
|
}
|
|
4803
4822
|
return false;
|
|
4804
4823
|
};
|
|
4805
|
-
|
|
4806
4824
|
//#endregion
|
|
4807
4825
|
//#region src/openApi/2.0.x/parser/operation.ts
|
|
4808
4826
|
const parseOperationJsDoc$2 = ({ irOperation, operation }) => {
|
|
@@ -5008,7 +5026,6 @@ const parsePathOperation$2 = ({ context, method, operation, path, securityScheme
|
|
|
5008
5026
|
state
|
|
5009
5027
|
});
|
|
5010
5028
|
};
|
|
5011
|
-
|
|
5012
5029
|
//#endregion
|
|
5013
5030
|
//#region src/openApi/2.0.x/parser/parameter.ts
|
|
5014
5031
|
/**
|
|
@@ -5095,7 +5112,6 @@ const parameterToIrParameter$2 = ({ $ref, context, parameter }) => {
|
|
|
5095
5112
|
});
|
|
5096
5113
|
return irParameter;
|
|
5097
5114
|
};
|
|
5098
|
-
|
|
5099
5115
|
//#endregion
|
|
5100
5116
|
//#region src/utils/url.ts
|
|
5101
5117
|
const parseUrlRegExp = /^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/;
|
|
@@ -5121,7 +5137,6 @@ function parseUrl(value) {
|
|
|
5121
5137
|
protocol
|
|
5122
5138
|
};
|
|
5123
5139
|
}
|
|
5124
|
-
|
|
5125
5140
|
//#endregion
|
|
5126
5141
|
//#region src/openApi/2.0.x/parser/server.ts
|
|
5127
5142
|
const parseServers$2 = ({ context }) => {
|
|
@@ -5139,7 +5154,6 @@ const parseServers$2 = ({ context }) => {
|
|
|
5139
5154
|
const servers = schemes.map((scheme) => `${scheme ? `${scheme}://` : ""}${host}${path}`).filter(Boolean);
|
|
5140
5155
|
if (servers.length) context.ir.servers = servers.map((url) => ({ url }));
|
|
5141
5156
|
};
|
|
5142
|
-
|
|
5143
5157
|
//#endregion
|
|
5144
5158
|
//#region src/openApi/2.0.x/parser/validate.ts
|
|
5145
5159
|
const validateOpenApiSpec$2 = (spec, logger) => {
|
|
@@ -5181,7 +5195,6 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5181
5195
|
valid: !issues.some((issue) => issue.severity === "error")
|
|
5182
5196
|
};
|
|
5183
5197
|
};
|
|
5184
|
-
|
|
5185
5198
|
//#endregion
|
|
5186
5199
|
//#region src/openApi/2.0.x/parser/index.ts
|
|
5187
5200
|
const parseV2_0_X = (context) => {
|
|
@@ -5383,7 +5396,6 @@ const parseV2_0_X = (context) => {
|
|
|
5383
5396
|
}
|
|
5384
5397
|
}
|
|
5385
5398
|
};
|
|
5386
|
-
|
|
5387
5399
|
//#endregion
|
|
5388
5400
|
//#region src/openApi/3.0.x/parser/filter.ts
|
|
5389
5401
|
/**
|
|
@@ -5452,7 +5464,6 @@ const filterSpec$1 = ({ logger, operations, parameters, preserveOrder, requestBo
|
|
|
5452
5464
|
}
|
|
5453
5465
|
eventFilterSpec.timeEnd();
|
|
5454
5466
|
};
|
|
5455
|
-
|
|
5456
5467
|
//#endregion
|
|
5457
5468
|
//#region src/openApi/3.0.x/parser/mediaType.ts
|
|
5458
5469
|
const contentToSchema$1 = ({ content }) => {
|
|
@@ -5480,18 +5491,17 @@ const mediaTypeObjects$1 = ({ content }) => {
|
|
|
5480
5491
|
});
|
|
5481
5492
|
return objects;
|
|
5482
5493
|
};
|
|
5483
|
-
|
|
5484
5494
|
//#endregion
|
|
5485
5495
|
//#region src/openApi/3.0.x/parser/schema.ts
|
|
5486
|
-
|
|
5496
|
+
function getSchemaType({ schema }) {
|
|
5487
5497
|
if (schema.type) return schema.type;
|
|
5488
5498
|
if (schema.properties) return "object";
|
|
5489
|
-
}
|
|
5499
|
+
}
|
|
5490
5500
|
/**
|
|
5491
5501
|
* Finds the type of a discriminator property by looking it up in the provided schemas.
|
|
5492
5502
|
* Searches through properties and allOf chains to find the property definition.
|
|
5493
5503
|
*/
|
|
5494
|
-
|
|
5504
|
+
function findDiscriminatorPropertyType$1({ context, propertyName, schemas }) {
|
|
5495
5505
|
for (const schema of schemas) {
|
|
5496
5506
|
const resolved = "$ref" in schema ? context.resolveRef(schema.$ref) : schema;
|
|
5497
5507
|
const property = resolved.properties?.[propertyName];
|
|
@@ -5509,13 +5519,13 @@ const findDiscriminatorPropertyType$1 = ({ context, propertyName, schemas }) =>
|
|
|
5509
5519
|
}
|
|
5510
5520
|
}
|
|
5511
5521
|
return "string";
|
|
5512
|
-
}
|
|
5522
|
+
}
|
|
5513
5523
|
/**
|
|
5514
5524
|
* Recursively finds discriminators in a schema, including nested allOf compositions.
|
|
5515
5525
|
* This is needed when a schema extends another schema via allOf, and that parent
|
|
5516
5526
|
* schema is itself an allOf composition with discriminators in inline schemas.
|
|
5517
5527
|
*/
|
|
5518
|
-
|
|
5528
|
+
function findDiscriminatorsInSchema$1({ context, discriminators = [], schema }) {
|
|
5519
5529
|
if (schema.discriminator) discriminators.push({
|
|
5520
5530
|
discriminator: schema.discriminator,
|
|
5521
5531
|
oneOf: schema.oneOf
|
|
@@ -5531,23 +5541,23 @@ const findDiscriminatorsInSchema$1 = ({ context, discriminators = [], schema })
|
|
|
5531
5541
|
});
|
|
5532
5542
|
}
|
|
5533
5543
|
return discriminators;
|
|
5534
|
-
}
|
|
5544
|
+
}
|
|
5535
5545
|
/**
|
|
5536
5546
|
* Gets the discriminator value for a schema.
|
|
5537
5547
|
* Returns only the schema's own discriminator value, not child values.
|
|
5538
5548
|
*/
|
|
5539
|
-
|
|
5549
|
+
function getAllDiscriminatorValues$1({ discriminator, schemaRef }) {
|
|
5540
5550
|
const values = [];
|
|
5541
5551
|
for (const [value, mappedSchemaRef] of Object.entries(discriminator.mapping || {})) if (mappedSchemaRef === schemaRef) values.push(value);
|
|
5542
5552
|
return values;
|
|
5543
|
-
}
|
|
5544
|
-
|
|
5553
|
+
}
|
|
5554
|
+
function parseSchemaJsDoc$1({ irSchema, schema }) {
|
|
5545
5555
|
if (schema.deprecated !== void 0) irSchema.deprecated = schema.deprecated;
|
|
5546
5556
|
if (schema.example) irSchema.example = schema.example;
|
|
5547
5557
|
if (schema.description) irSchema.description = schema.description;
|
|
5548
5558
|
if (schema.title) irSchema.title = schema.title;
|
|
5549
|
-
}
|
|
5550
|
-
|
|
5559
|
+
}
|
|
5560
|
+
function parseSchemaMeta$1({ irSchema, schema }) {
|
|
5551
5561
|
if (schema.default !== void 0) irSchema.default = schema.default;
|
|
5552
5562
|
if (schema.exclusiveMaximum) {
|
|
5553
5563
|
if (schema.maximum !== void 0) irSchema.exclusiveMaximum = schema.maximum;
|
|
@@ -5563,8 +5573,8 @@ const parseSchemaMeta$1 = ({ irSchema, schema }) => {
|
|
|
5563
5573
|
if (schema.pattern) irSchema.pattern = schema.pattern;
|
|
5564
5574
|
if (schema.readOnly) irSchema.accessScope = "read";
|
|
5565
5575
|
else if (schema.writeOnly) irSchema.accessScope = "write";
|
|
5566
|
-
}
|
|
5567
|
-
|
|
5576
|
+
}
|
|
5577
|
+
function parseArray$1({ context, irSchema = {}, schema, state }) {
|
|
5568
5578
|
if (schema.maxItems && schema.maxItems === schema.minItems) irSchema.type = "tuple";
|
|
5569
5579
|
else irSchema.type = "array";
|
|
5570
5580
|
let schemaItems = [];
|
|
@@ -5590,16 +5600,16 @@ const parseArray$1 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
5590
5600
|
schema: irSchema
|
|
5591
5601
|
});
|
|
5592
5602
|
return irSchema;
|
|
5593
|
-
}
|
|
5594
|
-
|
|
5603
|
+
}
|
|
5604
|
+
function parseBoolean$1({ irSchema = {} }) {
|
|
5595
5605
|
irSchema.type = "boolean";
|
|
5596
5606
|
return irSchema;
|
|
5597
|
-
}
|
|
5598
|
-
|
|
5607
|
+
}
|
|
5608
|
+
function parseNumber$1({ irSchema = {}, schema }) {
|
|
5599
5609
|
irSchema.type = schema.type;
|
|
5600
5610
|
return irSchema;
|
|
5601
|
-
}
|
|
5602
|
-
|
|
5611
|
+
}
|
|
5612
|
+
function parseObject$1({ context, irSchema = {}, schema, state }) {
|
|
5603
5613
|
irSchema.type = "object";
|
|
5604
5614
|
const schemaProperties = {};
|
|
5605
5615
|
for (const name in schema.properties) {
|
|
@@ -5641,15 +5651,15 @@ const parseObject$1 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
5641
5651
|
}
|
|
5642
5652
|
}
|
|
5643
5653
|
return irSchema;
|
|
5644
|
-
}
|
|
5645
|
-
|
|
5654
|
+
}
|
|
5655
|
+
function parseString$1({ irSchema = {} }) {
|
|
5646
5656
|
irSchema.type = "string";
|
|
5647
5657
|
return irSchema;
|
|
5648
|
-
}
|
|
5649
|
-
|
|
5658
|
+
}
|
|
5659
|
+
function parseExtensions$1({ source, target }) {
|
|
5650
5660
|
for (const key in source) if (key.startsWith("x-")) target[key] = source[key];
|
|
5651
|
-
}
|
|
5652
|
-
|
|
5661
|
+
}
|
|
5662
|
+
function initIrSchema$1({ schema }) {
|
|
5653
5663
|
const irSchema = {};
|
|
5654
5664
|
parseSchemaJsDoc$1({
|
|
5655
5665
|
irSchema,
|
|
@@ -5660,8 +5670,8 @@ const initIrSchema$1 = ({ schema }) => {
|
|
|
5660
5670
|
target: irSchema
|
|
5661
5671
|
});
|
|
5662
5672
|
return irSchema;
|
|
5663
|
-
}
|
|
5664
|
-
|
|
5673
|
+
}
|
|
5674
|
+
function parseAllOf$1({ context, schema, state }) {
|
|
5665
5675
|
let irSchema = initIrSchema$1({ schema });
|
|
5666
5676
|
const schemaItems = [];
|
|
5667
5677
|
const schemaType = getSchemaType({ schema });
|
|
@@ -5810,8 +5820,8 @@ const parseAllOf$1 = ({ context, schema, state }) => {
|
|
|
5810
5820
|
if (nestedItems[0].description) irSchema.description = nestedItems[0].description;
|
|
5811
5821
|
}
|
|
5812
5822
|
return irSchema;
|
|
5813
|
-
}
|
|
5814
|
-
|
|
5823
|
+
}
|
|
5824
|
+
function parseAnyOf$1({ context, schema, state }) {
|
|
5815
5825
|
let irSchema = initIrSchema$1({ schema });
|
|
5816
5826
|
const schemaItems = [];
|
|
5817
5827
|
const schemaType = getSchemaType({ schema });
|
|
@@ -5827,7 +5837,7 @@ const parseAnyOf$1 = ({ context, schema, state }) => {
|
|
|
5827
5837
|
schema: compositionSchema,
|
|
5828
5838
|
state
|
|
5829
5839
|
});
|
|
5830
|
-
if (schema.discriminator && irCompositionSchema.$ref
|
|
5840
|
+
if (schema.discriminator && irCompositionSchema.$ref) {
|
|
5831
5841
|
const valueSchemas = discriminatorValues(irCompositionSchema.$ref, schema.discriminator.mapping).map((value) => convertDiscriminatorValue(value, discriminatorPropertyType));
|
|
5832
5842
|
irCompositionSchema = {
|
|
5833
5843
|
items: [{
|
|
@@ -5863,9 +5873,13 @@ const parseAnyOf$1 = ({ context, schema, state }) => {
|
|
|
5863
5873
|
};
|
|
5864
5874
|
}
|
|
5865
5875
|
return irSchema;
|
|
5866
|
-
}
|
|
5867
|
-
|
|
5876
|
+
}
|
|
5877
|
+
function parseEnum$1({ context, schema, state }) {
|
|
5868
5878
|
let irSchema = initIrSchema$1({ schema });
|
|
5879
|
+
parseSchemaMeta$1({
|
|
5880
|
+
irSchema,
|
|
5881
|
+
schema
|
|
5882
|
+
});
|
|
5869
5883
|
irSchema.type = "enum";
|
|
5870
5884
|
const schemaItems = [];
|
|
5871
5885
|
for (const [index, enumValue] of schema.enum.entries()) {
|
|
@@ -5896,8 +5910,8 @@ const parseEnum$1 = ({ context, schema, state }) => {
|
|
|
5896
5910
|
schema: irSchema
|
|
5897
5911
|
});
|
|
5898
5912
|
return irSchema;
|
|
5899
|
-
}
|
|
5900
|
-
|
|
5913
|
+
}
|
|
5914
|
+
function parseOneOf$1({ context, schema, state }) {
|
|
5901
5915
|
let irSchema = initIrSchema$1({ schema });
|
|
5902
5916
|
let schemaItems = [];
|
|
5903
5917
|
const schemaType = getSchemaType({ schema });
|
|
@@ -5913,7 +5927,7 @@ const parseOneOf$1 = ({ context, schema, state }) => {
|
|
|
5913
5927
|
schema: compositionSchema,
|
|
5914
5928
|
state
|
|
5915
5929
|
});
|
|
5916
|
-
if (schema.discriminator && irCompositionSchema.$ref
|
|
5930
|
+
if (schema.discriminator && irCompositionSchema.$ref) {
|
|
5917
5931
|
const valueSchemas = discriminatorValues(irCompositionSchema.$ref, schema.discriminator.mapping).map((value) => convertDiscriminatorValue(value, discriminatorPropertyType));
|
|
5918
5932
|
irCompositionSchema = {
|
|
5919
5933
|
items: [{
|
|
@@ -5951,8 +5965,8 @@ const parseOneOf$1 = ({ context, schema, state }) => {
|
|
|
5951
5965
|
};
|
|
5952
5966
|
}
|
|
5953
5967
|
return irSchema;
|
|
5954
|
-
}
|
|
5955
|
-
|
|
5968
|
+
}
|
|
5969
|
+
function parseRef$1({ context, schema, state }) {
|
|
5956
5970
|
if (!isTopLevelComponent(schema.$ref)) {
|
|
5957
5971
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
5958
5972
|
const refSchema = context.resolveRef(schema.$ref);
|
|
@@ -5981,8 +5995,8 @@ const parseRef$1 = ({ context, schema, state }) => {
|
|
|
5981
5995
|
state.$ref = originalRef;
|
|
5982
5996
|
}
|
|
5983
5997
|
return irSchema;
|
|
5984
|
-
}
|
|
5985
|
-
|
|
5998
|
+
}
|
|
5999
|
+
function parseNullableType({ context, irSchema, schema, state }) {
|
|
5986
6000
|
if (!irSchema) irSchema = initIrSchema$1({ schema });
|
|
5987
6001
|
const typeIrSchema = {};
|
|
5988
6002
|
parseSchemaMeta$1({
|
|
@@ -6000,8 +6014,8 @@ const parseNullableType = ({ context, irSchema, schema, state }) => {
|
|
|
6000
6014
|
schema: irSchema
|
|
6001
6015
|
});
|
|
6002
6016
|
return irSchema;
|
|
6003
|
-
}
|
|
6004
|
-
|
|
6017
|
+
}
|
|
6018
|
+
function parseType$1({ context, schema, state }) {
|
|
6005
6019
|
const irSchema = initIrSchema$1({ schema });
|
|
6006
6020
|
parseSchemaMeta$1({
|
|
6007
6021
|
irSchema,
|
|
@@ -6027,8 +6041,8 @@ const parseType$1 = ({ context, schema, state }) => {
|
|
|
6027
6041
|
},
|
|
6028
6042
|
state
|
|
6029
6043
|
});
|
|
6030
|
-
}
|
|
6031
|
-
|
|
6044
|
+
}
|
|
6045
|
+
function parseOneType$1({ context, irSchema, schema, state }) {
|
|
6032
6046
|
if (!irSchema) {
|
|
6033
6047
|
irSchema = initIrSchema$1({ schema });
|
|
6034
6048
|
parseSchemaMeta$1({
|
|
@@ -6074,8 +6088,8 @@ const parseOneType$1 = ({ context, irSchema, schema, state }) => {
|
|
|
6074
6088
|
schema
|
|
6075
6089
|
});
|
|
6076
6090
|
}
|
|
6077
|
-
}
|
|
6078
|
-
|
|
6091
|
+
}
|
|
6092
|
+
function parseUnknown$1({ irSchema, schema }) {
|
|
6079
6093
|
if (!irSchema) irSchema = initIrSchema$1({ schema });
|
|
6080
6094
|
irSchema.type = "unknown";
|
|
6081
6095
|
parseSchemaMeta$1({
|
|
@@ -6083,8 +6097,8 @@ const parseUnknown$1 = ({ irSchema, schema }) => {
|
|
|
6083
6097
|
schema
|
|
6084
6098
|
});
|
|
6085
6099
|
return irSchema;
|
|
6086
|
-
}
|
|
6087
|
-
|
|
6100
|
+
}
|
|
6101
|
+
function schemaToIrSchema$1({ context, schema, state }) {
|
|
6088
6102
|
if (!state) state = { circularReferenceTracker: /* @__PURE__ */ new Set() };
|
|
6089
6103
|
if (state.$ref) state.circularReferenceTracker.add(state.$ref);
|
|
6090
6104
|
if ("$ref" in schema) return parseRef$1({
|
|
@@ -6121,8 +6135,8 @@ const schemaToIrSchema$1 = ({ context, schema, state }) => {
|
|
|
6121
6135
|
context,
|
|
6122
6136
|
schema
|
|
6123
6137
|
});
|
|
6124
|
-
}
|
|
6125
|
-
|
|
6138
|
+
}
|
|
6139
|
+
function parseSchema$1({ $ref, context, schema }) {
|
|
6126
6140
|
if (!context.ir.components) context.ir.components = {};
|
|
6127
6141
|
if (!context.ir.components.schemas) context.ir.components.schemas = {};
|
|
6128
6142
|
context.ir.components.schemas[refToName($ref)] = schemaToIrSchema$1({
|
|
@@ -6133,8 +6147,7 @@ const parseSchema$1 = ({ $ref, context, schema }) => {
|
|
|
6133
6147
|
circularReferenceTracker: /* @__PURE__ */ new Set()
|
|
6134
6148
|
}
|
|
6135
6149
|
});
|
|
6136
|
-
}
|
|
6137
|
-
|
|
6150
|
+
}
|
|
6138
6151
|
//#endregion
|
|
6139
6152
|
//#region src/openApi/3.0.x/parser/pagination.ts
|
|
6140
6153
|
const isPaginationType$1 = (schemaType) => schemaType === "boolean" || schemaType === "integer" || schemaType === "number" || schemaType === "string";
|
|
@@ -6179,7 +6192,6 @@ const paginationField$1 = ({ context, name, schema }) => {
|
|
|
6179
6192
|
}
|
|
6180
6193
|
return false;
|
|
6181
6194
|
};
|
|
6182
|
-
|
|
6183
6195
|
//#endregion
|
|
6184
6196
|
//#region src/openApi/3.0.x/parser/operation.ts
|
|
6185
6197
|
const parseOperationJsDoc$1 = ({ irOperation, operation }) => {
|
|
@@ -6305,7 +6317,6 @@ const parsePathOperation$1 = ({ context, method, operation, path, securityScheme
|
|
|
6305
6317
|
state
|
|
6306
6318
|
});
|
|
6307
6319
|
};
|
|
6308
|
-
|
|
6309
6320
|
//#endregion
|
|
6310
6321
|
//#region src/openApi/3.0.x/parser/parameter.ts
|
|
6311
6322
|
/**
|
|
@@ -6409,7 +6420,6 @@ const parseParameter$1 = ({ $ref, context, parameter }) => {
|
|
|
6409
6420
|
parameter
|
|
6410
6421
|
});
|
|
6411
6422
|
};
|
|
6412
|
-
|
|
6413
6423
|
//#endregion
|
|
6414
6424
|
//#region src/openApi/3.0.x/parser/requestBody.ts
|
|
6415
6425
|
const requestBodyToIrRequestBody$1 = ({ $ref, context, requestBody }) => {
|
|
@@ -6440,7 +6450,6 @@ const parseRequestBody$1 = ({ $ref, context, requestBody }) => {
|
|
|
6440
6450
|
requestBody
|
|
6441
6451
|
});
|
|
6442
6452
|
};
|
|
6443
|
-
|
|
6444
6453
|
//#endregion
|
|
6445
6454
|
//#region src/openApi/3.0.x/parser/server.ts
|
|
6446
6455
|
function parseServers$1({ context }) {
|
|
@@ -6454,7 +6463,6 @@ function parseServers$1({ context }) {
|
|
|
6454
6463
|
}
|
|
6455
6464
|
if (!context.ir.servers) context.ir.servers = [{ url: "/" }];
|
|
6456
6465
|
}
|
|
6457
|
-
|
|
6458
6466
|
//#endregion
|
|
6459
6467
|
//#region src/openApi/3.0.x/parser/validate.ts
|
|
6460
6468
|
const validateOpenApiSpec$1 = (spec, logger) => {
|
|
@@ -6523,7 +6531,6 @@ const validateOpenApiSpec$1 = (spec, logger) => {
|
|
|
6523
6531
|
valid: !issues.some((issue) => issue.severity === "error")
|
|
6524
6532
|
};
|
|
6525
6533
|
};
|
|
6526
|
-
|
|
6527
6534
|
//#endregion
|
|
6528
6535
|
//#region src/openApi/3.0.x/parser/index.ts
|
|
6529
6536
|
const parseV3_0_X = (context) => {
|
|
@@ -6729,7 +6736,6 @@ const parseV3_0_X = (context) => {
|
|
|
6729
6736
|
});
|
|
6730
6737
|
}
|
|
6731
6738
|
};
|
|
6732
|
-
|
|
6733
6739
|
//#endregion
|
|
6734
6740
|
//#region src/openApi/3.1.x/parser/filter.ts
|
|
6735
6741
|
/**
|
|
@@ -6798,7 +6804,6 @@ const filterSpec = ({ logger, operations, parameters, preserveOrder, requestBodi
|
|
|
6798
6804
|
}
|
|
6799
6805
|
eventFilterSpec.timeEnd();
|
|
6800
6806
|
};
|
|
6801
|
-
|
|
6802
6807
|
//#endregion
|
|
6803
6808
|
//#region src/openApi/3.1.x/parser/mediaType.ts
|
|
6804
6809
|
const contentToSchema = ({ content }) => {
|
|
@@ -6825,20 +6830,19 @@ const mediaTypeObjects = ({ content }) => {
|
|
|
6825
6830
|
});
|
|
6826
6831
|
return objects;
|
|
6827
6832
|
};
|
|
6828
|
-
|
|
6829
6833
|
//#endregion
|
|
6830
6834
|
//#region src/openApi/3.1.x/parser/schema.ts
|
|
6831
|
-
|
|
6835
|
+
function getSchemaTypes({ schema }) {
|
|
6832
6836
|
if (typeof schema.type === "string") return [schema.type];
|
|
6833
6837
|
if (schema.type) return schema.type;
|
|
6834
6838
|
if (schema.properties) return ["object"];
|
|
6835
6839
|
return [];
|
|
6836
|
-
}
|
|
6840
|
+
}
|
|
6837
6841
|
/**
|
|
6838
6842
|
* Finds the type of a discriminator property by looking it up in the provided schemas.
|
|
6839
6843
|
* Searches through properties and allOf chains to find the property definition.
|
|
6840
6844
|
*/
|
|
6841
|
-
|
|
6845
|
+
function findDiscriminatorPropertyType({ context, propertyName, schemas }) {
|
|
6842
6846
|
for (const schema of schemas) {
|
|
6843
6847
|
const resolved = schema.$ref ? context.resolveRef(schema.$ref) : schema;
|
|
6844
6848
|
const property = resolved.properties?.[propertyName];
|
|
@@ -6858,13 +6862,13 @@ const findDiscriminatorPropertyType = ({ context, propertyName, schemas }) => {
|
|
|
6858
6862
|
}
|
|
6859
6863
|
}
|
|
6860
6864
|
return "string";
|
|
6861
|
-
}
|
|
6865
|
+
}
|
|
6862
6866
|
/**
|
|
6863
6867
|
* Recursively finds discriminators in a schema, including nested allOf compositions.
|
|
6864
6868
|
* This is needed when a schema extends another schema via allOf, and that parent
|
|
6865
6869
|
* schema is itself an allOf composition with discriminators in inline schemas.
|
|
6866
6870
|
*/
|
|
6867
|
-
|
|
6871
|
+
function findDiscriminatorsInSchema({ context, discriminators = [], schema }) {
|
|
6868
6872
|
if (schema.discriminator) discriminators.push({
|
|
6869
6873
|
discriminator: schema.discriminator,
|
|
6870
6874
|
oneOf: schema.oneOf
|
|
@@ -6880,23 +6884,23 @@ const findDiscriminatorsInSchema = ({ context, discriminators = [], schema }) =>
|
|
|
6880
6884
|
});
|
|
6881
6885
|
}
|
|
6882
6886
|
return discriminators;
|
|
6883
|
-
}
|
|
6887
|
+
}
|
|
6884
6888
|
/**
|
|
6885
6889
|
* Gets the discriminator value for a schema.
|
|
6886
6890
|
* Returns only the schema's own discriminator value, not child values.
|
|
6887
6891
|
*/
|
|
6888
|
-
|
|
6892
|
+
function getAllDiscriminatorValues({ discriminator, schemaRef }) {
|
|
6889
6893
|
const values = [];
|
|
6890
6894
|
for (const [value, mappedSchemaRef] of Object.entries(discriminator.mapping || {})) if (mappedSchemaRef === schemaRef) values.push(value);
|
|
6891
6895
|
return values;
|
|
6892
|
-
}
|
|
6893
|
-
|
|
6896
|
+
}
|
|
6897
|
+
function parseSchemaJsDoc({ irSchema, schema }) {
|
|
6894
6898
|
if (schema.deprecated !== void 0) irSchema.deprecated = schema.deprecated;
|
|
6895
6899
|
if (schema.example) irSchema.example = schema.example;
|
|
6896
6900
|
if (schema.description) irSchema.description = schema.description;
|
|
6897
6901
|
if (schema.title) irSchema.title = schema.title;
|
|
6898
|
-
}
|
|
6899
|
-
|
|
6902
|
+
}
|
|
6903
|
+
function parseSchemaMeta({ irSchema, schema }) {
|
|
6900
6904
|
if (schema.const !== void 0) {
|
|
6901
6905
|
irSchema.const = schema.const;
|
|
6902
6906
|
if (!schema.type) if (schema.const === null) irSchema.type = "null";
|
|
@@ -6927,8 +6931,8 @@ const parseSchemaMeta = ({ irSchema, schema }) => {
|
|
|
6927
6931
|
if (schema.pattern) irSchema.pattern = schema.pattern;
|
|
6928
6932
|
if (schema.readOnly) irSchema.accessScope = "read";
|
|
6929
6933
|
else if (schema.writeOnly) irSchema.accessScope = "write";
|
|
6930
|
-
}
|
|
6931
|
-
|
|
6934
|
+
}
|
|
6935
|
+
function parseArray({ context, irSchema = {}, schema, state }) {
|
|
6932
6936
|
if (schema.prefixItems && schema.prefixItems.length || schema.maxItems && schema.maxItems === schema.minItems || schema.const !== void 0) irSchema.type = "tuple";
|
|
6933
6937
|
else irSchema.type = "array";
|
|
6934
6938
|
let schemaItems = [];
|
|
@@ -6961,20 +6965,20 @@ const parseArray = ({ context, irSchema = {}, schema, state }) => {
|
|
|
6961
6965
|
schema: irSchema
|
|
6962
6966
|
});
|
|
6963
6967
|
return irSchema;
|
|
6964
|
-
}
|
|
6965
|
-
|
|
6968
|
+
}
|
|
6969
|
+
function parseBoolean({ irSchema = {} }) {
|
|
6966
6970
|
irSchema.type = "boolean";
|
|
6967
6971
|
return irSchema;
|
|
6968
|
-
}
|
|
6969
|
-
|
|
6972
|
+
}
|
|
6973
|
+
function parseNull({ irSchema = {} }) {
|
|
6970
6974
|
irSchema.type = "null";
|
|
6971
6975
|
return irSchema;
|
|
6972
|
-
}
|
|
6973
|
-
|
|
6976
|
+
}
|
|
6977
|
+
function parseNumber({ irSchema = {}, schema }) {
|
|
6974
6978
|
irSchema.type = schema.type;
|
|
6975
6979
|
return irSchema;
|
|
6976
|
-
}
|
|
6977
|
-
|
|
6980
|
+
}
|
|
6981
|
+
function parseObject({ context, irSchema = {}, schema, state }) {
|
|
6978
6982
|
irSchema.type = "object";
|
|
6979
6983
|
const schemaProperties = {};
|
|
6980
6984
|
for (const name in schema.properties) {
|
|
@@ -7033,15 +7037,15 @@ const parseObject = ({ context, irSchema = {}, schema, state }) => {
|
|
|
7033
7037
|
}
|
|
7034
7038
|
}
|
|
7035
7039
|
return irSchema;
|
|
7036
|
-
}
|
|
7037
|
-
|
|
7040
|
+
}
|
|
7041
|
+
function parseString({ irSchema = {} }) {
|
|
7038
7042
|
irSchema.type = "string";
|
|
7039
7043
|
return irSchema;
|
|
7040
|
-
}
|
|
7041
|
-
|
|
7044
|
+
}
|
|
7045
|
+
function parseExtensions({ source, target }) {
|
|
7042
7046
|
for (const key in source) if (key.startsWith("x-")) target[key] = source[key];
|
|
7043
|
-
}
|
|
7044
|
-
|
|
7047
|
+
}
|
|
7048
|
+
function initIrSchema({ schema }) {
|
|
7045
7049
|
const irSchema = {};
|
|
7046
7050
|
parseSchemaJsDoc({
|
|
7047
7051
|
irSchema,
|
|
@@ -7052,8 +7056,8 @@ const initIrSchema = ({ schema }) => {
|
|
|
7052
7056
|
target: irSchema
|
|
7053
7057
|
});
|
|
7054
7058
|
return irSchema;
|
|
7055
|
-
}
|
|
7056
|
-
|
|
7059
|
+
}
|
|
7060
|
+
function parseAllOf({ context, schema, state }) {
|
|
7057
7061
|
let irSchema = initIrSchema({ schema });
|
|
7058
7062
|
parseSchemaMeta({
|
|
7059
7063
|
irSchema,
|
|
@@ -7204,8 +7208,8 @@ const parseAllOf = ({ context, schema, state }) => {
|
|
|
7204
7208
|
};
|
|
7205
7209
|
}
|
|
7206
7210
|
return irSchema;
|
|
7207
|
-
}
|
|
7208
|
-
|
|
7211
|
+
}
|
|
7212
|
+
function parseAnyOf({ context, schema, state }) {
|
|
7209
7213
|
let irSchema = initIrSchema({ schema });
|
|
7210
7214
|
parseSchemaMeta({
|
|
7211
7215
|
irSchema,
|
|
@@ -7225,7 +7229,7 @@ const parseAnyOf = ({ context, schema, state }) => {
|
|
|
7225
7229
|
schema: compositionSchema,
|
|
7226
7230
|
state
|
|
7227
7231
|
});
|
|
7228
|
-
if (schema.discriminator && irCompositionSchema.$ref
|
|
7232
|
+
if (schema.discriminator && irCompositionSchema.$ref) {
|
|
7229
7233
|
const valueSchemas = discriminatorValues(irCompositionSchema.$ref, schema.discriminator.mapping).map((value) => convertDiscriminatorValue(value, discriminatorPropertyType));
|
|
7230
7234
|
irCompositionSchema = {
|
|
7231
7235
|
items: [{
|
|
@@ -7261,9 +7265,13 @@ const parseAnyOf = ({ context, schema, state }) => {
|
|
|
7261
7265
|
};
|
|
7262
7266
|
}
|
|
7263
7267
|
return irSchema;
|
|
7264
|
-
}
|
|
7265
|
-
|
|
7268
|
+
}
|
|
7269
|
+
function parseEnum({ context, schema, state }) {
|
|
7266
7270
|
let irSchema = initIrSchema({ schema });
|
|
7271
|
+
parseSchemaMeta({
|
|
7272
|
+
irSchema,
|
|
7273
|
+
schema
|
|
7274
|
+
});
|
|
7267
7275
|
irSchema.type = "enum";
|
|
7268
7276
|
const schemaItems = [];
|
|
7269
7277
|
const schemaTypes = getSchemaTypes({ schema });
|
|
@@ -7293,8 +7301,8 @@ const parseEnum = ({ context, schema, state }) => {
|
|
|
7293
7301
|
schema: irSchema
|
|
7294
7302
|
});
|
|
7295
7303
|
return irSchema;
|
|
7296
|
-
}
|
|
7297
|
-
|
|
7304
|
+
}
|
|
7305
|
+
function parseOneOf({ context, schema, state }) {
|
|
7298
7306
|
let irSchema = initIrSchema({ schema });
|
|
7299
7307
|
parseSchemaMeta({
|
|
7300
7308
|
irSchema,
|
|
@@ -7314,7 +7322,7 @@ const parseOneOf = ({ context, schema, state }) => {
|
|
|
7314
7322
|
schema: compositionSchema,
|
|
7315
7323
|
state
|
|
7316
7324
|
});
|
|
7317
|
-
if (schema.discriminator && irCompositionSchema.$ref
|
|
7325
|
+
if (schema.discriminator && irCompositionSchema.$ref) {
|
|
7318
7326
|
const valueSchemas = discriminatorValues(irCompositionSchema.$ref, schema.discriminator.mapping).map((value) => convertDiscriminatorValue(value, discriminatorPropertyType));
|
|
7319
7327
|
irCompositionSchema = {
|
|
7320
7328
|
items: [{
|
|
@@ -7352,8 +7360,8 @@ const parseOneOf = ({ context, schema, state }) => {
|
|
|
7352
7360
|
};
|
|
7353
7361
|
}
|
|
7354
7362
|
return irSchema;
|
|
7355
|
-
}
|
|
7356
|
-
|
|
7363
|
+
}
|
|
7364
|
+
function parseRef({ context, schema, state }) {
|
|
7357
7365
|
if (!isTopLevelComponent(schema.$ref)) {
|
|
7358
7366
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
7359
7367
|
const refSchema = context.resolveRef(schema.$ref);
|
|
@@ -7397,8 +7405,8 @@ const parseRef = ({ context, schema, state }) => {
|
|
|
7397
7405
|
schema: irSchema
|
|
7398
7406
|
});
|
|
7399
7407
|
return irSchema;
|
|
7400
|
-
}
|
|
7401
|
-
|
|
7408
|
+
}
|
|
7409
|
+
function parseOneType({ context, irSchema, schema, state }) {
|
|
7402
7410
|
if (!irSchema) {
|
|
7403
7411
|
irSchema = initIrSchema({ schema });
|
|
7404
7412
|
parseSchemaMeta({
|
|
@@ -7446,8 +7454,8 @@ const parseOneType = ({ context, irSchema, schema, state }) => {
|
|
|
7446
7454
|
schema
|
|
7447
7455
|
});
|
|
7448
7456
|
}
|
|
7449
|
-
}
|
|
7450
|
-
|
|
7457
|
+
}
|
|
7458
|
+
function parseManyTypes({ context, irSchema, schema, state }) {
|
|
7451
7459
|
if (!irSchema) irSchema = initIrSchema({ schema });
|
|
7452
7460
|
const typeIrSchema = {};
|
|
7453
7461
|
parseSchemaMeta({
|
|
@@ -7474,8 +7482,8 @@ const parseManyTypes = ({ context, irSchema, schema, state }) => {
|
|
|
7474
7482
|
schema: irSchema
|
|
7475
7483
|
});
|
|
7476
7484
|
return irSchema;
|
|
7477
|
-
}
|
|
7478
|
-
|
|
7485
|
+
}
|
|
7486
|
+
function parseType({ context, schema, state }) {
|
|
7479
7487
|
const irSchema = initIrSchema({ schema });
|
|
7480
7488
|
parseSchemaMeta({
|
|
7481
7489
|
irSchema,
|
|
@@ -7500,8 +7508,8 @@ const parseType = ({ context, schema, state }) => {
|
|
|
7500
7508
|
},
|
|
7501
7509
|
state
|
|
7502
7510
|
});
|
|
7503
|
-
}
|
|
7504
|
-
|
|
7511
|
+
}
|
|
7512
|
+
function parseUnknown({ irSchema, schema }) {
|
|
7505
7513
|
if (!irSchema) irSchema = initIrSchema({ schema });
|
|
7506
7514
|
irSchema.type = "unknown";
|
|
7507
7515
|
parseSchemaMeta({
|
|
@@ -7509,8 +7517,8 @@ const parseUnknown = ({ irSchema, schema }) => {
|
|
|
7509
7517
|
schema
|
|
7510
7518
|
});
|
|
7511
7519
|
return irSchema;
|
|
7512
|
-
}
|
|
7513
|
-
|
|
7520
|
+
}
|
|
7521
|
+
function schemaToIrSchema({ context, schema, state }) {
|
|
7514
7522
|
if (!state) state = { circularReferenceTracker: /* @__PURE__ */ new Set() };
|
|
7515
7523
|
if (state.$ref) state.circularReferenceTracker.add(state.$ref);
|
|
7516
7524
|
if (schema.$ref) return parseRef({
|
|
@@ -7555,8 +7563,8 @@ const schemaToIrSchema = ({ context, schema, state }) => {
|
|
|
7555
7563
|
context,
|
|
7556
7564
|
schema
|
|
7557
7565
|
});
|
|
7558
|
-
}
|
|
7559
|
-
|
|
7566
|
+
}
|
|
7567
|
+
function parseSchema({ $ref, context, schema }) {
|
|
7560
7568
|
if (!context.ir.components) context.ir.components = {};
|
|
7561
7569
|
if (!context.ir.components.schemas) context.ir.components.schemas = {};
|
|
7562
7570
|
context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({
|
|
@@ -7567,8 +7575,7 @@ const parseSchema = ({ $ref, context, schema }) => {
|
|
|
7567
7575
|
circularReferenceTracker: /* @__PURE__ */ new Set()
|
|
7568
7576
|
}
|
|
7569
7577
|
});
|
|
7570
|
-
}
|
|
7571
|
-
|
|
7578
|
+
}
|
|
7572
7579
|
//#endregion
|
|
7573
7580
|
//#region src/openApi/3.1.x/parser/pagination.ts
|
|
7574
7581
|
const isPaginationType = (schemaTypes) => schemaTypes.includes("boolean") || schemaTypes.includes("integer") || schemaTypes.includes("number") || schemaTypes.includes("string");
|
|
@@ -7620,7 +7627,6 @@ const paginationField = ({ context, name, schema }) => {
|
|
|
7620
7627
|
}
|
|
7621
7628
|
return false;
|
|
7622
7629
|
};
|
|
7623
|
-
|
|
7624
7630
|
//#endregion
|
|
7625
7631
|
//#region src/openApi/3.1.x/parser/operation.ts
|
|
7626
7632
|
const parseOperationJsDoc = ({ irOperation, operation }) => {
|
|
@@ -7757,7 +7763,6 @@ const parseWebhookOperation = ({ context, key, method, ...options }) => {
|
|
|
7757
7763
|
});
|
|
7758
7764
|
context.ir.webhooks[key][method] = parsed;
|
|
7759
7765
|
};
|
|
7760
|
-
|
|
7761
7766
|
//#endregion
|
|
7762
7767
|
//#region src/openApi/3.1.x/parser/parameter.ts
|
|
7763
7768
|
/**
|
|
@@ -7857,7 +7862,6 @@ const parseParameter = ({ $ref, context, parameter }) => {
|
|
|
7857
7862
|
parameter
|
|
7858
7863
|
});
|
|
7859
7864
|
};
|
|
7860
|
-
|
|
7861
7865
|
//#endregion
|
|
7862
7866
|
//#region src/openApi/3.1.x/parser/requestBody.ts
|
|
7863
7867
|
const requestBodyToIrRequestBody = ({ $ref, context, requestBody }) => {
|
|
@@ -7888,7 +7892,6 @@ const parseRequestBody = ({ $ref, context, requestBody }) => {
|
|
|
7888
7892
|
requestBody
|
|
7889
7893
|
});
|
|
7890
7894
|
};
|
|
7891
|
-
|
|
7892
7895
|
//#endregion
|
|
7893
7896
|
//#region src/openApi/3.1.x/parser/server.ts
|
|
7894
7897
|
const parseServers = ({ context }) => {
|
|
@@ -7902,7 +7905,6 @@ const parseServers = ({ context }) => {
|
|
|
7902
7905
|
}
|
|
7903
7906
|
if (!context.ir.servers) context.ir.servers = [{ url: "/" }];
|
|
7904
7907
|
};
|
|
7905
|
-
|
|
7906
7908
|
//#endregion
|
|
7907
7909
|
//#region src/openApi/3.1.x/parser/validate.ts
|
|
7908
7910
|
const validateOpenApiSpec = (spec, logger) => {
|
|
@@ -7971,7 +7973,6 @@ const validateOpenApiSpec = (spec, logger) => {
|
|
|
7971
7973
|
valid: !issues.some((issue) => issue.severity === "error")
|
|
7972
7974
|
};
|
|
7973
7975
|
};
|
|
7974
|
-
|
|
7975
7976
|
//#endregion
|
|
7976
7977
|
//#region src/openApi/3.1.x/parser/webhook.ts
|
|
7977
7978
|
const parseWebhooks = ({ context, securitySchemesMap }) => {
|
|
@@ -8120,7 +8121,6 @@ const parseWebhooks = ({ context, securitySchemesMap }) => {
|
|
|
8120
8121
|
});
|
|
8121
8122
|
}
|
|
8122
8123
|
};
|
|
8123
|
-
|
|
8124
8124
|
//#endregion
|
|
8125
8125
|
//#region src/openApi/3.1.x/parser/index.ts
|
|
8126
8126
|
const parseV3_1_X = (context) => {
|
|
@@ -8330,7 +8330,6 @@ const parseV3_1_X = (context) => {
|
|
|
8330
8330
|
securitySchemesMap
|
|
8331
8331
|
});
|
|
8332
8332
|
};
|
|
8333
|
-
|
|
8334
8333
|
//#endregion
|
|
8335
8334
|
//#region src/openApi/index.ts
|
|
8336
8335
|
/**
|
|
@@ -8353,7 +8352,6 @@ function parseOpenApiSpec(context) {
|
|
|
8353
8352
|
}
|
|
8354
8353
|
throw new Error("Unsupported OpenAPI specification");
|
|
8355
8354
|
}
|
|
8356
|
-
|
|
8357
8355
|
//#endregion
|
|
8358
8356
|
//#region src/openApi/shared/locations/operation.ts
|
|
8359
8357
|
/**
|
|
@@ -8401,7 +8399,6 @@ const OperationPath = {
|
|
|
8401
8399
|
},
|
|
8402
8400
|
id: () => (operation) => [operation.id]
|
|
8403
8401
|
};
|
|
8404
|
-
|
|
8405
8402
|
//#endregion
|
|
8406
8403
|
//#region src/openApi/shared/utils/patch.ts
|
|
8407
8404
|
async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
@@ -8510,7 +8507,6 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8510
8507
|
await patchFn(operation);
|
|
8511
8508
|
}
|
|
8512
8509
|
}
|
|
8513
|
-
|
|
8514
8510
|
//#endregion
|
|
8515
8511
|
//#region src/plugins/shared/utils/config.ts
|
|
8516
8512
|
const definePluginConfig = (defaultConfig) => (userConfig) => ({
|
|
@@ -8528,7 +8524,6 @@ const mappers = {
|
|
|
8528
8524
|
function: (name) => ({ name }),
|
|
8529
8525
|
string: (name) => ({ name })
|
|
8530
8526
|
};
|
|
8531
|
-
|
|
8532
8527
|
//#endregion
|
|
8533
8528
|
//#region src/plugins/symbol.ts
|
|
8534
8529
|
/**
|
|
@@ -8555,13 +8550,38 @@ function buildSymbolIn({ plugin, ...ctx }) {
|
|
|
8555
8550
|
name: ctx.naming ? applyNaming(ctx.name, ctx.naming) : ctx.name
|
|
8556
8551
|
};
|
|
8557
8552
|
}
|
|
8558
|
-
|
|
8553
|
+
//#endregion
|
|
8554
|
+
//#region src/plugins/validator.ts
|
|
8555
|
+
/**
|
|
8556
|
+
* The ordered list of standard HTTP request layer keys.
|
|
8557
|
+
*/
|
|
8558
|
+
const requestValidatorLayers = [
|
|
8559
|
+
"body",
|
|
8560
|
+
"headers",
|
|
8561
|
+
"path",
|
|
8562
|
+
"query"
|
|
8563
|
+
];
|
|
8564
|
+
/**
|
|
8565
|
+
* Resolves the effective configuration for a single layer by merging the
|
|
8566
|
+
* layer's defaults with any explicit overrides supplied in `layers`.
|
|
8567
|
+
*
|
|
8568
|
+
* @param layers - Optional map of per-layer overrides.
|
|
8569
|
+
* @param key - The layer key to resolve.
|
|
8570
|
+
* @param defaultValues - Required fallback values for every layer key.
|
|
8571
|
+
* @returns The fully-resolved layer configuration.
|
|
8572
|
+
*/
|
|
8573
|
+
function resolveValidatorLayer(layers, key, defaultValues) {
|
|
8574
|
+
const override = Object.fromEntries(Object.entries(layers?.[key] ?? {}).filter(([, v]) => v !== void 0));
|
|
8575
|
+
return {
|
|
8576
|
+
...defaultValues[key],
|
|
8577
|
+
...override
|
|
8578
|
+
};
|
|
8579
|
+
}
|
|
8559
8580
|
//#endregion
|
|
8560
8581
|
//#region src/utils/escape.ts
|
|
8561
8582
|
function escapeComment(value) {
|
|
8562
8583
|
return value.replace(/\*\//g, "*").replace(/\/\*/g, "*").replace(/\r?\n(.*)/g, (_l, w) => EOL + w.trim());
|
|
8563
8584
|
}
|
|
8564
|
-
|
|
8565
8585
|
//#endregion
|
|
8566
8586
|
//#region src/utils/exports.ts
|
|
8567
8587
|
/**
|
|
@@ -8573,7 +8593,6 @@ const utils = {
|
|
|
8573
8593
|
},
|
|
8574
8594
|
toCase
|
|
8575
8595
|
};
|
|
8576
|
-
|
|
8577
8596
|
//#endregion
|
|
8578
8597
|
//#region src/utils/header.ts
|
|
8579
8598
|
/**
|
|
@@ -8591,7 +8610,6 @@ function outputHeaderToPrefix(ctx) {
|
|
|
8591
8610
|
const content = lines.join("\n");
|
|
8592
8611
|
return content ? `${content}\n\n` : "";
|
|
8593
8612
|
}
|
|
8594
|
-
|
|
8595
8613
|
//#endregion
|
|
8596
8614
|
//#region src/utils/path.ts
|
|
8597
8615
|
/**
|
|
@@ -8695,7 +8713,7 @@ function pathToName(path, options) {
|
|
|
8695
8713
|
}
|
|
8696
8714
|
return decodeURI(names.join("-"));
|
|
8697
8715
|
}
|
|
8698
|
-
|
|
8699
8716
|
//#endregion
|
|
8700
|
-
export { ConfigError, ConfigValidationError, Context, HeyApiError, IntentContext, JobError, MinHeap, OperationPath, OperationStrategy, PluginInstance, addItemsToSchema, applyNaming, buildGraph, buildSymbolIn, checkNodeVersion, childContext, compileInputPath, createOperationKey, createSchemaProcessor, createSchemaWalker, debugTools, deduplicateSchema, defaultPaginationKeywords, definePluginConfig, dependencyFactory, encodeJsonPointerSegment, ensureDirSync, escapeComment, findPackageJson, findTsConfigPath, getInput, getLogs, getParser, getSpec, hasOperationDataRequired, hasParameterGroupObjectRequired, hasParametersObjectRequired, heyApiRegistryBaseUrl, inputToApiRegistry, isEnvironment, isTopLevelComponent, jsonPointerToPath, loadPackageJson, logCrashReport, logInputPaths, mappers, normalizeJsonPointer, openGitHubIssueWithCrashReport, operationPagination, operationResponsesMap, outputHeaderToPrefix, parameterWithPagination, parseOpenApiSpec, parseUrl, parseV2_0_X, parseV3_0_X, parseV3_1_X, patchOpenApiSpec, pathToJsonPointer, pathToName, postprocessOutput, printCliIntro, printCrashReport, refToName, resolveNaming, resolveRef, resolveSource, satisfies, shouldReportCrash, statusCodeToGroup, toCase, utils, valueToObject };
|
|
8717
|
+
export { ConfigError, ConfigValidationError, Context, HeyApiError, InputError, IntentContext, JobError, MinHeap, OperationPath, OperationStrategy, PluginInstance, addItemsToSchema, applyNaming, buildGraph, buildSymbolIn, checkNodeVersion, childContext, compileInputPath, createOperationKey, createSchemaProcessor, createSchemaWalker, debugTools, deduplicateSchema, defaultPaginationKeywords, definePluginConfig, dependencyFactory, encodeJsonPointerSegment, ensureDirSync, escapeComment, findPackageJson, findTsConfigPath, getInput, getInputError, getLogs, getParser, getSpec, hasOperationDataRequired, hasParameterGroupObjectRequired, hasParametersObjectRequired, heyApiRegistryBaseUrl, inputToApiRegistry, isEnvironment, isTopLevelComponent, jsonPointerToPath, loadPackageJson, logCrashReport, logInputPaths, mappers, normalizeJsonPointer, openGitHubIssueWithCrashReport, operationPagination, operationResponsesMap, outputHeaderToPrefix, parameterWithPagination, parseOpenApiSpec, parseUrl, parseV2_0_X, parseV3_0_X, parseV3_1_X, patchOpenApiSpec, pathToJsonPointer, pathToName, postprocessOutput, printCliIntro, printCrashReport, refToName, requestValidatorLayers, resolveNaming, resolveRef, resolveSource, resolveValidatorLayer, satisfies, shouldReportCrash, statusCodeToGroup, toCase, utils, valueToObject };
|
|
8718
|
+
|
|
8701
8719
|
//# sourceMappingURL=index.mjs.map
|