@hey-api/shared 0.3.0 → 0.4.1
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 +33 -5
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +349 -311
- package/dist/index.mjs.map +1 -1
- package/package.json +11 -12
package/dist/index.mjs
CHANGED
|
@@ -5,9 +5,8 @@ import open from "open";
|
|
|
5
5
|
import { sync } from "cross-spawn";
|
|
6
6
|
import * as semver from "semver";
|
|
7
7
|
import { getResolvedInput, sendRequest } from "@hey-api/json-schema-ref-parser";
|
|
8
|
-
import { fromRef, ref } from "@hey-api/codegen-core";
|
|
8
|
+
import { fromRef, log, 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,20 +625,26 @@ 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) {
|
|
631
|
+
if (!fs.existsSync(config.path) || !fs.readdirSync(config.path).length) return;
|
|
607
632
|
for (const processor of config.postProcess) {
|
|
608
633
|
const resolved = typeof processor === "string" ? postProcessors[processor] : processor;
|
|
609
634
|
if (!resolved) continue;
|
|
610
635
|
const name = resolved.name ?? resolved.command;
|
|
611
636
|
const args = resolved.args.map((arg) => arg.replace("{{path}}", config.path));
|
|
612
637
|
console.log(`${jobPrefix}🧹 Running ${colors.cyanBright(name)}`);
|
|
613
|
-
sync(resolved.command, args);
|
|
638
|
+
const result = sync(resolved.command, args);
|
|
639
|
+
if (result.error) throw new ConfigError(`Post-processor "${name}" failed to run: ${result.error.message}`);
|
|
640
|
+
if (result.status !== null && result.status !== 0) {
|
|
641
|
+
let message = `Post-processor "${name}" exited with code ${result.status}`;
|
|
642
|
+
const stderr = result.stderr?.toString().trim();
|
|
643
|
+
if (stderr) message += `:\n${stderr}`;
|
|
644
|
+
throw new ConfigError(message);
|
|
645
|
+
}
|
|
614
646
|
}
|
|
615
647
|
}
|
|
616
|
-
|
|
617
648
|
//#endregion
|
|
618
649
|
//#region src/config/utils/config.ts
|
|
619
650
|
const isPlainObject = (value) => typeof value === "object" && value !== null && !Array.isArray(value) && typeof value !== "function";
|
|
@@ -657,7 +688,6 @@ const valueToObject = ({ defaultValue, mappers, value }) => {
|
|
|
657
688
|
}
|
|
658
689
|
return result;
|
|
659
690
|
};
|
|
660
|
-
|
|
661
691
|
//#endregion
|
|
662
692
|
//#region src/config/output/source/config.ts
|
|
663
693
|
function resolveSource(config) {
|
|
@@ -675,7 +705,6 @@ function resolveSource(config) {
|
|
|
675
705
|
else if (source.path === false) source.path = null;
|
|
676
706
|
return source;
|
|
677
707
|
}
|
|
678
|
-
|
|
679
708
|
//#endregion
|
|
680
709
|
//#region src/config/parser/config.ts
|
|
681
710
|
const defaultPaginationKeywords = [
|
|
@@ -774,7 +803,6 @@ function getParser(userConfig) {
|
|
|
774
803
|
value: userConfig.parser
|
|
775
804
|
});
|
|
776
805
|
}
|
|
777
|
-
|
|
778
806
|
//#endregion
|
|
779
807
|
//#region src/config/utils/dependencies.ts
|
|
780
808
|
const satisfies = (...args) => semver.satisfies(...args);
|
|
@@ -799,7 +827,6 @@ function dependencyFactory(dependencies) {
|
|
|
799
827
|
}
|
|
800
828
|
};
|
|
801
829
|
}
|
|
802
|
-
|
|
803
830
|
//#endregion
|
|
804
831
|
//#region src/debug/graph.ts
|
|
805
832
|
const analyzeStructure = (graph) => {
|
|
@@ -836,7 +863,6 @@ const graph = {
|
|
|
836
863
|
analyzeStructure,
|
|
837
864
|
exportForVisualization
|
|
838
865
|
};
|
|
839
|
-
|
|
840
866
|
//#endregion
|
|
841
867
|
//#region src/ir/parameter.ts
|
|
842
868
|
const getPaginationSchema = ({ context, parameter }) => {
|
|
@@ -905,7 +931,6 @@ const parameterWithPagination = ({ context, parameters }) => {
|
|
|
905
931
|
};
|
|
906
932
|
}
|
|
907
933
|
};
|
|
908
|
-
|
|
909
934
|
//#endregion
|
|
910
935
|
//#region src/ir/schema.ts
|
|
911
936
|
/**
|
|
@@ -957,7 +982,6 @@ function deduplicateSchema({ detectFormat = true, schema }) {
|
|
|
957
982
|
if (result.type === "unknown") return {};
|
|
958
983
|
return result;
|
|
959
984
|
}
|
|
960
|
-
|
|
961
985
|
//#endregion
|
|
962
986
|
//#region src/ir/utils.ts
|
|
963
987
|
/**
|
|
@@ -985,7 +1009,6 @@ function addItemsToSchema({ items, logicalOperator = "or", mutateSchemaOneItem =
|
|
|
985
1009
|
schema.items = items;
|
|
986
1010
|
return schema;
|
|
987
1011
|
}
|
|
988
|
-
|
|
989
1012
|
//#endregion
|
|
990
1013
|
//#region src/ir/operation.ts
|
|
991
1014
|
const hasOperationDataRequired = (operation) => {
|
|
@@ -1102,7 +1125,6 @@ const operationResponsesMap = (operation) => {
|
|
|
1102
1125
|
}
|
|
1103
1126
|
return result;
|
|
1104
1127
|
};
|
|
1105
|
-
|
|
1106
1128
|
//#endregion
|
|
1107
1129
|
//#region src/utils/naming/naming.ts
|
|
1108
1130
|
const uppercaseRegExp = /[\p{Lu}]/u;
|
|
@@ -1220,7 +1242,6 @@ function applyNaming(value, config) {
|
|
|
1220
1242
|
}
|
|
1221
1243
|
return toCase(result, casing);
|
|
1222
1244
|
}
|
|
1223
|
-
|
|
1224
1245
|
//#endregion
|
|
1225
1246
|
//#region src/openApi/shared/utils/operation.ts
|
|
1226
1247
|
const httpMethods = [
|
|
@@ -1278,32 +1299,31 @@ function operationToId({ context, count = 1, id, method, path, state }) {
|
|
|
1278
1299
|
}));
|
|
1279
1300
|
return result;
|
|
1280
1301
|
}
|
|
1281
|
-
|
|
1282
1302
|
//#endregion
|
|
1283
1303
|
//#region src/debug/ir.ts
|
|
1284
1304
|
const indent = (level) => " ".repeat(level);
|
|
1285
|
-
const log = (message, level) => console.log(`${indent(level ?? 0)}${message}`);
|
|
1305
|
+
const log$1 = (message, level) => console.log(`${indent(level ?? 0)}${message}`);
|
|
1286
1306
|
const print = (ir, options = {}) => {
|
|
1287
1307
|
const { depth = 2, section = "all", verbosity = "summary" } = options;
|
|
1288
1308
|
const printObject = (obj, level, kind = "generic") => {
|
|
1289
1309
|
if (verbosity === "summary" && obj && typeof obj === "object") if (kind === "responses") {
|
|
1290
1310
|
const count = Object.keys(obj).length;
|
|
1291
1311
|
const noun = count === 1 ? "code" : "codes";
|
|
1292
|
-
log(`responses: ${colors.yellow(`${count} ${noun}`)}`, level);
|
|
1293
|
-
} else if (kind === "requestBody") log(`requestBody: ${Object.keys(obj).join(", ")}`, level);
|
|
1294
|
-
else if (kind === "schema") log(`schema keys: ${Object.keys(obj).join(", ")}`, level);
|
|
1295
|
-
else log(`keys: ${Object.keys(obj).join(", ")}`, level);
|
|
1296
|
-
else log(JSON.stringify(obj, null, depth), level);
|
|
1312
|
+
log$1(`responses: ${colors.yellow(`${count} ${noun}`)}`, level);
|
|
1313
|
+
} else if (kind === "requestBody") log$1(`requestBody: ${Object.keys(obj).join(", ")}`, level);
|
|
1314
|
+
else if (kind === "schema") log$1(`schema keys: ${Object.keys(obj).join(", ")}`, level);
|
|
1315
|
+
else log$1(`keys: ${Object.keys(obj).join(", ")}`, level);
|
|
1316
|
+
else log$1(JSON.stringify(obj, null, depth), level);
|
|
1297
1317
|
};
|
|
1298
1318
|
const printPathItem = (key, item, base = 1) => {
|
|
1299
1319
|
if ("$ref" in item) {
|
|
1300
|
-
log(`${colors.cyan(key)} is a $ref → ${colors.yellow(item.$ref)}`, base);
|
|
1320
|
+
log$1(`${colors.cyan(key)} is a $ref → ${colors.yellow(item.$ref)}`, base);
|
|
1301
1321
|
return;
|
|
1302
1322
|
}
|
|
1303
1323
|
for (const method of Object.keys(item)) {
|
|
1304
1324
|
if (!httpMethods.includes(method)) continue;
|
|
1305
1325
|
const operation = item[method];
|
|
1306
|
-
log(`${colors.green(method.toUpperCase())} ${colors.cyan(key)} (${colors.magenta(operation.operationId ?? "")})`, base);
|
|
1326
|
+
log$1(`${colors.green(method.toUpperCase())} ${colors.cyan(key)} (${colors.magenta(operation.operationId ?? "")})`, base);
|
|
1307
1327
|
if (operation.body) printObject(operation.body, base + 1, "requestBody");
|
|
1308
1328
|
if (operation.responses) printObject(operation.responses, base + 1, "responses");
|
|
1309
1329
|
}
|
|
@@ -1312,34 +1332,31 @@ const print = (ir, options = {}) => {
|
|
|
1312
1332
|
for (const section of sections) switch (section) {
|
|
1313
1333
|
case "components":
|
|
1314
1334
|
if (ir.components?.schemas) {
|
|
1315
|
-
log(`Components: ${Object.keys(ir.components.schemas).length} schemas`);
|
|
1335
|
+
log$1(`Components: ${Object.keys(ir.components.schemas).length} schemas`);
|
|
1316
1336
|
for (const [, schema] of Object.entries(ir.components.schemas)) printObject(schema, 1, "schema");
|
|
1317
1337
|
}
|
|
1318
1338
|
break;
|
|
1319
1339
|
case "paths": {
|
|
1320
1340
|
const paths = ir.paths || {};
|
|
1321
|
-
log(`paths (${Object.keys(paths).length} items):`);
|
|
1341
|
+
log$1(`paths (${Object.keys(paths).length} items):`);
|
|
1322
1342
|
for (const [path, item] of Object.entries(paths)) printPathItem(path, item);
|
|
1323
1343
|
break;
|
|
1324
1344
|
}
|
|
1325
1345
|
case "servers": break;
|
|
1326
1346
|
case "webhooks": {
|
|
1327
1347
|
const webhooks = ir.webhooks || {};
|
|
1328
|
-
log(`webhooks (${Object.keys(webhooks).length} items):`);
|
|
1348
|
+
log$1(`webhooks (${Object.keys(webhooks).length} items):`);
|
|
1329
1349
|
for (const [path, item] of Object.entries(webhooks)) printPathItem(path, item);
|
|
1330
1350
|
break;
|
|
1331
1351
|
}
|
|
1332
1352
|
}
|
|
1333
1353
|
};
|
|
1334
|
-
const ir = { print };
|
|
1335
|
-
|
|
1336
1354
|
//#endregion
|
|
1337
1355
|
//#region src/debug/index.ts
|
|
1338
1356
|
const debugTools = {
|
|
1339
1357
|
graph,
|
|
1340
|
-
ir
|
|
1358
|
+
ir: { print }
|
|
1341
1359
|
};
|
|
1342
|
-
|
|
1343
1360
|
//#endregion
|
|
1344
1361
|
//#region src/getSpec.ts
|
|
1345
1362
|
const headersEntries = (headers) => {
|
|
@@ -1462,7 +1479,6 @@ async function getSpec({ fetchOptions, inputPath, timeout, watch }) {
|
|
|
1462
1479
|
resolvedInput
|
|
1463
1480
|
};
|
|
1464
1481
|
}
|
|
1465
|
-
|
|
1466
1482
|
//#endregion
|
|
1467
1483
|
//#region src/utils/minHeap.ts
|
|
1468
1484
|
var MinHeap = class {
|
|
@@ -1523,7 +1539,6 @@ var MinHeap = class {
|
|
|
1523
1539
|
}
|
|
1524
1540
|
}
|
|
1525
1541
|
};
|
|
1526
|
-
|
|
1527
1542
|
//#endregion
|
|
1528
1543
|
//#region src/graph/walk.ts
|
|
1529
1544
|
/**
|
|
@@ -1648,7 +1663,6 @@ const walk = (graph, callback, options) => {
|
|
|
1648
1663
|
if (options?.order === "topological") return walkTopological(graph, callback, options);
|
|
1649
1664
|
return walkDeclarations(graph, callback, options);
|
|
1650
1665
|
};
|
|
1651
|
-
|
|
1652
1666
|
//#endregion
|
|
1653
1667
|
//#region src/ir/graph.ts
|
|
1654
1668
|
const irTopLevelKinds = [
|
|
@@ -1711,7 +1725,6 @@ const getIrPointerPriority = (pointer) => {
|
|
|
1711
1725
|
if (result.matched) return kindPriority[result.kind] ?? defaultPriority;
|
|
1712
1726
|
return defaultPriority;
|
|
1713
1727
|
};
|
|
1714
|
-
|
|
1715
1728
|
//#endregion
|
|
1716
1729
|
//#region src/utils/ref.ts
|
|
1717
1730
|
const jsonPointerSlash = /~1/g;
|
|
@@ -1721,8 +1734,7 @@ const jsonPointerTilde = /~0/g;
|
|
|
1721
1734
|
*/
|
|
1722
1735
|
function refToName($ref) {
|
|
1723
1736
|
const path = jsonPointerToPath($ref);
|
|
1724
|
-
|
|
1725
|
-
return decodeURI(name);
|
|
1737
|
+
return path[path.length - 1];
|
|
1726
1738
|
}
|
|
1727
1739
|
/**
|
|
1728
1740
|
* Encodes a path segment for use in a JSON Pointer (RFC 6901).
|
|
@@ -1805,7 +1817,7 @@ function isTopLevelComponent(refOrPath) {
|
|
|
1805
1817
|
return false;
|
|
1806
1818
|
}
|
|
1807
1819
|
function resolveRef({ $ref, spec }) {
|
|
1808
|
-
const path = jsonPointerToPath(
|
|
1820
|
+
const path = jsonPointerToPath($ref);
|
|
1809
1821
|
let current = spec;
|
|
1810
1822
|
for (const part of path) {
|
|
1811
1823
|
const segment = part;
|
|
@@ -1814,7 +1826,6 @@ function resolveRef({ $ref, spec }) {
|
|
|
1814
1826
|
}
|
|
1815
1827
|
return current;
|
|
1816
1828
|
}
|
|
1817
|
-
|
|
1818
1829
|
//#endregion
|
|
1819
1830
|
//#region src/plugins/shared/utils/instance.ts
|
|
1820
1831
|
const defaultGetFilePath = (symbol) => {
|
|
@@ -2145,7 +2156,6 @@ var PluginInstance = class {
|
|
|
2145
2156
|
return false;
|
|
2146
2157
|
}
|
|
2147
2158
|
};
|
|
2148
|
-
|
|
2149
2159
|
//#endregion
|
|
2150
2160
|
//#region src/ir/context.ts
|
|
2151
2161
|
var Context = class {
|
|
@@ -2256,7 +2266,6 @@ var Context = class {
|
|
|
2256
2266
|
});
|
|
2257
2267
|
}
|
|
2258
2268
|
};
|
|
2259
|
-
|
|
2260
2269
|
//#endregion
|
|
2261
2270
|
//#region src/ir/intents.ts
|
|
2262
2271
|
var IntentContext = class {
|
|
@@ -2276,7 +2285,6 @@ var IntentContext = class {
|
|
|
2276
2285
|
source["x-codeSamples"].push(example);
|
|
2277
2286
|
}
|
|
2278
2287
|
};
|
|
2279
|
-
|
|
2280
2288
|
//#endregion
|
|
2281
2289
|
//#region src/ir/schema-processor.ts
|
|
2282
2290
|
function createSchemaProcessor() {
|
|
@@ -2313,7 +2321,6 @@ function createSchemaProcessor() {
|
|
|
2313
2321
|
}
|
|
2314
2322
|
};
|
|
2315
2323
|
}
|
|
2316
|
-
|
|
2317
2324
|
//#endregion
|
|
2318
2325
|
//#region src/ir/schema-walker.ts
|
|
2319
2326
|
/**
|
|
@@ -2382,24 +2389,25 @@ function childContext(ctx, ...segments) {
|
|
|
2382
2389
|
path: ref([...fromRef(ctx.path), ...segments])
|
|
2383
2390
|
};
|
|
2384
2391
|
}
|
|
2385
|
-
|
|
2386
2392
|
//#endregion
|
|
2387
2393
|
//#region src/openApi/shared/utils/filter.ts
|
|
2388
2394
|
const namespaceNeedle = "/";
|
|
2389
|
-
|
|
2390
|
-
|
|
2395
|
+
function addNamespace(namespace, value = "") {
|
|
2396
|
+
return `${namespace}${namespaceNeedle}${value}`;
|
|
2397
|
+
}
|
|
2398
|
+
function removeNamespace(key) {
|
|
2391
2399
|
const index = key.indexOf(namespaceNeedle);
|
|
2392
2400
|
return {
|
|
2393
2401
|
name: key.slice(index + 1),
|
|
2394
2402
|
namespace: key.slice(0, index)
|
|
2395
2403
|
};
|
|
2396
|
-
}
|
|
2404
|
+
}
|
|
2397
2405
|
/**
|
|
2398
2406
|
* Converts reference strings from OpenAPI $ref keywords into namespaces.
|
|
2399
2407
|
*
|
|
2400
2408
|
* @example '#/components/schemas/Foo' -> 'schema'
|
|
2401
2409
|
*/
|
|
2402
|
-
|
|
2410
|
+
function stringToNamespace(value) {
|
|
2403
2411
|
switch (value) {
|
|
2404
2412
|
case "parameters": return "parameter";
|
|
2405
2413
|
case "requestBodies": return "body";
|
|
@@ -2408,8 +2416,16 @@ const stringToNamespace = (value) => {
|
|
|
2408
2416
|
case "schemas": return "schema";
|
|
2409
2417
|
default: return "unknown";
|
|
2410
2418
|
}
|
|
2411
|
-
}
|
|
2412
|
-
|
|
2419
|
+
}
|
|
2420
|
+
function getResourceDependencies(key, resourceMetadata) {
|
|
2421
|
+
const { namespace } = removeNamespace(key);
|
|
2422
|
+
if (namespace === "body") return resourceMetadata.requestBodies.get(key)?.dependencies;
|
|
2423
|
+
if (namespace === "operation") return resourceMetadata.operations.get(key)?.dependencies;
|
|
2424
|
+
if (namespace === "parameter") return resourceMetadata.parameters.get(key)?.dependencies;
|
|
2425
|
+
if (namespace === "response") return resourceMetadata.responses.get(key)?.dependencies;
|
|
2426
|
+
if (namespace === "schema") return resourceMetadata.schemas.get(key)?.dependencies;
|
|
2427
|
+
}
|
|
2428
|
+
function createFiltersSetAndRegExps(type, filters) {
|
|
2413
2429
|
const keys = [];
|
|
2414
2430
|
const regexps = [];
|
|
2415
2431
|
if (filters) for (const value of filters) if (value.startsWith("/") && value.endsWith("/")) regexps.push(new RegExp(value.slice(1, value.length - 1)));
|
|
@@ -2418,8 +2434,8 @@ const createFiltersSetAndRegExps = (type, filters) => {
|
|
|
2418
2434
|
regexps,
|
|
2419
2435
|
set: new Set(keys)
|
|
2420
2436
|
};
|
|
2421
|
-
}
|
|
2422
|
-
|
|
2437
|
+
}
|
|
2438
|
+
function collectFiltersSetFromRegExpsOpenApiV2({ excludeOperations, excludeSchemas, includeOperations, includeSchemas, spec }) {
|
|
2423
2439
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2424
2440
|
const path = entry[0];
|
|
2425
2441
|
const pathItem = entry[1];
|
|
@@ -2439,8 +2455,8 @@ const collectFiltersSetFromRegExpsOpenApiV2 = ({ excludeOperations, excludeSchem
|
|
|
2439
2455
|
if (includeSchemas.regexps.some((regexp) => regexp.test(key))) includeSchemas.set.add(addNamespace("schema", key));
|
|
2440
2456
|
}
|
|
2441
2457
|
}
|
|
2442
|
-
}
|
|
2443
|
-
|
|
2458
|
+
}
|
|
2459
|
+
function collectFiltersSetFromRegExpsOpenApiV3({ excludeOperations, excludeParameters, excludeRequestBodies, excludeResponses, excludeSchemas, includeOperations, includeParameters, includeRequestBodies, includeResponses, includeSchemas, spec }) {
|
|
2444
2460
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2445
2461
|
const path = entry[0];
|
|
2446
2462
|
const pathItem = entry[1];
|
|
@@ -2472,8 +2488,8 @@ const collectFiltersSetFromRegExpsOpenApiV3 = ({ excludeOperations, excludeParam
|
|
|
2472
2488
|
if (includeSchemas.regexps.some((regexp) => regexp.test(key))) includeSchemas.set.add(addNamespace("schema", key));
|
|
2473
2489
|
}
|
|
2474
2490
|
}
|
|
2475
|
-
}
|
|
2476
|
-
|
|
2491
|
+
}
|
|
2492
|
+
function collectFiltersSetFromRegExps({ spec, ...filters }) {
|
|
2477
2493
|
if ("swagger" in spec) collectFiltersSetFromRegExpsOpenApiV2({
|
|
2478
2494
|
...filters,
|
|
2479
2495
|
spec
|
|
@@ -2482,8 +2498,8 @@ const collectFiltersSetFromRegExps = ({ spec, ...filters }) => {
|
|
|
2482
2498
|
...filters,
|
|
2483
2499
|
spec
|
|
2484
2500
|
});
|
|
2485
|
-
}
|
|
2486
|
-
|
|
2501
|
+
}
|
|
2502
|
+
function createFilters(config, spec, logger) {
|
|
2487
2503
|
const eventCreateFilters = logger.timeEvent("create-filters");
|
|
2488
2504
|
const excludeOperations = createFiltersSetAndRegExps("operation", config?.operations?.exclude);
|
|
2489
2505
|
const includeOperations = createFiltersSetAndRegExps("operation", config?.operations?.include);
|
|
@@ -2539,16 +2555,18 @@ const createFilters = (config, spec, logger) => {
|
|
|
2539
2555
|
};
|
|
2540
2556
|
eventCreateFilters.timeEnd();
|
|
2541
2557
|
return filters;
|
|
2542
|
-
}
|
|
2543
|
-
|
|
2558
|
+
}
|
|
2559
|
+
function hasFilters(config) {
|
|
2544
2560
|
if (!config) return false;
|
|
2545
2561
|
if (config.orphans === false || config.deprecated === false) return true;
|
|
2546
2562
|
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);
|
|
2547
|
-
}
|
|
2563
|
+
}
|
|
2548
2564
|
/**
|
|
2549
2565
|
* Collect operations that satisfy the include/exclude filters and schema dependencies.
|
|
2566
|
+
*
|
|
2567
|
+
* Must be called after dropping components.
|
|
2550
2568
|
*/
|
|
2551
|
-
|
|
2569
|
+
function collectOperations({ filters, parameters, requestBodies, resourceMetadata, responses, schemas }) {
|
|
2552
2570
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2553
2571
|
const stack = [...filters.operations.include.size ? filters.operations.include : new Set(resourceMetadata.operations.keys())];
|
|
2554
2572
|
while (stack.length) {
|
|
@@ -2565,18 +2583,22 @@ const collectOperations = ({ filters, parameters, requestBodies, resourceMetadat
|
|
|
2565
2583
|
case "body": return !requestBodies.has(dependency);
|
|
2566
2584
|
case "parameter": return !parameters.has(dependency);
|
|
2567
2585
|
case "response": return !responses.has(dependency);
|
|
2568
|
-
case "schema":
|
|
2586
|
+
case "schema":
|
|
2587
|
+
if (schemas.has(dependency)) return false;
|
|
2588
|
+
if (filters.schemas.exclude.has(dependency)) return true;
|
|
2589
|
+
schemas.add(dependency);
|
|
2590
|
+
return false;
|
|
2569
2591
|
default: return false;
|
|
2570
2592
|
}
|
|
2571
2593
|
})) continue;
|
|
2572
2594
|
finalSet.add(key);
|
|
2573
2595
|
}
|
|
2574
2596
|
return { operations: finalSet };
|
|
2575
|
-
}
|
|
2597
|
+
}
|
|
2576
2598
|
/**
|
|
2577
2599
|
* Collect parameters that satisfy the include/exclude filters and schema dependencies.
|
|
2578
2600
|
*/
|
|
2579
|
-
|
|
2601
|
+
function collectParameters({ filters, resourceMetadata, schemas }) {
|
|
2580
2602
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2581
2603
|
const stack = [...filters.parameters.include.size ? filters.parameters.include : new Set(resourceMetadata.parameters.keys())];
|
|
2582
2604
|
while (stack.length) {
|
|
@@ -2602,11 +2624,11 @@ const collectParameters = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2602
2624
|
}
|
|
2603
2625
|
}
|
|
2604
2626
|
return { parameters: finalSet };
|
|
2605
|
-
}
|
|
2627
|
+
}
|
|
2606
2628
|
/**
|
|
2607
2629
|
* Collect request bodies that satisfy the include/exclude filters and schema dependencies.
|
|
2608
2630
|
*/
|
|
2609
|
-
|
|
2631
|
+
function collectRequestBodies({ filters, resourceMetadata, schemas }) {
|
|
2610
2632
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2611
2633
|
const stack = [...filters.requestBodies.include.size ? filters.requestBodies.include : new Set(resourceMetadata.requestBodies.keys())];
|
|
2612
2634
|
while (stack.length) {
|
|
@@ -2632,11 +2654,11 @@ const collectRequestBodies = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2632
2654
|
}
|
|
2633
2655
|
}
|
|
2634
2656
|
return { requestBodies: finalSet };
|
|
2635
|
-
}
|
|
2657
|
+
}
|
|
2636
2658
|
/**
|
|
2637
2659
|
* Collect responses that satisfy the include/exclude filters and schema dependencies.
|
|
2638
2660
|
*/
|
|
2639
|
-
|
|
2661
|
+
function collectResponses({ filters, resourceMetadata, schemas }) {
|
|
2640
2662
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2641
2663
|
const stack = [...filters.responses.include.size ? filters.responses.include : new Set(resourceMetadata.responses.keys())];
|
|
2642
2664
|
while (stack.length) {
|
|
@@ -2662,11 +2684,11 @@ const collectResponses = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2662
2684
|
}
|
|
2663
2685
|
}
|
|
2664
2686
|
return { responses: finalSet };
|
|
2665
|
-
}
|
|
2687
|
+
}
|
|
2666
2688
|
/**
|
|
2667
2689
|
* Collect schemas that satisfy the include/exclude filters.
|
|
2668
2690
|
*/
|
|
2669
|
-
|
|
2691
|
+
function collectSchemas({ filters, resourceMetadata }) {
|
|
2670
2692
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2671
2693
|
const stack = [...filters.schemas.include.size ? filters.schemas.include : new Set(resourceMetadata.schemas.keys())];
|
|
2672
2694
|
while (stack.length) {
|
|
@@ -2687,11 +2709,11 @@ const collectSchemas = ({ filters, resourceMetadata }) => {
|
|
|
2687
2709
|
}
|
|
2688
2710
|
}
|
|
2689
2711
|
return { schemas: finalSet };
|
|
2690
|
-
}
|
|
2712
|
+
}
|
|
2691
2713
|
/**
|
|
2692
2714
|
* Drop parameters that depend on already excluded parameters.
|
|
2693
2715
|
*/
|
|
2694
|
-
|
|
2716
|
+
function dropExcludedParameters({ filters, parameters, resourceMetadata }) {
|
|
2695
2717
|
if (!filters.parameters.exclude.size) return;
|
|
2696
2718
|
for (const key of parameters) {
|
|
2697
2719
|
const node = resourceMetadata.parameters.get(key);
|
|
@@ -2701,11 +2723,11 @@ const dropExcludedParameters = ({ filters, parameters, resourceMetadata }) => {
|
|
|
2701
2723
|
break;
|
|
2702
2724
|
}
|
|
2703
2725
|
}
|
|
2704
|
-
}
|
|
2726
|
+
}
|
|
2705
2727
|
/**
|
|
2706
2728
|
* Drop request bodies that depend on already excluded request bodies.
|
|
2707
2729
|
*/
|
|
2708
|
-
|
|
2730
|
+
function dropExcludedRequestBodies({ filters, requestBodies, resourceMetadata }) {
|
|
2709
2731
|
if (!filters.requestBodies.exclude.size) return;
|
|
2710
2732
|
for (const key of requestBodies) {
|
|
2711
2733
|
const node = resourceMetadata.requestBodies.get(key);
|
|
@@ -2715,11 +2737,11 @@ const dropExcludedRequestBodies = ({ filters, requestBodies, resourceMetadata })
|
|
|
2715
2737
|
break;
|
|
2716
2738
|
}
|
|
2717
2739
|
}
|
|
2718
|
-
}
|
|
2740
|
+
}
|
|
2719
2741
|
/**
|
|
2720
2742
|
* Drop responses that depend on already excluded responses.
|
|
2721
2743
|
*/
|
|
2722
|
-
|
|
2744
|
+
function dropExcludedResponses({ filters, resourceMetadata, responses }) {
|
|
2723
2745
|
if (!filters.responses.exclude.size) return;
|
|
2724
2746
|
for (const key of responses) {
|
|
2725
2747
|
const node = resourceMetadata.responses.get(key);
|
|
@@ -2729,11 +2751,11 @@ const dropExcludedResponses = ({ filters, resourceMetadata, responses }) => {
|
|
|
2729
2751
|
break;
|
|
2730
2752
|
}
|
|
2731
2753
|
}
|
|
2732
|
-
}
|
|
2754
|
+
}
|
|
2733
2755
|
/**
|
|
2734
2756
|
* Drop schemas that depend on already excluded schemas.
|
|
2735
2757
|
*/
|
|
2736
|
-
|
|
2758
|
+
function dropExcludedSchemas({ filters, resourceMetadata, schemas }) {
|
|
2737
2759
|
if (!filters.schemas.exclude.size) return;
|
|
2738
2760
|
for (const key of schemas) {
|
|
2739
2761
|
const node = resourceMetadata.schemas.get(key);
|
|
@@ -2743,33 +2765,56 @@ const dropExcludedSchemas = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2743
2765
|
break;
|
|
2744
2766
|
}
|
|
2745
2767
|
}
|
|
2746
|
-
}
|
|
2747
|
-
|
|
2748
|
-
for (const key of schemas) if (!operationDependencies.has(key)) schemas.delete(key);
|
|
2749
|
-
for (const key of parameters) if (!operationDependencies.has(key)) parameters.delete(key);
|
|
2750
|
-
for (const key of requestBodies) if (!operationDependencies.has(key)) requestBodies.delete(key);
|
|
2751
|
-
for (const key of responses) if (!operationDependencies.has(key)) responses.delete(key);
|
|
2752
|
-
}
|
|
2753
|
-
|
|
2768
|
+
}
|
|
2769
|
+
function dropOrphans({ includedDependencies, operationDependencies, parameters, requestBodies, responses, schemas }) {
|
|
2770
|
+
for (const key of schemas) if (!operationDependencies.has(key) && !includedDependencies.has(key)) schemas.delete(key);
|
|
2771
|
+
for (const key of parameters) if (!operationDependencies.has(key) && !includedDependencies.has(key)) parameters.delete(key);
|
|
2772
|
+
for (const key of requestBodies) if (!operationDependencies.has(key) && !includedDependencies.has(key)) requestBodies.delete(key);
|
|
2773
|
+
for (const key of responses) if (!operationDependencies.has(key) && !includedDependencies.has(key)) responses.delete(key);
|
|
2774
|
+
}
|
|
2775
|
+
function collectDependencies({ resourceMetadata, seeds }) {
|
|
2754
2776
|
const finalSet = /* @__PURE__ */ new Set();
|
|
2755
|
-
const stack = [...
|
|
2777
|
+
const stack = [...seeds];
|
|
2756
2778
|
while (stack.length) {
|
|
2757
2779
|
const key = stack.pop();
|
|
2758
2780
|
if (finalSet.has(key)) continue;
|
|
2759
2781
|
finalSet.add(key);
|
|
2782
|
+
const dependencies = getResourceDependencies(key, resourceMetadata);
|
|
2783
|
+
if (!dependencies?.size) continue;
|
|
2784
|
+
for (const dependency of dependencies) if (!finalSet.has(dependency)) stack.push(dependency);
|
|
2785
|
+
}
|
|
2786
|
+
return { dependencies: finalSet };
|
|
2787
|
+
}
|
|
2788
|
+
function collectExplicitDependencies({ filters, resourceMetadata }) {
|
|
2789
|
+
const seeds = /* @__PURE__ */ new Set();
|
|
2790
|
+
for (const key of filters.parameters.include) if (!filters.parameters.exclude.has(key)) seeds.add(key);
|
|
2791
|
+
for (const key of filters.requestBodies.include) if (!filters.requestBodies.exclude.has(key)) seeds.add(key);
|
|
2792
|
+
for (const key of filters.responses.include) if (!filters.responses.exclude.has(key)) seeds.add(key);
|
|
2793
|
+
for (const key of filters.schemas.include) if (!filters.schemas.exclude.has(key)) seeds.add(key);
|
|
2794
|
+
const { dependencies } = collectDependencies({
|
|
2795
|
+
resourceMetadata,
|
|
2796
|
+
seeds
|
|
2797
|
+
});
|
|
2798
|
+
for (const key of dependencies) {
|
|
2760
2799
|
const { namespace } = removeNamespace(key);
|
|
2761
|
-
|
|
2762
|
-
|
|
2763
|
-
|
|
2764
|
-
|
|
2765
|
-
|
|
2766
|
-
|
|
2800
|
+
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);
|
|
2801
|
+
}
|
|
2802
|
+
return { explicitDependencies: dependencies };
|
|
2803
|
+
}
|
|
2804
|
+
function collectOperationDependencies({ operations, resourceMetadata }) {
|
|
2805
|
+
const finalSet = /* @__PURE__ */ new Set();
|
|
2806
|
+
const stack = [...new Set([...operations].flatMap((key) => [...resourceMetadata.operations.get(key)?.dependencies ?? []]))];
|
|
2807
|
+
while (stack.length) {
|
|
2808
|
+
const key = stack.pop();
|
|
2809
|
+
if (finalSet.has(key)) continue;
|
|
2810
|
+
finalSet.add(key);
|
|
2811
|
+
const dependencies = getResourceDependencies(key, resourceMetadata);
|
|
2767
2812
|
if (!dependencies?.size) continue;
|
|
2768
2813
|
for (const dependency of dependencies) if (!finalSet.has(dependency)) stack.push(dependency);
|
|
2769
2814
|
}
|
|
2770
2815
|
return { operationDependencies: finalSet };
|
|
2771
|
-
}
|
|
2772
|
-
|
|
2816
|
+
}
|
|
2817
|
+
function createFilteredDependencies({ filters, logger, resourceMetadata }) {
|
|
2773
2818
|
const eventCreateFilteredDependencies = logger.timeEvent("create-filtered-dependencies");
|
|
2774
2819
|
const { schemas } = collectSchemas({
|
|
2775
2820
|
filters,
|
|
@@ -2823,7 +2868,12 @@ const createFilteredDependencies = ({ filters, logger, resourceMetadata }) => {
|
|
|
2823
2868
|
operations,
|
|
2824
2869
|
resourceMetadata
|
|
2825
2870
|
});
|
|
2871
|
+
const { explicitDependencies } = collectExplicitDependencies({
|
|
2872
|
+
filters,
|
|
2873
|
+
resourceMetadata
|
|
2874
|
+
});
|
|
2826
2875
|
dropOrphans({
|
|
2876
|
+
includedDependencies: explicitDependencies,
|
|
2827
2877
|
operationDependencies,
|
|
2828
2878
|
parameters,
|
|
2829
2879
|
requestBodies,
|
|
@@ -2839,8 +2889,7 @@ const createFilteredDependencies = ({ filters, logger, resourceMetadata }) => {
|
|
|
2839
2889
|
responses,
|
|
2840
2890
|
schemas
|
|
2841
2891
|
};
|
|
2842
|
-
}
|
|
2843
|
-
|
|
2892
|
+
}
|
|
2844
2893
|
//#endregion
|
|
2845
2894
|
//#region src/openApi/shared/graph/meta.ts
|
|
2846
2895
|
/**
|
|
@@ -2932,11 +2981,9 @@ const buildResourceMetadata = (graph, logger) => {
|
|
|
2932
2981
|
eventBuildResourceMetadata.timeEnd();
|
|
2933
2982
|
return { resourceMetadata };
|
|
2934
2983
|
};
|
|
2935
|
-
|
|
2936
2984
|
//#endregion
|
|
2937
2985
|
//#region src/openApi/shared/utils/schema.ts
|
|
2938
2986
|
const deepClone = (obj) => JSON.parse(JSON.stringify(obj));
|
|
2939
|
-
|
|
2940
2987
|
//#endregion
|
|
2941
2988
|
//#region src/openApi/shared/utils/schemaChildRelationships.ts
|
|
2942
2989
|
const childSchemaRelationships = [
|
|
@@ -2955,7 +3002,6 @@ const childSchemaRelationships = [
|
|
|
2955
3002
|
["then", "single"],
|
|
2956
3003
|
["unevaluatedProperties", "single"]
|
|
2957
3004
|
];
|
|
2958
|
-
|
|
2959
3005
|
//#endregion
|
|
2960
3006
|
//#region src/openApi/shared/utils/transforms.ts
|
|
2961
3007
|
const getSchemasObject = (spec) => {
|
|
@@ -2972,7 +3018,6 @@ const hasComponentsSchemasObject = (spec) => typeof spec === "object" && spec !=
|
|
|
2972
3018
|
* Returns true if present, false otherwise.
|
|
2973
3019
|
*/
|
|
2974
3020
|
const hasDefinitionsObject = (spec) => typeof spec === "object" && spec !== null && "definitions" in spec && typeof spec.definitions === "object" && spec.definitions !== null;
|
|
2975
|
-
|
|
2976
3021
|
//#endregion
|
|
2977
3022
|
//#region src/openApi/shared/transforms/utils.ts
|
|
2978
3023
|
const hasName = (obj, value) => {
|
|
@@ -2997,7 +3042,6 @@ const specToSchemasPointerNamespace = (spec) => {
|
|
|
2997
3042
|
}
|
|
2998
3043
|
return "";
|
|
2999
3044
|
};
|
|
3000
|
-
|
|
3001
3045
|
//#endregion
|
|
3002
3046
|
//#region src/openApi/shared/transforms/enums.ts
|
|
3003
3047
|
/**
|
|
@@ -3161,7 +3205,6 @@ const enumsTransform = ({ config, spec }) => {
|
|
|
3161
3205
|
return;
|
|
3162
3206
|
}
|
|
3163
3207
|
};
|
|
3164
|
-
|
|
3165
3208
|
//#endregion
|
|
3166
3209
|
//#region src/openApi/shared/transforms/propertiesRequiredByDefault.ts
|
|
3167
3210
|
/**
|
|
@@ -3221,7 +3264,6 @@ const propertiesRequiredByDefaultTransform = ({ spec }) => {
|
|
|
3221
3264
|
}
|
|
3222
3265
|
});
|
|
3223
3266
|
};
|
|
3224
|
-
|
|
3225
3267
|
//#endregion
|
|
3226
3268
|
//#region src/openApi/shared/utils/deepEqual.ts
|
|
3227
3269
|
/**
|
|
@@ -3249,7 +3291,6 @@ const deepEqual = (a, b) => {
|
|
|
3249
3291
|
for (const key of keysA) if (!deepEqual(objA[key], objB[key])) return false;
|
|
3250
3292
|
return true;
|
|
3251
3293
|
};
|
|
3252
|
-
|
|
3253
3294
|
//#endregion
|
|
3254
3295
|
//#region src/openApi/shared/utils/graph.ts
|
|
3255
3296
|
/**
|
|
@@ -3543,7 +3584,6 @@ function buildGraph(root, logger) {
|
|
|
3543
3584
|
eventBuildGraph.timeEnd();
|
|
3544
3585
|
return { graph };
|
|
3545
3586
|
}
|
|
3546
|
-
|
|
3547
3587
|
//#endregion
|
|
3548
3588
|
//#region src/openApi/shared/transforms/readWrite.ts
|
|
3549
3589
|
const schemaKeys = new Set([
|
|
@@ -4072,7 +4112,6 @@ const readWriteTransform = ({ config, logger, spec }) => {
|
|
|
4072
4112
|
split
|
|
4073
4113
|
});
|
|
4074
4114
|
};
|
|
4075
|
-
|
|
4076
4115
|
//#endregion
|
|
4077
4116
|
//#region src/openApi/shared/transforms/schemas.ts
|
|
4078
4117
|
/**
|
|
@@ -4113,7 +4152,6 @@ const schemaNameTransform = ({ config, spec }) => {
|
|
|
4113
4152
|
}
|
|
4114
4153
|
if (Object.keys(renameMap).length) rewriteRefs(spec, renameMap);
|
|
4115
4154
|
};
|
|
4116
|
-
|
|
4117
4155
|
//#endregion
|
|
4118
4156
|
//#region src/openApi/shared/transforms/index.ts
|
|
4119
4157
|
const transformOpenApiSpec = ({ context }) => {
|
|
@@ -4135,7 +4173,6 @@ const transformOpenApiSpec = ({ context }) => {
|
|
|
4135
4173
|
});
|
|
4136
4174
|
eventTransformOpenApiSpec.timeEnd();
|
|
4137
4175
|
};
|
|
4138
|
-
|
|
4139
4176
|
//#endregion
|
|
4140
4177
|
//#region src/openApi/shared/utils/parameter.ts
|
|
4141
4178
|
const mergeParametersObjects = ({ source, target }) => {
|
|
@@ -4165,7 +4202,6 @@ const mergeParametersObjects = ({ source, target }) => {
|
|
|
4165
4202
|
if (!Object.keys(result).length) return;
|
|
4166
4203
|
return result;
|
|
4167
4204
|
};
|
|
4168
|
-
|
|
4169
4205
|
//#endregion
|
|
4170
4206
|
//#region src/openApi/shared/utils/validator.ts
|
|
4171
4207
|
const isSimpleKey = (key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
|
|
@@ -4192,7 +4228,6 @@ const handleValidatorResult = ({ context, result }) => {
|
|
|
4192
4228
|
})) console.log(formatValidatorIssue(issue));
|
|
4193
4229
|
if (!result.valid) process.exit(1);
|
|
4194
4230
|
};
|
|
4195
|
-
|
|
4196
4231
|
//#endregion
|
|
4197
4232
|
//#region src/openApi/2.0.x/parser/filter.ts
|
|
4198
4233
|
/**
|
|
@@ -4226,7 +4261,6 @@ const filterSpec$2 = ({ logger, operations, preserveOrder, schemas, spec }) => {
|
|
|
4226
4261
|
}
|
|
4227
4262
|
eventFilterSpec.timeEnd();
|
|
4228
4263
|
};
|
|
4229
|
-
|
|
4230
4264
|
//#endregion
|
|
4231
4265
|
//#region src/ir/mediaType.ts
|
|
4232
4266
|
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;
|
|
@@ -4251,7 +4285,6 @@ const mediaTypeToIrMediaType = ({ mediaType }) => {
|
|
|
4251
4285
|
octetStreamMimeRegExp.lastIndex = 0;
|
|
4252
4286
|
if (octetStreamMimeRegExp.test(mediaType)) return "octet-stream";
|
|
4253
4287
|
};
|
|
4254
|
-
|
|
4255
4288
|
//#endregion
|
|
4256
4289
|
//#region src/openApi/2.0.x/parser/mediaType.ts
|
|
4257
4290
|
const contentToSchema$2 = ({ content }) => {
|
|
@@ -4279,14 +4312,12 @@ const mediaTypeObjects$2 = ({ mimeTypes, response }) => {
|
|
|
4279
4312
|
});
|
|
4280
4313
|
return objects;
|
|
4281
4314
|
};
|
|
4282
|
-
|
|
4283
4315
|
//#endregion
|
|
4284
4316
|
//#region src/ir/pagination.ts
|
|
4285
4317
|
function getPaginationKeywordsRegExp(pagination) {
|
|
4286
4318
|
const pattern = `^(${pagination.keywords.join("|")})$`;
|
|
4287
4319
|
return new RegExp(pattern);
|
|
4288
4320
|
}
|
|
4289
|
-
|
|
4290
4321
|
//#endregion
|
|
4291
4322
|
//#region src/openApi/shared/utils/discriminator.ts
|
|
4292
4323
|
/**
|
|
@@ -4353,19 +4384,18 @@ const discriminatorValues = ($ref, mapping, shouldUseRefAsValue) => {
|
|
|
4353
4384
|
if (!values.length && (!shouldUseRefAsValue || shouldUseRefAsValue())) return [refToName($ref)];
|
|
4354
4385
|
return values;
|
|
4355
4386
|
};
|
|
4356
|
-
|
|
4357
4387
|
//#endregion
|
|
4358
4388
|
//#region src/openApi/2.0.x/parser/schema.ts
|
|
4359
|
-
|
|
4389
|
+
function getSchemaType$1({ schema }) {
|
|
4360
4390
|
if (schema.type) return schema.type;
|
|
4361
4391
|
if (schema.properties) return "object";
|
|
4362
|
-
}
|
|
4363
|
-
|
|
4392
|
+
}
|
|
4393
|
+
function parseSchemaJsDoc$2({ irSchema, schema }) {
|
|
4364
4394
|
if (schema.example) irSchema.example = schema.example;
|
|
4365
4395
|
if (schema.description) irSchema.description = schema.description;
|
|
4366
4396
|
if (schema.title) irSchema.title = schema.title;
|
|
4367
|
-
}
|
|
4368
|
-
|
|
4397
|
+
}
|
|
4398
|
+
function parseSchemaMeta$2({ irSchema, schema }) {
|
|
4369
4399
|
if (schema.default !== void 0) irSchema.default = schema.default;
|
|
4370
4400
|
if (schema.exclusiveMaximum) {
|
|
4371
4401
|
if (schema.maximum !== void 0) irSchema.exclusiveMaximum = schema.maximum;
|
|
@@ -4380,8 +4410,8 @@ const parseSchemaMeta$2 = ({ irSchema, schema }) => {
|
|
|
4380
4410
|
if (schema.minLength !== void 0) irSchema.minLength = schema.minLength;
|
|
4381
4411
|
if (schema.pattern) irSchema.pattern = schema.pattern;
|
|
4382
4412
|
if (schema.readOnly) irSchema.accessScope = "read";
|
|
4383
|
-
}
|
|
4384
|
-
|
|
4413
|
+
}
|
|
4414
|
+
function parseArray$2({ context, irSchema = {}, schema, state }) {
|
|
4385
4415
|
if (schema.maxItems && schema.maxItems === schema.minItems) irSchema.type = "tuple";
|
|
4386
4416
|
else irSchema.type = "array";
|
|
4387
4417
|
let schemaItems = [];
|
|
@@ -4407,16 +4437,16 @@ const parseArray$2 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
4407
4437
|
schema: irSchema
|
|
4408
4438
|
});
|
|
4409
4439
|
return irSchema;
|
|
4410
|
-
}
|
|
4411
|
-
|
|
4440
|
+
}
|
|
4441
|
+
function parseBoolean$2({ irSchema = {} }) {
|
|
4412
4442
|
irSchema.type = "boolean";
|
|
4413
4443
|
return irSchema;
|
|
4414
|
-
}
|
|
4415
|
-
|
|
4444
|
+
}
|
|
4445
|
+
function parseNumber$2({ irSchema = {}, schema }) {
|
|
4416
4446
|
irSchema.type = schema.type;
|
|
4417
4447
|
return irSchema;
|
|
4418
|
-
}
|
|
4419
|
-
|
|
4448
|
+
}
|
|
4449
|
+
function parseObject$2({ context, irSchema = {}, schema, state }) {
|
|
4420
4450
|
irSchema.type = "object";
|
|
4421
4451
|
const schemaProperties = {};
|
|
4422
4452
|
for (const name in schema.properties) {
|
|
@@ -4439,15 +4469,15 @@ const parseObject$2 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
4439
4469
|
});
|
|
4440
4470
|
if (schema.required) irSchema.required = schema.required;
|
|
4441
4471
|
return irSchema;
|
|
4442
|
-
}
|
|
4443
|
-
|
|
4472
|
+
}
|
|
4473
|
+
function parseString$2({ irSchema = {} }) {
|
|
4444
4474
|
irSchema.type = "string";
|
|
4445
4475
|
return irSchema;
|
|
4446
|
-
}
|
|
4447
|
-
|
|
4476
|
+
}
|
|
4477
|
+
function parseExtensions$2({ source, target }) {
|
|
4448
4478
|
for (const key in source) if (key.startsWith("x-")) target[key] = source[key];
|
|
4449
|
-
}
|
|
4450
|
-
|
|
4479
|
+
}
|
|
4480
|
+
function initIrSchema$2({ schema }) {
|
|
4451
4481
|
const irSchema = {};
|
|
4452
4482
|
parseSchemaJsDoc$2({
|
|
4453
4483
|
irSchema,
|
|
@@ -4458,8 +4488,8 @@ const initIrSchema$2 = ({ schema }) => {
|
|
|
4458
4488
|
target: irSchema
|
|
4459
4489
|
});
|
|
4460
4490
|
return irSchema;
|
|
4461
|
-
}
|
|
4462
|
-
|
|
4491
|
+
}
|
|
4492
|
+
function parseAllOf$2({ context, schema, state }) {
|
|
4463
4493
|
let irSchema = initIrSchema$2({ schema });
|
|
4464
4494
|
const schemaItems = [];
|
|
4465
4495
|
const schemaType = getSchemaType$1({ schema });
|
|
@@ -4543,9 +4573,13 @@ const parseAllOf$2 = ({ context, schema, state }) => {
|
|
|
4543
4573
|
if (nestedItems[0].description) irSchema.description = nestedItems[0].description;
|
|
4544
4574
|
}
|
|
4545
4575
|
return irSchema;
|
|
4546
|
-
}
|
|
4547
|
-
|
|
4576
|
+
}
|
|
4577
|
+
function parseEnum$2({ context, schema, state }) {
|
|
4548
4578
|
let irSchema = initIrSchema$2({ schema });
|
|
4579
|
+
parseSchemaMeta$2({
|
|
4580
|
+
irSchema,
|
|
4581
|
+
schema
|
|
4582
|
+
});
|
|
4549
4583
|
irSchema.type = "enum";
|
|
4550
4584
|
const schemaItems = [];
|
|
4551
4585
|
for (const [index, enumValue] of schema.enum.entries()) {
|
|
@@ -4576,8 +4610,8 @@ const parseEnum$2 = ({ context, schema, state }) => {
|
|
|
4576
4610
|
schema: irSchema
|
|
4577
4611
|
});
|
|
4578
4612
|
return irSchema;
|
|
4579
|
-
}
|
|
4580
|
-
|
|
4613
|
+
}
|
|
4614
|
+
function parseRef$2({ context, schema, state }) {
|
|
4581
4615
|
const irSchema = {};
|
|
4582
4616
|
if (!isTopLevelComponent(schema.$ref)) {
|
|
4583
4617
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
@@ -4593,7 +4627,7 @@ const parseRef$2 = ({ context, schema, state }) => {
|
|
|
4593
4627
|
return irSchema;
|
|
4594
4628
|
}
|
|
4595
4629
|
}
|
|
4596
|
-
irSchema.$ref =
|
|
4630
|
+
irSchema.$ref = schema.$ref;
|
|
4597
4631
|
irSchema.$ref = irSchema.$ref.replace(/#\/definitions\/([^/]+)/g, "#/components/schemas/$1");
|
|
4598
4632
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
4599
4633
|
const refSchema = context.resolveRef(schema.$ref);
|
|
@@ -4607,8 +4641,8 @@ const parseRef$2 = ({ context, schema, state }) => {
|
|
|
4607
4641
|
state.$ref = originalRef;
|
|
4608
4642
|
}
|
|
4609
4643
|
return irSchema;
|
|
4610
|
-
}
|
|
4611
|
-
|
|
4644
|
+
}
|
|
4645
|
+
function parseNullableType$1({ context, irSchema, schema, state }) {
|
|
4612
4646
|
if (!irSchema) irSchema = initIrSchema$2({ schema });
|
|
4613
4647
|
const typeIrSchema = {};
|
|
4614
4648
|
parseSchemaMeta$2({
|
|
@@ -4626,8 +4660,8 @@ const parseNullableType$1 = ({ context, irSchema, schema, state }) => {
|
|
|
4626
4660
|
schema: irSchema
|
|
4627
4661
|
});
|
|
4628
4662
|
return irSchema;
|
|
4629
|
-
}
|
|
4630
|
-
|
|
4663
|
+
}
|
|
4664
|
+
function parseType$2({ context, schema, state }) {
|
|
4631
4665
|
const irSchema = initIrSchema$2({ schema });
|
|
4632
4666
|
parseSchemaMeta$2({
|
|
4633
4667
|
irSchema,
|
|
@@ -4653,8 +4687,8 @@ const parseType$2 = ({ context, schema, state }) => {
|
|
|
4653
4687
|
},
|
|
4654
4688
|
state
|
|
4655
4689
|
});
|
|
4656
|
-
}
|
|
4657
|
-
|
|
4690
|
+
}
|
|
4691
|
+
function parseOneType$2({ context, irSchema, schema, state }) {
|
|
4658
4692
|
if (!irSchema) {
|
|
4659
4693
|
irSchema = initIrSchema$2({ schema });
|
|
4660
4694
|
parseSchemaMeta$2({
|
|
@@ -4700,8 +4734,8 @@ const parseOneType$2 = ({ context, irSchema, schema, state }) => {
|
|
|
4700
4734
|
schema
|
|
4701
4735
|
});
|
|
4702
4736
|
}
|
|
4703
|
-
}
|
|
4704
|
-
|
|
4737
|
+
}
|
|
4738
|
+
function parseUnknown$2({ irSchema, schema }) {
|
|
4705
4739
|
if (!irSchema) irSchema = initIrSchema$2({ schema });
|
|
4706
4740
|
irSchema.type = "unknown";
|
|
4707
4741
|
parseSchemaMeta$2({
|
|
@@ -4709,8 +4743,8 @@ const parseUnknown$2 = ({ irSchema, schema }) => {
|
|
|
4709
4743
|
schema
|
|
4710
4744
|
});
|
|
4711
4745
|
return irSchema;
|
|
4712
|
-
}
|
|
4713
|
-
|
|
4746
|
+
}
|
|
4747
|
+
function schemaToIrSchema$2({ context, schema, state }) {
|
|
4714
4748
|
if (!state) state = { circularReferenceTracker: /* @__PURE__ */ new Set() };
|
|
4715
4749
|
if (state.$ref) state.circularReferenceTracker.add(state.$ref);
|
|
4716
4750
|
if (schema.$ref) return parseRef$2({
|
|
@@ -4737,8 +4771,8 @@ const schemaToIrSchema$2 = ({ context, schema, state }) => {
|
|
|
4737
4771
|
context,
|
|
4738
4772
|
schema
|
|
4739
4773
|
});
|
|
4740
|
-
}
|
|
4741
|
-
|
|
4774
|
+
}
|
|
4775
|
+
function parseSchema$2({ $ref, context, schema }) {
|
|
4742
4776
|
if (!context.ir.components) context.ir.components = {};
|
|
4743
4777
|
if (!context.ir.components.schemas) context.ir.components.schemas = {};
|
|
4744
4778
|
context.ir.components.schemas[refToName($ref)] = schemaToIrSchema$2({
|
|
@@ -4749,8 +4783,7 @@ const parseSchema$2 = ({ $ref, context, schema }) => {
|
|
|
4749
4783
|
circularReferenceTracker: /* @__PURE__ */ new Set()
|
|
4750
4784
|
}
|
|
4751
4785
|
});
|
|
4752
|
-
}
|
|
4753
|
-
|
|
4786
|
+
}
|
|
4754
4787
|
//#endregion
|
|
4755
4788
|
//#region src/openApi/2.0.x/parser/pagination.ts
|
|
4756
4789
|
const isPaginationType$2 = (schemaType) => schemaType === "boolean" || schemaType === "integer" || schemaType === "number" || schemaType === "string";
|
|
@@ -4799,7 +4832,6 @@ const paginationField$2 = ({ context, name, schema }) => {
|
|
|
4799
4832
|
}
|
|
4800
4833
|
return false;
|
|
4801
4834
|
};
|
|
4802
|
-
|
|
4803
4835
|
//#endregion
|
|
4804
4836
|
//#region src/openApi/2.0.x/parser/operation.ts
|
|
4805
4837
|
const parseOperationJsDoc$2 = ({ irOperation, operation }) => {
|
|
@@ -5005,7 +5037,6 @@ const parsePathOperation$2 = ({ context, method, operation, path, securityScheme
|
|
|
5005
5037
|
state
|
|
5006
5038
|
});
|
|
5007
5039
|
};
|
|
5008
|
-
|
|
5009
5040
|
//#endregion
|
|
5010
5041
|
//#region src/openApi/2.0.x/parser/parameter.ts
|
|
5011
5042
|
/**
|
|
@@ -5092,7 +5123,6 @@ const parameterToIrParameter$2 = ({ $ref, context, parameter }) => {
|
|
|
5092
5123
|
});
|
|
5093
5124
|
return irParameter;
|
|
5094
5125
|
};
|
|
5095
|
-
|
|
5096
5126
|
//#endregion
|
|
5097
5127
|
//#region src/utils/url.ts
|
|
5098
5128
|
const parseUrlRegExp = /^(([^:/?#]+):)?((\/\/)?([^:/?#]*)(:?([^/?#]*)))?([^?#]*)(\?([^#]*))?(#(.*))?/;
|
|
@@ -5118,7 +5148,6 @@ function parseUrl(value) {
|
|
|
5118
5148
|
protocol
|
|
5119
5149
|
};
|
|
5120
5150
|
}
|
|
5121
|
-
|
|
5122
5151
|
//#endregion
|
|
5123
5152
|
//#region src/openApi/2.0.x/parser/server.ts
|
|
5124
5153
|
const parseServers$2 = ({ context }) => {
|
|
@@ -5136,7 +5165,6 @@ const parseServers$2 = ({ context }) => {
|
|
|
5136
5165
|
const servers = schemes.map((scheme) => `${scheme ? `${scheme}://` : ""}${host}${path}`).filter(Boolean);
|
|
5137
5166
|
if (servers.length) context.ir.servers = servers.map((url) => ({ url }));
|
|
5138
5167
|
};
|
|
5139
|
-
|
|
5140
5168
|
//#endregion
|
|
5141
5169
|
//#region src/openApi/2.0.x/parser/validate.ts
|
|
5142
5170
|
const validateOpenApiSpec$2 = (spec, logger) => {
|
|
@@ -5178,7 +5206,6 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5178
5206
|
valid: !issues.some((issue) => issue.severity === "error")
|
|
5179
5207
|
};
|
|
5180
5208
|
};
|
|
5181
|
-
|
|
5182
5209
|
//#endregion
|
|
5183
5210
|
//#region src/openApi/2.0.x/parser/index.ts
|
|
5184
5211
|
const parseV2_0_X = (context) => {
|
|
@@ -5380,7 +5407,6 @@ const parseV2_0_X = (context) => {
|
|
|
5380
5407
|
}
|
|
5381
5408
|
}
|
|
5382
5409
|
};
|
|
5383
|
-
|
|
5384
5410
|
//#endregion
|
|
5385
5411
|
//#region src/openApi/3.0.x/parser/filter.ts
|
|
5386
5412
|
/**
|
|
@@ -5449,7 +5475,6 @@ const filterSpec$1 = ({ logger, operations, parameters, preserveOrder, requestBo
|
|
|
5449
5475
|
}
|
|
5450
5476
|
eventFilterSpec.timeEnd();
|
|
5451
5477
|
};
|
|
5452
|
-
|
|
5453
5478
|
//#endregion
|
|
5454
5479
|
//#region src/openApi/3.0.x/parser/mediaType.ts
|
|
5455
5480
|
const contentToSchema$1 = ({ content }) => {
|
|
@@ -5477,18 +5502,17 @@ const mediaTypeObjects$1 = ({ content }) => {
|
|
|
5477
5502
|
});
|
|
5478
5503
|
return objects;
|
|
5479
5504
|
};
|
|
5480
|
-
|
|
5481
5505
|
//#endregion
|
|
5482
5506
|
//#region src/openApi/3.0.x/parser/schema.ts
|
|
5483
|
-
|
|
5507
|
+
function getSchemaType({ schema }) {
|
|
5484
5508
|
if (schema.type) return schema.type;
|
|
5485
5509
|
if (schema.properties) return "object";
|
|
5486
|
-
}
|
|
5510
|
+
}
|
|
5487
5511
|
/**
|
|
5488
5512
|
* Finds the type of a discriminator property by looking it up in the provided schemas.
|
|
5489
5513
|
* Searches through properties and allOf chains to find the property definition.
|
|
5490
5514
|
*/
|
|
5491
|
-
|
|
5515
|
+
function findDiscriminatorPropertyType$1({ context, propertyName, schemas }) {
|
|
5492
5516
|
for (const schema of schemas) {
|
|
5493
5517
|
const resolved = "$ref" in schema ? context.resolveRef(schema.$ref) : schema;
|
|
5494
5518
|
const property = resolved.properties?.[propertyName];
|
|
@@ -5506,13 +5530,13 @@ const findDiscriminatorPropertyType$1 = ({ context, propertyName, schemas }) =>
|
|
|
5506
5530
|
}
|
|
5507
5531
|
}
|
|
5508
5532
|
return "string";
|
|
5509
|
-
}
|
|
5533
|
+
}
|
|
5510
5534
|
/**
|
|
5511
5535
|
* Recursively finds discriminators in a schema, including nested allOf compositions.
|
|
5512
5536
|
* This is needed when a schema extends another schema via allOf, and that parent
|
|
5513
5537
|
* schema is itself an allOf composition with discriminators in inline schemas.
|
|
5514
5538
|
*/
|
|
5515
|
-
|
|
5539
|
+
function findDiscriminatorsInSchema$1({ context, discriminators = [], schema }) {
|
|
5516
5540
|
if (schema.discriminator) discriminators.push({
|
|
5517
5541
|
discriminator: schema.discriminator,
|
|
5518
5542
|
oneOf: schema.oneOf
|
|
@@ -5528,23 +5552,23 @@ const findDiscriminatorsInSchema$1 = ({ context, discriminators = [], schema })
|
|
|
5528
5552
|
});
|
|
5529
5553
|
}
|
|
5530
5554
|
return discriminators;
|
|
5531
|
-
}
|
|
5555
|
+
}
|
|
5532
5556
|
/**
|
|
5533
5557
|
* Gets the discriminator value for a schema.
|
|
5534
5558
|
* Returns only the schema's own discriminator value, not child values.
|
|
5535
5559
|
*/
|
|
5536
|
-
|
|
5560
|
+
function getAllDiscriminatorValues$1({ discriminator, schemaRef }) {
|
|
5537
5561
|
const values = [];
|
|
5538
5562
|
for (const [value, mappedSchemaRef] of Object.entries(discriminator.mapping || {})) if (mappedSchemaRef === schemaRef) values.push(value);
|
|
5539
5563
|
return values;
|
|
5540
|
-
}
|
|
5541
|
-
|
|
5564
|
+
}
|
|
5565
|
+
function parseSchemaJsDoc$1({ irSchema, schema }) {
|
|
5542
5566
|
if (schema.deprecated !== void 0) irSchema.deprecated = schema.deprecated;
|
|
5543
5567
|
if (schema.example) irSchema.example = schema.example;
|
|
5544
5568
|
if (schema.description) irSchema.description = schema.description;
|
|
5545
5569
|
if (schema.title) irSchema.title = schema.title;
|
|
5546
|
-
}
|
|
5547
|
-
|
|
5570
|
+
}
|
|
5571
|
+
function parseSchemaMeta$1({ irSchema, schema }) {
|
|
5548
5572
|
if (schema.default !== void 0) irSchema.default = schema.default;
|
|
5549
5573
|
if (schema.exclusiveMaximum) {
|
|
5550
5574
|
if (schema.maximum !== void 0) irSchema.exclusiveMaximum = schema.maximum;
|
|
@@ -5560,8 +5584,8 @@ const parseSchemaMeta$1 = ({ irSchema, schema }) => {
|
|
|
5560
5584
|
if (schema.pattern) irSchema.pattern = schema.pattern;
|
|
5561
5585
|
if (schema.readOnly) irSchema.accessScope = "read";
|
|
5562
5586
|
else if (schema.writeOnly) irSchema.accessScope = "write";
|
|
5563
|
-
}
|
|
5564
|
-
|
|
5587
|
+
}
|
|
5588
|
+
function parseArray$1({ context, irSchema = {}, schema, state }) {
|
|
5565
5589
|
if (schema.maxItems && schema.maxItems === schema.minItems) irSchema.type = "tuple";
|
|
5566
5590
|
else irSchema.type = "array";
|
|
5567
5591
|
let schemaItems = [];
|
|
@@ -5587,16 +5611,16 @@ const parseArray$1 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
5587
5611
|
schema: irSchema
|
|
5588
5612
|
});
|
|
5589
5613
|
return irSchema;
|
|
5590
|
-
}
|
|
5591
|
-
|
|
5614
|
+
}
|
|
5615
|
+
function parseBoolean$1({ irSchema = {} }) {
|
|
5592
5616
|
irSchema.type = "boolean";
|
|
5593
5617
|
return irSchema;
|
|
5594
|
-
}
|
|
5595
|
-
|
|
5618
|
+
}
|
|
5619
|
+
function parseNumber$1({ irSchema = {}, schema }) {
|
|
5596
5620
|
irSchema.type = schema.type;
|
|
5597
5621
|
return irSchema;
|
|
5598
|
-
}
|
|
5599
|
-
|
|
5622
|
+
}
|
|
5623
|
+
function parseObject$1({ context, irSchema = {}, schema, state }) {
|
|
5600
5624
|
irSchema.type = "object";
|
|
5601
5625
|
const schemaProperties = {};
|
|
5602
5626
|
for (const name in schema.properties) {
|
|
@@ -5638,15 +5662,15 @@ const parseObject$1 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
5638
5662
|
}
|
|
5639
5663
|
}
|
|
5640
5664
|
return irSchema;
|
|
5641
|
-
}
|
|
5642
|
-
|
|
5665
|
+
}
|
|
5666
|
+
function parseString$1({ irSchema = {} }) {
|
|
5643
5667
|
irSchema.type = "string";
|
|
5644
5668
|
return irSchema;
|
|
5645
|
-
}
|
|
5646
|
-
|
|
5669
|
+
}
|
|
5670
|
+
function parseExtensions$1({ source, target }) {
|
|
5647
5671
|
for (const key in source) if (key.startsWith("x-")) target[key] = source[key];
|
|
5648
|
-
}
|
|
5649
|
-
|
|
5672
|
+
}
|
|
5673
|
+
function initIrSchema$1({ schema }) {
|
|
5650
5674
|
const irSchema = {};
|
|
5651
5675
|
parseSchemaJsDoc$1({
|
|
5652
5676
|
irSchema,
|
|
@@ -5657,8 +5681,8 @@ const initIrSchema$1 = ({ schema }) => {
|
|
|
5657
5681
|
target: irSchema
|
|
5658
5682
|
});
|
|
5659
5683
|
return irSchema;
|
|
5660
|
-
}
|
|
5661
|
-
|
|
5684
|
+
}
|
|
5685
|
+
function parseAllOf$1({ context, schema, state }) {
|
|
5662
5686
|
let irSchema = initIrSchema$1({ schema });
|
|
5663
5687
|
const schemaItems = [];
|
|
5664
5688
|
const schemaType = getSchemaType({ schema });
|
|
@@ -5807,8 +5831,8 @@ const parseAllOf$1 = ({ context, schema, state }) => {
|
|
|
5807
5831
|
if (nestedItems[0].description) irSchema.description = nestedItems[0].description;
|
|
5808
5832
|
}
|
|
5809
5833
|
return irSchema;
|
|
5810
|
-
}
|
|
5811
|
-
|
|
5834
|
+
}
|
|
5835
|
+
function parseAnyOf$1({ context, schema, state }) {
|
|
5812
5836
|
let irSchema = initIrSchema$1({ schema });
|
|
5813
5837
|
const schemaItems = [];
|
|
5814
5838
|
const schemaType = getSchemaType({ schema });
|
|
@@ -5859,10 +5883,15 @@ const parseAnyOf$1 = ({ context, schema, state }) => {
|
|
|
5859
5883
|
logicalOperator: "and"
|
|
5860
5884
|
};
|
|
5861
5885
|
}
|
|
5886
|
+
if (schema.discriminator && irSchema.logicalOperator === "or") irSchema.discriminator = { propertyName: schema.discriminator.propertyName };
|
|
5862
5887
|
return irSchema;
|
|
5863
|
-
}
|
|
5864
|
-
|
|
5888
|
+
}
|
|
5889
|
+
function parseEnum$1({ context, schema, state }) {
|
|
5865
5890
|
let irSchema = initIrSchema$1({ schema });
|
|
5891
|
+
parseSchemaMeta$1({
|
|
5892
|
+
irSchema,
|
|
5893
|
+
schema
|
|
5894
|
+
});
|
|
5866
5895
|
irSchema.type = "enum";
|
|
5867
5896
|
const schemaItems = [];
|
|
5868
5897
|
for (const [index, enumValue] of schema.enum.entries()) {
|
|
@@ -5893,8 +5922,8 @@ const parseEnum$1 = ({ context, schema, state }) => {
|
|
|
5893
5922
|
schema: irSchema
|
|
5894
5923
|
});
|
|
5895
5924
|
return irSchema;
|
|
5896
|
-
}
|
|
5897
|
-
|
|
5925
|
+
}
|
|
5926
|
+
function parseOneOf$1({ context, schema, state }) {
|
|
5898
5927
|
let irSchema = initIrSchema$1({ schema });
|
|
5899
5928
|
let schemaItems = [];
|
|
5900
5929
|
const schemaType = getSchemaType({ schema });
|
|
@@ -5947,9 +5976,10 @@ const parseOneOf$1 = ({ context, schema, state }) => {
|
|
|
5947
5976
|
logicalOperator: "and"
|
|
5948
5977
|
};
|
|
5949
5978
|
}
|
|
5979
|
+
if (schema.discriminator && irSchema.logicalOperator === "or") irSchema.discriminator = { propertyName: schema.discriminator.propertyName };
|
|
5950
5980
|
return irSchema;
|
|
5951
|
-
}
|
|
5952
|
-
|
|
5981
|
+
}
|
|
5982
|
+
function parseRef$1({ context, schema, state }) {
|
|
5953
5983
|
if (!isTopLevelComponent(schema.$ref)) {
|
|
5954
5984
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
5955
5985
|
const refSchema = context.resolveRef(schema.$ref);
|
|
@@ -5965,7 +5995,7 @@ const parseRef$1 = ({ context, schema, state }) => {
|
|
|
5965
5995
|
}
|
|
5966
5996
|
}
|
|
5967
5997
|
const irSchema = {};
|
|
5968
|
-
irSchema.$ref =
|
|
5998
|
+
irSchema.$ref = schema.$ref;
|
|
5969
5999
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
5970
6000
|
const refSchema = context.resolveRef(schema.$ref);
|
|
5971
6001
|
const originalRef = state.$ref;
|
|
@@ -5978,8 +6008,8 @@ const parseRef$1 = ({ context, schema, state }) => {
|
|
|
5978
6008
|
state.$ref = originalRef;
|
|
5979
6009
|
}
|
|
5980
6010
|
return irSchema;
|
|
5981
|
-
}
|
|
5982
|
-
|
|
6011
|
+
}
|
|
6012
|
+
function parseNullableType({ context, irSchema, schema, state }) {
|
|
5983
6013
|
if (!irSchema) irSchema = initIrSchema$1({ schema });
|
|
5984
6014
|
const typeIrSchema = {};
|
|
5985
6015
|
parseSchemaMeta$1({
|
|
@@ -5997,8 +6027,8 @@ const parseNullableType = ({ context, irSchema, schema, state }) => {
|
|
|
5997
6027
|
schema: irSchema
|
|
5998
6028
|
});
|
|
5999
6029
|
return irSchema;
|
|
6000
|
-
}
|
|
6001
|
-
|
|
6030
|
+
}
|
|
6031
|
+
function parseType$1({ context, schema, state }) {
|
|
6002
6032
|
const irSchema = initIrSchema$1({ schema });
|
|
6003
6033
|
parseSchemaMeta$1({
|
|
6004
6034
|
irSchema,
|
|
@@ -6024,8 +6054,8 @@ const parseType$1 = ({ context, schema, state }) => {
|
|
|
6024
6054
|
},
|
|
6025
6055
|
state
|
|
6026
6056
|
});
|
|
6027
|
-
}
|
|
6028
|
-
|
|
6057
|
+
}
|
|
6058
|
+
function parseOneType$1({ context, irSchema, schema, state }) {
|
|
6029
6059
|
if (!irSchema) {
|
|
6030
6060
|
irSchema = initIrSchema$1({ schema });
|
|
6031
6061
|
parseSchemaMeta$1({
|
|
@@ -6071,8 +6101,8 @@ const parseOneType$1 = ({ context, irSchema, schema, state }) => {
|
|
|
6071
6101
|
schema
|
|
6072
6102
|
});
|
|
6073
6103
|
}
|
|
6074
|
-
}
|
|
6075
|
-
|
|
6104
|
+
}
|
|
6105
|
+
function parseUnknown$1({ irSchema, schema }) {
|
|
6076
6106
|
if (!irSchema) irSchema = initIrSchema$1({ schema });
|
|
6077
6107
|
irSchema.type = "unknown";
|
|
6078
6108
|
parseSchemaMeta$1({
|
|
@@ -6080,8 +6110,8 @@ const parseUnknown$1 = ({ irSchema, schema }) => {
|
|
|
6080
6110
|
schema
|
|
6081
6111
|
});
|
|
6082
6112
|
return irSchema;
|
|
6083
|
-
}
|
|
6084
|
-
|
|
6113
|
+
}
|
|
6114
|
+
function schemaToIrSchema$1({ context, schema, state }) {
|
|
6085
6115
|
if (!state) state = { circularReferenceTracker: /* @__PURE__ */ new Set() };
|
|
6086
6116
|
if (state.$ref) state.circularReferenceTracker.add(state.$ref);
|
|
6087
6117
|
if ("$ref" in schema) return parseRef$1({
|
|
@@ -6118,8 +6148,8 @@ const schemaToIrSchema$1 = ({ context, schema, state }) => {
|
|
|
6118
6148
|
context,
|
|
6119
6149
|
schema
|
|
6120
6150
|
});
|
|
6121
|
-
}
|
|
6122
|
-
|
|
6151
|
+
}
|
|
6152
|
+
function parseSchema$1({ $ref, context, schema }) {
|
|
6123
6153
|
if (!context.ir.components) context.ir.components = {};
|
|
6124
6154
|
if (!context.ir.components.schemas) context.ir.components.schemas = {};
|
|
6125
6155
|
context.ir.components.schemas[refToName($ref)] = schemaToIrSchema$1({
|
|
@@ -6130,8 +6160,7 @@ const parseSchema$1 = ({ $ref, context, schema }) => {
|
|
|
6130
6160
|
circularReferenceTracker: /* @__PURE__ */ new Set()
|
|
6131
6161
|
}
|
|
6132
6162
|
});
|
|
6133
|
-
}
|
|
6134
|
-
|
|
6163
|
+
}
|
|
6135
6164
|
//#endregion
|
|
6136
6165
|
//#region src/openApi/3.0.x/parser/pagination.ts
|
|
6137
6166
|
const isPaginationType$1 = (schemaType) => schemaType === "boolean" || schemaType === "integer" || schemaType === "number" || schemaType === "string";
|
|
@@ -6176,7 +6205,6 @@ const paginationField$1 = ({ context, name, schema }) => {
|
|
|
6176
6205
|
}
|
|
6177
6206
|
return false;
|
|
6178
6207
|
};
|
|
6179
|
-
|
|
6180
6208
|
//#endregion
|
|
6181
6209
|
//#region src/openApi/3.0.x/parser/operation.ts
|
|
6182
6210
|
const parseOperationJsDoc$1 = ({ irOperation, operation }) => {
|
|
@@ -6302,7 +6330,6 @@ const parsePathOperation$1 = ({ context, method, operation, path, securityScheme
|
|
|
6302
6330
|
state
|
|
6303
6331
|
});
|
|
6304
6332
|
};
|
|
6305
|
-
|
|
6306
6333
|
//#endregion
|
|
6307
6334
|
//#region src/openApi/3.0.x/parser/parameter.ts
|
|
6308
6335
|
/**
|
|
@@ -6406,7 +6433,6 @@ const parseParameter$1 = ({ $ref, context, parameter }) => {
|
|
|
6406
6433
|
parameter
|
|
6407
6434
|
});
|
|
6408
6435
|
};
|
|
6409
|
-
|
|
6410
6436
|
//#endregion
|
|
6411
6437
|
//#region src/openApi/3.0.x/parser/requestBody.ts
|
|
6412
6438
|
const requestBodyToIrRequestBody$1 = ({ $ref, context, requestBody }) => {
|
|
@@ -6437,7 +6463,6 @@ const parseRequestBody$1 = ({ $ref, context, requestBody }) => {
|
|
|
6437
6463
|
requestBody
|
|
6438
6464
|
});
|
|
6439
6465
|
};
|
|
6440
|
-
|
|
6441
6466
|
//#endregion
|
|
6442
6467
|
//#region src/openApi/3.0.x/parser/server.ts
|
|
6443
6468
|
function parseServers$1({ context }) {
|
|
@@ -6451,7 +6476,6 @@ function parseServers$1({ context }) {
|
|
|
6451
6476
|
}
|
|
6452
6477
|
if (!context.ir.servers) context.ir.servers = [{ url: "/" }];
|
|
6453
6478
|
}
|
|
6454
|
-
|
|
6455
6479
|
//#endregion
|
|
6456
6480
|
//#region src/openApi/3.0.x/parser/validate.ts
|
|
6457
6481
|
const validateOpenApiSpec$1 = (spec, logger) => {
|
|
@@ -6520,7 +6544,6 @@ const validateOpenApiSpec$1 = (spec, logger) => {
|
|
|
6520
6544
|
valid: !issues.some((issue) => issue.severity === "error")
|
|
6521
6545
|
};
|
|
6522
6546
|
};
|
|
6523
|
-
|
|
6524
6547
|
//#endregion
|
|
6525
6548
|
//#region src/openApi/3.0.x/parser/index.ts
|
|
6526
6549
|
const parseV3_0_X = (context) => {
|
|
@@ -6726,7 +6749,6 @@ const parseV3_0_X = (context) => {
|
|
|
6726
6749
|
});
|
|
6727
6750
|
}
|
|
6728
6751
|
};
|
|
6729
|
-
|
|
6730
6752
|
//#endregion
|
|
6731
6753
|
//#region src/openApi/3.1.x/parser/filter.ts
|
|
6732
6754
|
/**
|
|
@@ -6795,7 +6817,6 @@ const filterSpec = ({ logger, operations, parameters, preserveOrder, requestBodi
|
|
|
6795
6817
|
}
|
|
6796
6818
|
eventFilterSpec.timeEnd();
|
|
6797
6819
|
};
|
|
6798
|
-
|
|
6799
6820
|
//#endregion
|
|
6800
6821
|
//#region src/openApi/3.1.x/parser/mediaType.ts
|
|
6801
6822
|
const contentToSchema = ({ content }) => {
|
|
@@ -6822,20 +6843,19 @@ const mediaTypeObjects = ({ content }) => {
|
|
|
6822
6843
|
});
|
|
6823
6844
|
return objects;
|
|
6824
6845
|
};
|
|
6825
|
-
|
|
6826
6846
|
//#endregion
|
|
6827
6847
|
//#region src/openApi/3.1.x/parser/schema.ts
|
|
6828
|
-
|
|
6848
|
+
function getSchemaTypes({ schema }) {
|
|
6829
6849
|
if (typeof schema.type === "string") return [schema.type];
|
|
6830
6850
|
if (schema.type) return schema.type;
|
|
6831
6851
|
if (schema.properties) return ["object"];
|
|
6832
6852
|
return [];
|
|
6833
|
-
}
|
|
6853
|
+
}
|
|
6834
6854
|
/**
|
|
6835
6855
|
* Finds the type of a discriminator property by looking it up in the provided schemas.
|
|
6836
6856
|
* Searches through properties and allOf chains to find the property definition.
|
|
6837
6857
|
*/
|
|
6838
|
-
|
|
6858
|
+
function findDiscriminatorPropertyType({ context, propertyName, schemas }) {
|
|
6839
6859
|
for (const schema of schemas) {
|
|
6840
6860
|
const resolved = schema.$ref ? context.resolveRef(schema.$ref) : schema;
|
|
6841
6861
|
const property = resolved.properties?.[propertyName];
|
|
@@ -6855,13 +6875,13 @@ const findDiscriminatorPropertyType = ({ context, propertyName, schemas }) => {
|
|
|
6855
6875
|
}
|
|
6856
6876
|
}
|
|
6857
6877
|
return "string";
|
|
6858
|
-
}
|
|
6878
|
+
}
|
|
6859
6879
|
/**
|
|
6860
6880
|
* Recursively finds discriminators in a schema, including nested allOf compositions.
|
|
6861
6881
|
* This is needed when a schema extends another schema via allOf, and that parent
|
|
6862
6882
|
* schema is itself an allOf composition with discriminators in inline schemas.
|
|
6863
6883
|
*/
|
|
6864
|
-
|
|
6884
|
+
function findDiscriminatorsInSchema({ context, discriminators = [], schema }) {
|
|
6865
6885
|
if (schema.discriminator) discriminators.push({
|
|
6866
6886
|
discriminator: schema.discriminator,
|
|
6867
6887
|
oneOf: schema.oneOf
|
|
@@ -6877,23 +6897,23 @@ const findDiscriminatorsInSchema = ({ context, discriminators = [], schema }) =>
|
|
|
6877
6897
|
});
|
|
6878
6898
|
}
|
|
6879
6899
|
return discriminators;
|
|
6880
|
-
}
|
|
6900
|
+
}
|
|
6881
6901
|
/**
|
|
6882
6902
|
* Gets the discriminator value for a schema.
|
|
6883
6903
|
* Returns only the schema's own discriminator value, not child values.
|
|
6884
6904
|
*/
|
|
6885
|
-
|
|
6905
|
+
function getAllDiscriminatorValues({ discriminator, schemaRef }) {
|
|
6886
6906
|
const values = [];
|
|
6887
6907
|
for (const [value, mappedSchemaRef] of Object.entries(discriminator.mapping || {})) if (mappedSchemaRef === schemaRef) values.push(value);
|
|
6888
6908
|
return values;
|
|
6889
|
-
}
|
|
6890
|
-
|
|
6909
|
+
}
|
|
6910
|
+
function parseSchemaJsDoc({ irSchema, schema }) {
|
|
6891
6911
|
if (schema.deprecated !== void 0) irSchema.deprecated = schema.deprecated;
|
|
6892
6912
|
if (schema.example) irSchema.example = schema.example;
|
|
6893
6913
|
if (schema.description) irSchema.description = schema.description;
|
|
6894
6914
|
if (schema.title) irSchema.title = schema.title;
|
|
6895
|
-
}
|
|
6896
|
-
|
|
6915
|
+
}
|
|
6916
|
+
function parseSchemaMeta({ irSchema, schema }) {
|
|
6897
6917
|
if (schema.const !== void 0) {
|
|
6898
6918
|
irSchema.const = schema.const;
|
|
6899
6919
|
if (!schema.type) if (schema.const === null) irSchema.type = "null";
|
|
@@ -6924,8 +6944,8 @@ const parseSchemaMeta = ({ irSchema, schema }) => {
|
|
|
6924
6944
|
if (schema.pattern) irSchema.pattern = schema.pattern;
|
|
6925
6945
|
if (schema.readOnly) irSchema.accessScope = "read";
|
|
6926
6946
|
else if (schema.writeOnly) irSchema.accessScope = "write";
|
|
6927
|
-
}
|
|
6928
|
-
|
|
6947
|
+
}
|
|
6948
|
+
function parseArray({ context, irSchema = {}, schema, state }) {
|
|
6929
6949
|
if (schema.prefixItems && schema.prefixItems.length || schema.maxItems && schema.maxItems === schema.minItems || schema.const !== void 0) irSchema.type = "tuple";
|
|
6930
6950
|
else irSchema.type = "array";
|
|
6931
6951
|
let schemaItems = [];
|
|
@@ -6958,20 +6978,20 @@ const parseArray = ({ context, irSchema = {}, schema, state }) => {
|
|
|
6958
6978
|
schema: irSchema
|
|
6959
6979
|
});
|
|
6960
6980
|
return irSchema;
|
|
6961
|
-
}
|
|
6962
|
-
|
|
6981
|
+
}
|
|
6982
|
+
function parseBoolean({ irSchema = {} }) {
|
|
6963
6983
|
irSchema.type = "boolean";
|
|
6964
6984
|
return irSchema;
|
|
6965
|
-
}
|
|
6966
|
-
|
|
6985
|
+
}
|
|
6986
|
+
function parseNull({ irSchema = {} }) {
|
|
6967
6987
|
irSchema.type = "null";
|
|
6968
6988
|
return irSchema;
|
|
6969
|
-
}
|
|
6970
|
-
|
|
6989
|
+
}
|
|
6990
|
+
function parseNumber({ irSchema = {}, schema }) {
|
|
6971
6991
|
irSchema.type = schema.type;
|
|
6972
6992
|
return irSchema;
|
|
6973
|
-
}
|
|
6974
|
-
|
|
6993
|
+
}
|
|
6994
|
+
function parseObject({ context, irSchema = {}, schema, state }) {
|
|
6975
6995
|
irSchema.type = "object";
|
|
6976
6996
|
const schemaProperties = {};
|
|
6977
6997
|
for (const name in schema.properties) {
|
|
@@ -7030,15 +7050,15 @@ const parseObject = ({ context, irSchema = {}, schema, state }) => {
|
|
|
7030
7050
|
}
|
|
7031
7051
|
}
|
|
7032
7052
|
return irSchema;
|
|
7033
|
-
}
|
|
7034
|
-
|
|
7053
|
+
}
|
|
7054
|
+
function parseString({ irSchema = {} }) {
|
|
7035
7055
|
irSchema.type = "string";
|
|
7036
7056
|
return irSchema;
|
|
7037
|
-
}
|
|
7038
|
-
|
|
7057
|
+
}
|
|
7058
|
+
function parseExtensions({ source, target }) {
|
|
7039
7059
|
for (const key in source) if (key.startsWith("x-")) target[key] = source[key];
|
|
7040
|
-
}
|
|
7041
|
-
|
|
7060
|
+
}
|
|
7061
|
+
function initIrSchema({ schema }) {
|
|
7042
7062
|
const irSchema = {};
|
|
7043
7063
|
parseSchemaJsDoc({
|
|
7044
7064
|
irSchema,
|
|
@@ -7049,8 +7069,8 @@ const initIrSchema = ({ schema }) => {
|
|
|
7049
7069
|
target: irSchema
|
|
7050
7070
|
});
|
|
7051
7071
|
return irSchema;
|
|
7052
|
-
}
|
|
7053
|
-
|
|
7072
|
+
}
|
|
7073
|
+
function parseAllOf({ context, schema, state }) {
|
|
7054
7074
|
let irSchema = initIrSchema({ schema });
|
|
7055
7075
|
parseSchemaMeta({
|
|
7056
7076
|
irSchema,
|
|
@@ -7201,8 +7221,8 @@ const parseAllOf = ({ context, schema, state }) => {
|
|
|
7201
7221
|
};
|
|
7202
7222
|
}
|
|
7203
7223
|
return irSchema;
|
|
7204
|
-
}
|
|
7205
|
-
|
|
7224
|
+
}
|
|
7225
|
+
function parseAnyOf({ context, schema, state }) {
|
|
7206
7226
|
let irSchema = initIrSchema({ schema });
|
|
7207
7227
|
parseSchemaMeta({
|
|
7208
7228
|
irSchema,
|
|
@@ -7257,10 +7277,15 @@ const parseAnyOf = ({ context, schema, state }) => {
|
|
|
7257
7277
|
logicalOperator: "and"
|
|
7258
7278
|
};
|
|
7259
7279
|
}
|
|
7280
|
+
if (schema.discriminator && irSchema.logicalOperator === "or") irSchema.discriminator = { propertyName: schema.discriminator.propertyName };
|
|
7260
7281
|
return irSchema;
|
|
7261
|
-
}
|
|
7262
|
-
|
|
7282
|
+
}
|
|
7283
|
+
function parseEnum({ context, schema, state }) {
|
|
7263
7284
|
let irSchema = initIrSchema({ schema });
|
|
7285
|
+
parseSchemaMeta({
|
|
7286
|
+
irSchema,
|
|
7287
|
+
schema
|
|
7288
|
+
});
|
|
7264
7289
|
irSchema.type = "enum";
|
|
7265
7290
|
const schemaItems = [];
|
|
7266
7291
|
const schemaTypes = getSchemaTypes({ schema });
|
|
@@ -7290,8 +7315,8 @@ const parseEnum = ({ context, schema, state }) => {
|
|
|
7290
7315
|
schema: irSchema
|
|
7291
7316
|
});
|
|
7292
7317
|
return irSchema;
|
|
7293
|
-
}
|
|
7294
|
-
|
|
7318
|
+
}
|
|
7319
|
+
function parseOneOf({ context, schema, state }) {
|
|
7295
7320
|
let irSchema = initIrSchema({ schema });
|
|
7296
7321
|
parseSchemaMeta({
|
|
7297
7322
|
irSchema,
|
|
@@ -7348,9 +7373,10 @@ const parseOneOf = ({ context, schema, state }) => {
|
|
|
7348
7373
|
logicalOperator: "and"
|
|
7349
7374
|
};
|
|
7350
7375
|
}
|
|
7376
|
+
if (schema.discriminator && irSchema.logicalOperator === "or") irSchema.discriminator = { propertyName: schema.discriminator.propertyName };
|
|
7351
7377
|
return irSchema;
|
|
7352
|
-
}
|
|
7353
|
-
|
|
7378
|
+
}
|
|
7379
|
+
function parseRef({ context, schema, state }) {
|
|
7354
7380
|
if (!isTopLevelComponent(schema.$ref)) {
|
|
7355
7381
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
7356
7382
|
const refSchema = context.resolveRef(schema.$ref);
|
|
@@ -7371,7 +7397,7 @@ const parseRef = ({ context, schema, state }) => {
|
|
|
7371
7397
|
schema
|
|
7372
7398
|
});
|
|
7373
7399
|
const irRefSchema = {};
|
|
7374
|
-
irRefSchema.$ref =
|
|
7400
|
+
irRefSchema.$ref = schema.$ref;
|
|
7375
7401
|
if (!state.circularReferenceTracker.has(schema.$ref)) {
|
|
7376
7402
|
const refSchema = context.resolveRef(schema.$ref);
|
|
7377
7403
|
const originalRef = state.$ref;
|
|
@@ -7394,8 +7420,8 @@ const parseRef = ({ context, schema, state }) => {
|
|
|
7394
7420
|
schema: irSchema
|
|
7395
7421
|
});
|
|
7396
7422
|
return irSchema;
|
|
7397
|
-
}
|
|
7398
|
-
|
|
7423
|
+
}
|
|
7424
|
+
function parseOneType({ context, irSchema, schema, state }) {
|
|
7399
7425
|
if (!irSchema) {
|
|
7400
7426
|
irSchema = initIrSchema({ schema });
|
|
7401
7427
|
parseSchemaMeta({
|
|
@@ -7443,8 +7469,8 @@ const parseOneType = ({ context, irSchema, schema, state }) => {
|
|
|
7443
7469
|
schema
|
|
7444
7470
|
});
|
|
7445
7471
|
}
|
|
7446
|
-
}
|
|
7447
|
-
|
|
7472
|
+
}
|
|
7473
|
+
function parseManyTypes({ context, irSchema, schema, state }) {
|
|
7448
7474
|
if (!irSchema) irSchema = initIrSchema({ schema });
|
|
7449
7475
|
const typeIrSchema = {};
|
|
7450
7476
|
parseSchemaMeta({
|
|
@@ -7471,8 +7497,8 @@ const parseManyTypes = ({ context, irSchema, schema, state }) => {
|
|
|
7471
7497
|
schema: irSchema
|
|
7472
7498
|
});
|
|
7473
7499
|
return irSchema;
|
|
7474
|
-
}
|
|
7475
|
-
|
|
7500
|
+
}
|
|
7501
|
+
function parseType({ context, schema, state }) {
|
|
7476
7502
|
const irSchema = initIrSchema({ schema });
|
|
7477
7503
|
parseSchemaMeta({
|
|
7478
7504
|
irSchema,
|
|
@@ -7497,8 +7523,8 @@ const parseType = ({ context, schema, state }) => {
|
|
|
7497
7523
|
},
|
|
7498
7524
|
state
|
|
7499
7525
|
});
|
|
7500
|
-
}
|
|
7501
|
-
|
|
7526
|
+
}
|
|
7527
|
+
function parseUnknown({ irSchema, schema }) {
|
|
7502
7528
|
if (!irSchema) irSchema = initIrSchema({ schema });
|
|
7503
7529
|
irSchema.type = "unknown";
|
|
7504
7530
|
parseSchemaMeta({
|
|
@@ -7506,8 +7532,8 @@ const parseUnknown = ({ irSchema, schema }) => {
|
|
|
7506
7532
|
schema
|
|
7507
7533
|
});
|
|
7508
7534
|
return irSchema;
|
|
7509
|
-
}
|
|
7510
|
-
|
|
7535
|
+
}
|
|
7536
|
+
function schemaToIrSchema({ context, schema, state }) {
|
|
7511
7537
|
if (!state) state = { circularReferenceTracker: /* @__PURE__ */ new Set() };
|
|
7512
7538
|
if (state.$ref) state.circularReferenceTracker.add(state.$ref);
|
|
7513
7539
|
if (schema.$ref) return parseRef({
|
|
@@ -7552,8 +7578,8 @@ const schemaToIrSchema = ({ context, schema, state }) => {
|
|
|
7552
7578
|
context,
|
|
7553
7579
|
schema
|
|
7554
7580
|
});
|
|
7555
|
-
}
|
|
7556
|
-
|
|
7581
|
+
}
|
|
7582
|
+
function parseSchema({ $ref, context, schema }) {
|
|
7557
7583
|
if (!context.ir.components) context.ir.components = {};
|
|
7558
7584
|
if (!context.ir.components.schemas) context.ir.components.schemas = {};
|
|
7559
7585
|
context.ir.components.schemas[refToName($ref)] = schemaToIrSchema({
|
|
@@ -7564,8 +7590,7 @@ const parseSchema = ({ $ref, context, schema }) => {
|
|
|
7564
7590
|
circularReferenceTracker: /* @__PURE__ */ new Set()
|
|
7565
7591
|
}
|
|
7566
7592
|
});
|
|
7567
|
-
}
|
|
7568
|
-
|
|
7593
|
+
}
|
|
7569
7594
|
//#endregion
|
|
7570
7595
|
//#region src/openApi/3.1.x/parser/pagination.ts
|
|
7571
7596
|
const isPaginationType = (schemaTypes) => schemaTypes.includes("boolean") || schemaTypes.includes("integer") || schemaTypes.includes("number") || schemaTypes.includes("string");
|
|
@@ -7617,7 +7642,6 @@ const paginationField = ({ context, name, schema }) => {
|
|
|
7617
7642
|
}
|
|
7618
7643
|
return false;
|
|
7619
7644
|
};
|
|
7620
|
-
|
|
7621
7645
|
//#endregion
|
|
7622
7646
|
//#region src/openApi/3.1.x/parser/operation.ts
|
|
7623
7647
|
const parseOperationJsDoc = ({ irOperation, operation }) => {
|
|
@@ -7754,7 +7778,6 @@ const parseWebhookOperation = ({ context, key, method, ...options }) => {
|
|
|
7754
7778
|
});
|
|
7755
7779
|
context.ir.webhooks[key][method] = parsed;
|
|
7756
7780
|
};
|
|
7757
|
-
|
|
7758
7781
|
//#endregion
|
|
7759
7782
|
//#region src/openApi/3.1.x/parser/parameter.ts
|
|
7760
7783
|
/**
|
|
@@ -7854,7 +7877,6 @@ const parseParameter = ({ $ref, context, parameter }) => {
|
|
|
7854
7877
|
parameter
|
|
7855
7878
|
});
|
|
7856
7879
|
};
|
|
7857
|
-
|
|
7858
7880
|
//#endregion
|
|
7859
7881
|
//#region src/openApi/3.1.x/parser/requestBody.ts
|
|
7860
7882
|
const requestBodyToIrRequestBody = ({ $ref, context, requestBody }) => {
|
|
@@ -7885,7 +7907,6 @@ const parseRequestBody = ({ $ref, context, requestBody }) => {
|
|
|
7885
7907
|
requestBody
|
|
7886
7908
|
});
|
|
7887
7909
|
};
|
|
7888
|
-
|
|
7889
7910
|
//#endregion
|
|
7890
7911
|
//#region src/openApi/3.1.x/parser/server.ts
|
|
7891
7912
|
const parseServers = ({ context }) => {
|
|
@@ -7899,7 +7920,6 @@ const parseServers = ({ context }) => {
|
|
|
7899
7920
|
}
|
|
7900
7921
|
if (!context.ir.servers) context.ir.servers = [{ url: "/" }];
|
|
7901
7922
|
};
|
|
7902
|
-
|
|
7903
7923
|
//#endregion
|
|
7904
7924
|
//#region src/openApi/3.1.x/parser/validate.ts
|
|
7905
7925
|
const validateOpenApiSpec = (spec, logger) => {
|
|
@@ -7968,7 +7988,6 @@ const validateOpenApiSpec = (spec, logger) => {
|
|
|
7968
7988
|
valid: !issues.some((issue) => issue.severity === "error")
|
|
7969
7989
|
};
|
|
7970
7990
|
};
|
|
7971
|
-
|
|
7972
7991
|
//#endregion
|
|
7973
7992
|
//#region src/openApi/3.1.x/parser/webhook.ts
|
|
7974
7993
|
const parseWebhooks = ({ context, securitySchemesMap }) => {
|
|
@@ -8117,7 +8136,6 @@ const parseWebhooks = ({ context, securitySchemesMap }) => {
|
|
|
8117
8136
|
});
|
|
8118
8137
|
}
|
|
8119
8138
|
};
|
|
8120
|
-
|
|
8121
8139
|
//#endregion
|
|
8122
8140
|
//#region src/openApi/3.1.x/parser/index.ts
|
|
8123
8141
|
const parseV3_1_X = (context) => {
|
|
@@ -8327,7 +8345,6 @@ const parseV3_1_X = (context) => {
|
|
|
8327
8345
|
securitySchemesMap
|
|
8328
8346
|
});
|
|
8329
8347
|
};
|
|
8330
|
-
|
|
8331
8348
|
//#endregion
|
|
8332
8349
|
//#region src/openApi/index.ts
|
|
8333
8350
|
/**
|
|
@@ -8350,7 +8367,6 @@ function parseOpenApiSpec(context) {
|
|
|
8350
8367
|
}
|
|
8351
8368
|
throw new Error("Unsupported OpenAPI specification");
|
|
8352
8369
|
}
|
|
8353
|
-
|
|
8354
8370
|
//#endregion
|
|
8355
8371
|
//#region src/openApi/shared/locations/operation.ts
|
|
8356
8372
|
/**
|
|
@@ -8398,7 +8414,6 @@ const OperationPath = {
|
|
|
8398
8414
|
},
|
|
8399
8415
|
id: () => (operation) => [operation.id]
|
|
8400
8416
|
};
|
|
8401
|
-
|
|
8402
8417
|
//#endregion
|
|
8403
8418
|
//#region src/openApi/shared/utils/patch.ts
|
|
8404
8419
|
async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
@@ -8507,7 +8522,36 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8507
8522
|
await patchFn(operation);
|
|
8508
8523
|
}
|
|
8509
8524
|
}
|
|
8510
|
-
|
|
8525
|
+
//#endregion
|
|
8526
|
+
//#region src/plugins/duplicate.ts
|
|
8527
|
+
function stableStringify(value) {
|
|
8528
|
+
return JSON.stringify(value, (_, v) => {
|
|
8529
|
+
if (typeof v === "function") return `[function:${v.toString()}]`;
|
|
8530
|
+
if (v && typeof v === "object" && !Array.isArray(v)) return Object.fromEntries(Object.entries(v).sort(([a], [b]) => a.localeCompare(b)));
|
|
8531
|
+
return v;
|
|
8532
|
+
});
|
|
8533
|
+
}
|
|
8534
|
+
function normalizePluginEntry(plugin) {
|
|
8535
|
+
if (typeof plugin === "string") return {
|
|
8536
|
+
name: plugin,
|
|
8537
|
+
serialized: "{}"
|
|
8538
|
+
};
|
|
8539
|
+
const { name, ...config } = plugin;
|
|
8540
|
+
return {
|
|
8541
|
+
name,
|
|
8542
|
+
serialized: stableStringify(config)
|
|
8543
|
+
};
|
|
8544
|
+
}
|
|
8545
|
+
function warnOnConflictingDuplicatePlugins(plugins) {
|
|
8546
|
+
const seen = /* @__PURE__ */ new Map();
|
|
8547
|
+
for (const plugin of plugins) {
|
|
8548
|
+
const { name, serialized } = normalizePluginEntry(plugin);
|
|
8549
|
+
if (!name) continue;
|
|
8550
|
+
const previous = seen.get(name);
|
|
8551
|
+
if (previous !== void 0 && previous !== serialized) log.warn(`Plugin "${name}" is configured multiple times. Only the last instance will take effect.`);
|
|
8552
|
+
seen.set(name, serialized);
|
|
8553
|
+
}
|
|
8554
|
+
}
|
|
8511
8555
|
//#endregion
|
|
8512
8556
|
//#region src/plugins/shared/utils/config.ts
|
|
8513
8557
|
const definePluginConfig = (defaultConfig) => (userConfig) => ({
|
|
@@ -8525,7 +8569,6 @@ const mappers = {
|
|
|
8525
8569
|
function: (name) => ({ name }),
|
|
8526
8570
|
string: (name) => ({ name })
|
|
8527
8571
|
};
|
|
8528
|
-
|
|
8529
8572
|
//#endregion
|
|
8530
8573
|
//#region src/plugins/symbol.ts
|
|
8531
8574
|
/**
|
|
@@ -8552,7 +8595,6 @@ function buildSymbolIn({ plugin, ...ctx }) {
|
|
|
8552
8595
|
name: ctx.naming ? applyNaming(ctx.name, ctx.naming) : ctx.name
|
|
8553
8596
|
};
|
|
8554
8597
|
}
|
|
8555
|
-
|
|
8556
8598
|
//#endregion
|
|
8557
8599
|
//#region src/plugins/validator.ts
|
|
8558
8600
|
/**
|
|
@@ -8580,13 +8622,11 @@ function resolveValidatorLayer(layers, key, defaultValues) {
|
|
|
8580
8622
|
...override
|
|
8581
8623
|
};
|
|
8582
8624
|
}
|
|
8583
|
-
|
|
8584
8625
|
//#endregion
|
|
8585
8626
|
//#region src/utils/escape.ts
|
|
8586
8627
|
function escapeComment(value) {
|
|
8587
8628
|
return value.replace(/\*\//g, "*").replace(/\/\*/g, "*").replace(/\r?\n(.*)/g, (_l, w) => EOL + w.trim());
|
|
8588
8629
|
}
|
|
8589
|
-
|
|
8590
8630
|
//#endregion
|
|
8591
8631
|
//#region src/utils/exports.ts
|
|
8592
8632
|
/**
|
|
@@ -8598,7 +8638,6 @@ const utils = {
|
|
|
8598
8638
|
},
|
|
8599
8639
|
toCase
|
|
8600
8640
|
};
|
|
8601
|
-
|
|
8602
8641
|
//#endregion
|
|
8603
8642
|
//#region src/utils/header.ts
|
|
8604
8643
|
/**
|
|
@@ -8616,7 +8655,6 @@ function outputHeaderToPrefix(ctx) {
|
|
|
8616
8655
|
const content = lines.join("\n");
|
|
8617
8656
|
return content ? `${content}\n\n` : "";
|
|
8618
8657
|
}
|
|
8619
|
-
|
|
8620
8658
|
//#endregion
|
|
8621
8659
|
//#region src/utils/path.ts
|
|
8622
8660
|
/**
|
|
@@ -8718,9 +8756,9 @@ function pathToName(path, options) {
|
|
|
8718
8756
|
} else if (STRUCTURAL_SUFFIX[segment]) names.push(STRUCTURAL_SUFFIX[segment]);
|
|
8719
8757
|
index++;
|
|
8720
8758
|
}
|
|
8721
|
-
return
|
|
8759
|
+
return names.join("-");
|
|
8722
8760
|
}
|
|
8723
|
-
|
|
8724
8761
|
//#endregion
|
|
8725
|
-
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, requestValidatorLayers, resolveNaming, resolveRef, resolveSource, resolveValidatorLayer, satisfies, shouldReportCrash, statusCodeToGroup, toCase, utils, valueToObject };
|
|
8762
|
+
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, warnOnConflictingDuplicatePlugins };
|
|
8763
|
+
|
|
8726
8764
|
//# sourceMappingURL=index.mjs.map
|