@hey-api/shared 0.2.3 → 0.2.5
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 +66 -71
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +437 -408
- package/dist/index.mjs.map +1 -1
- package/package.json +4 -7
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import colors from "ansi-colors";
|
|
2
2
|
import fs from "node:fs";
|
|
3
3
|
import path from "node:path";
|
|
4
|
-
import
|
|
4
|
+
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";
|
|
@@ -54,12 +54,6 @@ function findTsConfigPath(baseDir, tsConfigPath) {
|
|
|
54
54
|
}
|
|
55
55
|
return null;
|
|
56
56
|
}
|
|
57
|
-
function loadTsConfig(configPath) {
|
|
58
|
-
if (!configPath) return null;
|
|
59
|
-
const raw = ts.readConfigFile(configPath, ts.sys.readFile);
|
|
60
|
-
if (raw.error) throw new Error(`Couldn't read tsconfig from path: ${configPath}`);
|
|
61
|
-
return ts.parseJsonConfigFileContent(raw.config, ts.sys, path.dirname(configPath));
|
|
62
|
-
}
|
|
63
57
|
|
|
64
58
|
//#endregion
|
|
65
59
|
//#region src/cli.ts
|
|
@@ -112,8 +106,8 @@ function printCliIntro(initialDir, showLogo = false) {
|
|
|
112
106
|
|
|
113
107
|
//#endregion
|
|
114
108
|
//#region src/fs.ts
|
|
115
|
-
function ensureDirSync(path
|
|
116
|
-
if (!fs.existsSync(path
|
|
109
|
+
function ensureDirSync(path) {
|
|
110
|
+
if (!fs.existsSync(path)) fs.mkdirSync(path, { recursive: true });
|
|
117
111
|
}
|
|
118
112
|
|
|
119
113
|
//#endregion
|
|
@@ -207,9 +201,7 @@ async function openGitHubIssueWithCrashReport(error, initialDir) {
|
|
|
207
201
|
labels: "bug 🔥",
|
|
208
202
|
title: "Crash Report"
|
|
209
203
|
});
|
|
210
|
-
|
|
211
|
-
const open = (await import("open")).default;
|
|
212
|
-
await open(url);
|
|
204
|
+
await open(`${packageJson.bugs.url}new?${search.toString()}`);
|
|
213
205
|
}
|
|
214
206
|
function printCrashReport({ error, logPath }) {
|
|
215
207
|
if (error instanceof ConfigValidationError && error.errors.length) {
|
|
@@ -429,7 +421,7 @@ function inputToApiRegistry(input) {
|
|
|
429
421
|
return;
|
|
430
422
|
}
|
|
431
423
|
if (input.path.startsWith(".")) return;
|
|
432
|
-
if (input.path.startsWith(
|
|
424
|
+
if (input.path.startsWith("https://get.heyapi.dev")) {
|
|
433
425
|
input.path = input.path.slice(heyApiRegistryBaseUrl.length + 1);
|
|
434
426
|
Object.assign(input, inputToHeyApiPath(input));
|
|
435
427
|
return;
|
|
@@ -504,9 +496,9 @@ function compileInputPath(input) {
|
|
|
504
496
|
}
|
|
505
497
|
const [basePath, baseQuery] = input.path.split("?");
|
|
506
498
|
const queryPath = (baseQuery || "").split("&").map((part) => part.split("="));
|
|
507
|
-
let path
|
|
508
|
-
if (path
|
|
509
|
-
const [, pathUrl] = path
|
|
499
|
+
let path = basePath || "";
|
|
500
|
+
if (path.endsWith("/")) path = path.slice(0, path.length - 1);
|
|
501
|
+
const [, pathUrl] = path.split("://");
|
|
510
502
|
const [baseUrl, organization, project] = (pathUrl || "").split("/");
|
|
511
503
|
result.organization = organization || input.organization;
|
|
512
504
|
result.project = project || input.project;
|
|
@@ -629,36 +621,36 @@ const mergeResult = (result, mapped) => {
|
|
|
629
621
|
for (const [key, value] of Object.entries(mapped)) if (value !== void 0 && value !== "") result[key] = value;
|
|
630
622
|
return result;
|
|
631
623
|
};
|
|
632
|
-
const valueToObject = ({ defaultValue, mappers
|
|
624
|
+
const valueToObject = ({ defaultValue, mappers, value }) => {
|
|
633
625
|
let result = { ...defaultValue };
|
|
634
626
|
switch (typeof value) {
|
|
635
627
|
case "boolean":
|
|
636
|
-
if (mappers
|
|
637
|
-
const mapper = mappers
|
|
628
|
+
if (mappers && "boolean" in mappers) {
|
|
629
|
+
const mapper = mappers.boolean;
|
|
638
630
|
result = mergeResult(result, mapper(value));
|
|
639
631
|
}
|
|
640
632
|
break;
|
|
641
633
|
case "function":
|
|
642
|
-
if (mappers
|
|
643
|
-
const mapper = mappers
|
|
634
|
+
if (mappers && "function" in mappers) {
|
|
635
|
+
const mapper = mappers.function;
|
|
644
636
|
result = mergeResult(result, mapper(value));
|
|
645
637
|
}
|
|
646
638
|
break;
|
|
647
639
|
case "number":
|
|
648
|
-
if (mappers
|
|
649
|
-
const mapper = mappers
|
|
640
|
+
if (mappers && "number" in mappers) {
|
|
641
|
+
const mapper = mappers.number;
|
|
650
642
|
result = mergeResult(result, mapper(value));
|
|
651
643
|
}
|
|
652
644
|
break;
|
|
653
645
|
case "string":
|
|
654
|
-
if (mappers
|
|
655
|
-
const mapper = mappers
|
|
646
|
+
if (mappers && "string" in mappers) {
|
|
647
|
+
const mapper = mappers.string;
|
|
656
648
|
result = mergeResult(result, mapper(value));
|
|
657
649
|
}
|
|
658
650
|
break;
|
|
659
651
|
case "object":
|
|
660
|
-
if (isPlainObject(value)) if (mappers
|
|
661
|
-
const mapper = mappers
|
|
652
|
+
if (isPlainObject(value)) if (mappers && "object" in mappers && typeof mappers.object === "function") {
|
|
653
|
+
const mapper = mappers.object;
|
|
662
654
|
result = mergeResult(result, mapper(value, defaultValue));
|
|
663
655
|
} else result = mergeResult(result, value);
|
|
664
656
|
break;
|
|
@@ -730,50 +722,50 @@ function getParser(userConfig) {
|
|
|
730
722
|
}),
|
|
731
723
|
transforms: valueToObject({
|
|
732
724
|
defaultValue: { ...defaultValue.transforms },
|
|
733
|
-
mappers: { object: (fields
|
|
734
|
-
...fields
|
|
725
|
+
mappers: { object: (fields, defaultValue) => ({
|
|
726
|
+
...fields,
|
|
735
727
|
enums: valueToObject({
|
|
736
728
|
defaultValue: {
|
|
737
|
-
...defaultValue
|
|
738
|
-
enabled: fields
|
|
729
|
+
...defaultValue.enums,
|
|
730
|
+
enabled: fields.enums !== void 0 ? Boolean(fields.enums) : defaultValue.enums.enabled
|
|
739
731
|
},
|
|
740
732
|
mappers: {
|
|
741
733
|
boolean: (enabled) => ({ enabled }),
|
|
742
734
|
string: (mode) => ({ mode })
|
|
743
735
|
},
|
|
744
|
-
value: fields
|
|
736
|
+
value: fields.enums
|
|
745
737
|
}),
|
|
746
|
-
propertiesRequiredByDefault: fields
|
|
738
|
+
propertiesRequiredByDefault: fields.propertiesRequiredByDefault !== void 0 ? fields.propertiesRequiredByDefault : defaultValue.propertiesRequiredByDefault,
|
|
747
739
|
readWrite: valueToObject({
|
|
748
740
|
defaultValue: {
|
|
749
|
-
...defaultValue
|
|
750
|
-
enabled: fields
|
|
741
|
+
...defaultValue.readWrite,
|
|
742
|
+
enabled: fields.readWrite !== void 0 ? Boolean(fields.readWrite) : defaultValue.readWrite.enabled
|
|
751
743
|
},
|
|
752
744
|
mappers: {
|
|
753
745
|
boolean: (enabled) => ({ enabled }),
|
|
754
|
-
object: (fields
|
|
755
|
-
...fields
|
|
746
|
+
object: (fields, defaultValue) => ({
|
|
747
|
+
...fields,
|
|
756
748
|
requests: valueToObject({
|
|
757
|
-
defaultValue: { ...defaultValue
|
|
749
|
+
defaultValue: { ...defaultValue.requests },
|
|
758
750
|
mappers: {
|
|
759
751
|
function: (name) => ({ name }),
|
|
760
752
|
string: (name) => ({ name })
|
|
761
753
|
},
|
|
762
|
-
value: fields
|
|
754
|
+
value: fields.requests
|
|
763
755
|
}),
|
|
764
756
|
responses: valueToObject({
|
|
765
|
-
defaultValue: { ...defaultValue
|
|
757
|
+
defaultValue: { ...defaultValue.responses },
|
|
766
758
|
mappers: {
|
|
767
759
|
function: (name) => ({ name }),
|
|
768
760
|
string: (name) => ({ name })
|
|
769
761
|
},
|
|
770
|
-
value: fields
|
|
762
|
+
value: fields.responses
|
|
771
763
|
})
|
|
772
764
|
})
|
|
773
765
|
},
|
|
774
|
-
value: fields
|
|
766
|
+
value: fields.readWrite
|
|
775
767
|
}),
|
|
776
|
-
schemaName: fields
|
|
768
|
+
schemaName: fields.schemaName !== void 0 ? fields.schemaName : defaultValue.schemaName
|
|
777
769
|
}) },
|
|
778
770
|
value: fields.transforms
|
|
779
771
|
}),
|
|
@@ -810,31 +802,31 @@ function dependencyFactory(dependencies) {
|
|
|
810
802
|
|
|
811
803
|
//#endregion
|
|
812
804
|
//#region src/debug/graph.ts
|
|
813
|
-
const analyzeStructure = (graph
|
|
805
|
+
const analyzeStructure = (graph) => {
|
|
814
806
|
let maxDepth = 0;
|
|
815
807
|
let maxChildren = 0;
|
|
816
808
|
const computeDepth = (pointer, depth) => {
|
|
817
809
|
maxDepth = Math.max(maxDepth, depth);
|
|
818
|
-
const children = Array.from(graph
|
|
810
|
+
const children = Array.from(graph.nodes.entries()).filter(([, nodeInfo]) => nodeInfo.parentPointer === pointer).map(([childPointer]) => childPointer);
|
|
819
811
|
maxChildren = Math.max(maxChildren, children.length);
|
|
820
812
|
for (const childPointer of children) computeDepth(childPointer, depth + 1);
|
|
821
813
|
};
|
|
822
|
-
const totalNodes = graph
|
|
823
|
-
if (graph
|
|
814
|
+
const totalNodes = graph.nodes.size;
|
|
815
|
+
if (graph.nodes.has("#")) computeDepth("#", 1);
|
|
824
816
|
return {
|
|
825
817
|
maxChildren,
|
|
826
818
|
maxDepth,
|
|
827
819
|
totalNodes
|
|
828
820
|
};
|
|
829
821
|
};
|
|
830
|
-
const exportForVisualization = (graph
|
|
822
|
+
const exportForVisualization = (graph) => {
|
|
831
823
|
const childrenMap = /* @__PURE__ */ new Map();
|
|
832
|
-
for (const [pointer, nodeInfo] of graph
|
|
824
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
833
825
|
if (!nodeInfo.parentPointer) continue;
|
|
834
826
|
if (!childrenMap.has(nodeInfo.parentPointer)) childrenMap.set(nodeInfo.parentPointer, []);
|
|
835
827
|
childrenMap.get(nodeInfo.parentPointer).push(pointer);
|
|
836
828
|
}
|
|
837
|
-
return Array.from(graph
|
|
829
|
+
return Array.from(graph.nodes.keys()).map((pointer) => ({
|
|
838
830
|
children: childrenMap.get(pointer)?.length ?? 0,
|
|
839
831
|
childrenPointers: childrenMap.get(pointer) || [],
|
|
840
832
|
pointer
|
|
@@ -1001,7 +993,7 @@ const hasOperationDataRequired = (operation) => {
|
|
|
1001
993
|
if (operation.body?.required) return true;
|
|
1002
994
|
return false;
|
|
1003
995
|
};
|
|
1004
|
-
const createOperationKey = ({ method, path
|
|
996
|
+
const createOperationKey = ({ method, path }) => `${method.toUpperCase()} ${path}`;
|
|
1005
997
|
const operationPagination = ({ context, operation }) => {
|
|
1006
998
|
const body = operation.body;
|
|
1007
999
|
if (!body || !body.pagination) return parameterWithPagination({
|
|
@@ -1117,7 +1109,7 @@ const uppercaseRegExp = /[\p{Lu}]/u;
|
|
|
1117
1109
|
const lowercaseRegExp = /[\p{Ll}]/u;
|
|
1118
1110
|
const identifierRegExp = /([\p{Alpha}\p{N}_]|$)/u;
|
|
1119
1111
|
const separatorsRegExp = /[_.$+:\- `\\[\](){}\\/]+/;
|
|
1120
|
-
const leadingSeparatorsRegExp =
|
|
1112
|
+
const leadingSeparatorsRegExp = new RegExp(`^${separatorsRegExp.source}`);
|
|
1121
1113
|
const separatorsAndIdentifierRegExp = new RegExp(`${separatorsRegExp.source}${identifierRegExp.source}`, "gu");
|
|
1122
1114
|
const numbersAndIdentifierRegExp = new RegExp(`\\d+${identifierRegExp.source}`, "gu");
|
|
1123
1115
|
const preserveCase = (value, casing) => {
|
|
@@ -1265,24 +1257,24 @@ const sanitizeNamespaceIdentifier = (name) => name.replace(/^[^\p{ID_Start}]+/u,
|
|
|
1265
1257
|
*
|
|
1266
1258
|
* @deprecated
|
|
1267
1259
|
*/
|
|
1268
|
-
function operationToId({ context, count = 1, id, method, path
|
|
1260
|
+
function operationToId({ context, count = 1, id, method, path, state }) {
|
|
1269
1261
|
let result;
|
|
1270
1262
|
const { output } = context.config;
|
|
1271
1263
|
const targetCase = (output !== void 0 && typeof output === "object" && "case" in output ? output.case : void 0) ?? "camelCase";
|
|
1272
1264
|
if (id && (!context.config.plugins["@hey-api/sdk"] || context.config.plugins["@hey-api/sdk"].config.operations && typeof context.config.plugins["@hey-api/sdk"].config.operations !== "function" && typeof context.config.plugins["@hey-api/sdk"].config.operations === "object" && context.config.plugins["@hey-api/sdk"].config.operations.nesting === "operationId")) result = toCase(sanitizeNamespaceIdentifier(id), targetCase);
|
|
1273
|
-
else result = toCase(`${method}-${path
|
|
1265
|
+
else result = toCase(`${method}-${path.replace(/{(.*?)}/g, "by-$1").replace(/[/:+]/g, "-")}`, targetCase);
|
|
1274
1266
|
if (count > 1) result = `${result}${count}`;
|
|
1275
1267
|
if (state.ids.has(result)) return operationToId({
|
|
1276
1268
|
context,
|
|
1277
1269
|
count: count + 1,
|
|
1278
1270
|
id,
|
|
1279
1271
|
method,
|
|
1280
|
-
path
|
|
1272
|
+
path,
|
|
1281
1273
|
state
|
|
1282
1274
|
});
|
|
1283
1275
|
state.ids.set(result, createOperationKey({
|
|
1284
1276
|
method,
|
|
1285
|
-
path
|
|
1277
|
+
path
|
|
1286
1278
|
}));
|
|
1287
1279
|
return result;
|
|
1288
1280
|
}
|
|
@@ -1291,7 +1283,7 @@ function operationToId({ context, count = 1, id, method, path: path$1, state })
|
|
|
1291
1283
|
//#region src/debug/ir.ts
|
|
1292
1284
|
const indent = (level) => " ".repeat(level);
|
|
1293
1285
|
const log = (message, level) => console.log(`${indent(level ?? 0)}${message}`);
|
|
1294
|
-
const print = (ir
|
|
1286
|
+
const print = (ir, options = {}) => {
|
|
1295
1287
|
const { depth = 2, section = "all", verbosity = "summary" } = options;
|
|
1296
1288
|
const printObject = (obj, level, kind = "generic") => {
|
|
1297
1289
|
if (verbosity === "summary" && obj && typeof obj === "object") if (kind === "responses") {
|
|
@@ -1316,25 +1308,25 @@ const print = (ir$1, options = {}) => {
|
|
|
1316
1308
|
if (operation.responses) printObject(operation.responses, base + 1, "responses");
|
|
1317
1309
|
}
|
|
1318
1310
|
};
|
|
1319
|
-
const sections = section === "all" ? Object.keys(ir
|
|
1320
|
-
for (const section
|
|
1311
|
+
const sections = section === "all" ? Object.keys(ir) : [section];
|
|
1312
|
+
for (const section of sections) switch (section) {
|
|
1321
1313
|
case "components":
|
|
1322
|
-
if (ir
|
|
1323
|
-
log(`Components: ${Object.keys(ir
|
|
1324
|
-
for (const [, schema] of Object.entries(ir
|
|
1314
|
+
if (ir.components?.schemas) {
|
|
1315
|
+
log(`Components: ${Object.keys(ir.components.schemas).length} schemas`);
|
|
1316
|
+
for (const [, schema] of Object.entries(ir.components.schemas)) printObject(schema, 1, "schema");
|
|
1325
1317
|
}
|
|
1326
1318
|
break;
|
|
1327
1319
|
case "paths": {
|
|
1328
|
-
const paths = ir
|
|
1320
|
+
const paths = ir.paths || {};
|
|
1329
1321
|
log(`paths (${Object.keys(paths).length} items):`);
|
|
1330
|
-
for (const [path
|
|
1322
|
+
for (const [path, item] of Object.entries(paths)) printPathItem(path, item);
|
|
1331
1323
|
break;
|
|
1332
1324
|
}
|
|
1333
1325
|
case "servers": break;
|
|
1334
1326
|
case "webhooks": {
|
|
1335
|
-
const webhooks = ir
|
|
1327
|
+
const webhooks = ir.webhooks || {};
|
|
1336
1328
|
log(`webhooks (${Object.keys(webhooks).length} items):`);
|
|
1337
|
-
for (const [path
|
|
1329
|
+
for (const [path, item] of Object.entries(webhooks)) printPathItem(path, item);
|
|
1338
1330
|
break;
|
|
1339
1331
|
}
|
|
1340
1332
|
}
|
|
@@ -1540,8 +1532,8 @@ var MinHeap = class {
|
|
|
1540
1532
|
* is not required and the caller only wants nodes in the order they were
|
|
1541
1533
|
* added to the graph.
|
|
1542
1534
|
*/
|
|
1543
|
-
const walkDeclarations = (graph
|
|
1544
|
-
const pointers = Array.from(graph
|
|
1535
|
+
const walkDeclarations = (graph, callback, options) => {
|
|
1536
|
+
const pointers = Array.from(graph.nodes.keys());
|
|
1545
1537
|
if (options?.preferGroups && options.preferGroups.length > 0) {
|
|
1546
1538
|
const emitted = /* @__PURE__ */ new Set();
|
|
1547
1539
|
if (options.matchPointerToGroup) for (const kind of options.preferGroups) for (const pointer of pointers) {
|
|
@@ -1549,16 +1541,16 @@ const walkDeclarations = (graph$1, callback, options) => {
|
|
|
1549
1541
|
if (!result.matched) continue;
|
|
1550
1542
|
if (result.kind === kind) {
|
|
1551
1543
|
emitted.add(pointer);
|
|
1552
|
-
callback(pointer, graph
|
|
1544
|
+
callback(pointer, graph.nodes.get(pointer));
|
|
1553
1545
|
}
|
|
1554
1546
|
}
|
|
1555
1547
|
for (const pointer of pointers) {
|
|
1556
1548
|
if (emitted.has(pointer)) continue;
|
|
1557
|
-
callback(pointer, graph
|
|
1549
|
+
callback(pointer, graph.nodes.get(pointer));
|
|
1558
1550
|
}
|
|
1559
1551
|
return;
|
|
1560
1552
|
}
|
|
1561
|
-
for (const pointer of pointers) callback(pointer, graph
|
|
1553
|
+
for (const pointer of pointers) callback(pointer, graph.nodes.get(pointer));
|
|
1562
1554
|
};
|
|
1563
1555
|
/**
|
|
1564
1556
|
* Walks the nodes of the graph in topological order (dependencies before dependents).
|
|
@@ -1568,8 +1560,8 @@ const walkDeclarations = (graph$1, callback, options) => {
|
|
|
1568
1560
|
* @param graph - The dependency graph
|
|
1569
1561
|
* @param callback - Function to call for each node pointer
|
|
1570
1562
|
*/
|
|
1571
|
-
const walkTopological = (graph
|
|
1572
|
-
const pointers = Array.from(graph
|
|
1563
|
+
const walkTopological = (graph, callback, options) => {
|
|
1564
|
+
const pointers = Array.from(graph.nodes.keys());
|
|
1573
1565
|
const baseIndex = /* @__PURE__ */ new Map();
|
|
1574
1566
|
pointers.forEach((pointer, index) => baseIndex.set(pointer, index));
|
|
1575
1567
|
const declIndex = /* @__PURE__ */ new Map();
|
|
@@ -1579,11 +1571,11 @@ const walkTopological = (graph$1, callback, options) => {
|
|
|
1579
1571
|
}
|
|
1580
1572
|
const depsOf = /* @__PURE__ */ new Map();
|
|
1581
1573
|
for (const pointer of pointers) {
|
|
1582
|
-
const raw = graph
|
|
1574
|
+
const raw = graph.subtreeDependencies?.get(pointer) ?? /* @__PURE__ */ new Set();
|
|
1583
1575
|
const filtered = /* @__PURE__ */ new Set();
|
|
1584
1576
|
for (const rawPointer of raw) {
|
|
1585
1577
|
if (rawPointer === pointer) continue;
|
|
1586
|
-
if (graph
|
|
1578
|
+
if (graph.nodes.has(rawPointer)) filtered.add(rawPointer);
|
|
1587
1579
|
}
|
|
1588
1580
|
depsOf.set(pointer, filtered);
|
|
1589
1581
|
}
|
|
@@ -1650,11 +1642,11 @@ const walkTopological = (graph$1, callback, options) => {
|
|
|
1650
1642
|
return false;
|
|
1651
1643
|
})()) finalOrder = proposed;
|
|
1652
1644
|
}
|
|
1653
|
-
for (const pointer of finalOrder) callback(pointer, graph
|
|
1645
|
+
for (const pointer of finalOrder) callback(pointer, graph.nodes.get(pointer));
|
|
1654
1646
|
};
|
|
1655
|
-
const walk = (graph
|
|
1656
|
-
if (options?.order === "topological") return walkTopological(graph
|
|
1657
|
-
return walkDeclarations(graph
|
|
1647
|
+
const walk = (graph, callback, options) => {
|
|
1648
|
+
if (options?.order === "topological") return walkTopological(graph, callback, options);
|
|
1649
|
+
return walkDeclarations(graph, callback, options);
|
|
1658
1650
|
};
|
|
1659
1651
|
|
|
1660
1652
|
//#endregion
|
|
@@ -1688,9 +1680,9 @@ const matchIrPointerToGroup = (pointer, kind) => {
|
|
|
1688
1680
|
matched: true
|
|
1689
1681
|
} : { matched: false };
|
|
1690
1682
|
for (const key of Object.keys(patterns)) {
|
|
1691
|
-
const kind
|
|
1692
|
-
if (patterns[kind
|
|
1693
|
-
kind
|
|
1683
|
+
const kind = key;
|
|
1684
|
+
if (patterns[kind].test(pointer)) return {
|
|
1685
|
+
kind,
|
|
1694
1686
|
matched: true
|
|
1695
1687
|
};
|
|
1696
1688
|
}
|
|
@@ -1728,8 +1720,8 @@ const jsonPointerTilde = /~0/g;
|
|
|
1728
1720
|
* Returns the reusable component name from `$ref`.
|
|
1729
1721
|
*/
|
|
1730
1722
|
function refToName($ref) {
|
|
1731
|
-
const path
|
|
1732
|
-
const name = path
|
|
1723
|
+
const path = jsonPointerToPath($ref);
|
|
1724
|
+
const name = path[path.length - 1];
|
|
1733
1725
|
return decodeURI(name);
|
|
1734
1726
|
}
|
|
1735
1727
|
/**
|
|
@@ -1789,8 +1781,8 @@ function normalizeJsonPointer(pointer) {
|
|
|
1789
1781
|
* @param path
|
|
1790
1782
|
* @returns
|
|
1791
1783
|
*/
|
|
1792
|
-
function pathToJsonPointer(path
|
|
1793
|
-
const segments = path
|
|
1784
|
+
function pathToJsonPointer(path) {
|
|
1785
|
+
const segments = path.map(encodeJsonPointerSegment).join("/");
|
|
1794
1786
|
return "#" + (segments ? `/${segments}` : "");
|
|
1795
1787
|
}
|
|
1796
1788
|
/**
|
|
@@ -1807,15 +1799,15 @@ function pathToJsonPointer(path$1) {
|
|
|
1807
1799
|
* @returns true if the ref points to a top-level component, false otherwise
|
|
1808
1800
|
*/
|
|
1809
1801
|
function isTopLevelComponent(refOrPath) {
|
|
1810
|
-
const path
|
|
1811
|
-
if (path
|
|
1812
|
-
if (path
|
|
1802
|
+
const path = refOrPath instanceof Array ? refOrPath : jsonPointerToPath(refOrPath);
|
|
1803
|
+
if (path[0] === "components") return path.length === 3;
|
|
1804
|
+
if (path[0] === "definitions") return path.length === 2;
|
|
1813
1805
|
return false;
|
|
1814
1806
|
}
|
|
1815
1807
|
function resolveRef({ $ref, spec }) {
|
|
1816
|
-
const path
|
|
1808
|
+
const path = jsonPointerToPath(decodeURI($ref));
|
|
1817
1809
|
let current = spec;
|
|
1818
|
-
for (const part of path
|
|
1810
|
+
for (const part of path) {
|
|
1819
1811
|
const segment = part;
|
|
1820
1812
|
if (current[segment] === void 0) throw new Error(`Reference not found: ${$ref}`);
|
|
1821
1813
|
current = current[segment];
|
|
@@ -2272,10 +2264,10 @@ var IntentContext = class {
|
|
|
2272
2264
|
constructor(spec) {
|
|
2273
2265
|
this.spec = spec;
|
|
2274
2266
|
}
|
|
2275
|
-
getOperation(path
|
|
2267
|
+
getOperation(path, method) {
|
|
2276
2268
|
const paths = this.spec.paths;
|
|
2277
2269
|
if (!paths) return;
|
|
2278
|
-
return paths[path
|
|
2270
|
+
return paths[path]?.[method];
|
|
2279
2271
|
}
|
|
2280
2272
|
setExample(operation, example) {
|
|
2281
2273
|
const source = this.getOperation(operation.path, operation.method);
|
|
@@ -2298,11 +2290,11 @@ function createSchemaProcessor() {
|
|
|
2298
2290
|
tags: contextTags
|
|
2299
2291
|
};
|
|
2300
2292
|
},
|
|
2301
|
-
hasEmitted(path
|
|
2302
|
-
return emitted.has(pathToJsonPointer(path
|
|
2293
|
+
hasEmitted(path) {
|
|
2294
|
+
return emitted.has(pathToJsonPointer(path));
|
|
2303
2295
|
},
|
|
2304
|
-
markEmitted(path
|
|
2305
|
-
const pointer = pathToJsonPointer(path
|
|
2296
|
+
markEmitted(path) {
|
|
2297
|
+
const pointer = pathToJsonPointer(path);
|
|
2306
2298
|
if (emitted.has(pointer)) return false;
|
|
2307
2299
|
emitted.add(pointer);
|
|
2308
2300
|
return true;
|
|
@@ -2333,21 +2325,21 @@ function createSchemaProcessor() {
|
|
|
2333
2325
|
* - Path tracking for child schemas
|
|
2334
2326
|
*/
|
|
2335
2327
|
function createSchemaWalker(visitor) {
|
|
2336
|
-
const walk
|
|
2328
|
+
const walk = (schema, ctx) => {
|
|
2337
2329
|
if (visitor.intercept) {
|
|
2338
|
-
const intercepted = visitor.intercept(schema, ctx, walk
|
|
2330
|
+
const intercepted = visitor.intercept(schema, ctx, walk);
|
|
2339
2331
|
if (intercepted !== void 0) return intercepted;
|
|
2340
2332
|
}
|
|
2341
2333
|
if (schema.$ref) return visitor.reference(schema.$ref, schema, ctx);
|
|
2342
2334
|
if (schema.type) {
|
|
2343
|
-
let result = visitTyped(schema, ctx, visitor, walk
|
|
2335
|
+
let result = visitTyped(schema, ctx, visitor, walk);
|
|
2344
2336
|
if (visitor.postProcess) result = visitor.postProcess(result, schema, ctx);
|
|
2345
2337
|
return result;
|
|
2346
2338
|
}
|
|
2347
2339
|
if (schema.items) {
|
|
2348
2340
|
const deduplicated = deduplicateSchema({ schema });
|
|
2349
|
-
if (!deduplicated.items) return walk
|
|
2350
|
-
const itemResults = deduplicated.items.map((item, index) => walk
|
|
2341
|
+
if (!deduplicated.items) return walk(deduplicated, ctx);
|
|
2342
|
+
const itemResults = deduplicated.items.map((item, index) => walk(item, {
|
|
2351
2343
|
...ctx,
|
|
2352
2344
|
path: ref([
|
|
2353
2345
|
...fromRef(ctx.path),
|
|
@@ -2359,23 +2351,23 @@ function createSchemaWalker(visitor) {
|
|
|
2359
2351
|
}
|
|
2360
2352
|
return visitor.unknown({ type: "unknown" }, ctx);
|
|
2361
2353
|
};
|
|
2362
|
-
return walk
|
|
2354
|
+
return walk;
|
|
2363
2355
|
}
|
|
2364
2356
|
/**
|
|
2365
2357
|
* Dispatch to the appropriate visitor method based on schema type.
|
|
2366
2358
|
*/
|
|
2367
|
-
function visitTyped(schema, ctx, visitor, walk
|
|
2359
|
+
function visitTyped(schema, ctx, visitor, walk) {
|
|
2368
2360
|
switch (schema.type) {
|
|
2369
|
-
case "array": return visitor.array(schema, ctx, walk
|
|
2361
|
+
case "array": return visitor.array(schema, ctx, walk);
|
|
2370
2362
|
case "boolean": return visitor.boolean(schema, ctx);
|
|
2371
|
-
case "enum": return visitor.enum(schema, ctx, walk
|
|
2363
|
+
case "enum": return visitor.enum(schema, ctx, walk);
|
|
2372
2364
|
case "integer": return visitor.integer(schema, ctx);
|
|
2373
2365
|
case "never": return visitor.never(schema, ctx);
|
|
2374
2366
|
case "null": return visitor.null(schema, ctx);
|
|
2375
2367
|
case "number": return visitor.number(schema, ctx);
|
|
2376
|
-
case "object": return visitor.object(schema, ctx, walk
|
|
2368
|
+
case "object": return visitor.object(schema, ctx, walk);
|
|
2377
2369
|
case "string": return visitor.string(schema, ctx);
|
|
2378
|
-
case "tuple": return visitor.tuple(schema, ctx, walk
|
|
2370
|
+
case "tuple": return visitor.tuple(schema, ctx, walk);
|
|
2379
2371
|
case "undefined": return visitor.undefined(schema, ctx);
|
|
2380
2372
|
case "unknown": return visitor.unknown(schema, ctx);
|
|
2381
2373
|
case "void": return visitor.void(schema, ctx);
|
|
@@ -2394,7 +2386,7 @@ function childContext(ctx, ...segments) {
|
|
|
2394
2386
|
//#endregion
|
|
2395
2387
|
//#region src/openApi/shared/utils/filter.ts
|
|
2396
2388
|
const namespaceNeedle = "/";
|
|
2397
|
-
const addNamespace = (namespace
|
|
2389
|
+
const addNamespace = (namespace, value = "") => `${namespace}${namespaceNeedle}${value}`;
|
|
2398
2390
|
const removeNamespace = (key) => {
|
|
2399
2391
|
const index = key.indexOf(namespaceNeedle);
|
|
2400
2392
|
return {
|
|
@@ -2429,13 +2421,13 @@ const createFiltersSetAndRegExps = (type, filters) => {
|
|
|
2429
2421
|
};
|
|
2430
2422
|
const collectFiltersSetFromRegExpsOpenApiV2 = ({ excludeOperations, excludeSchemas, includeOperations, includeSchemas, spec }) => {
|
|
2431
2423
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2432
|
-
const path
|
|
2424
|
+
const path = entry[0];
|
|
2433
2425
|
const pathItem = entry[1];
|
|
2434
2426
|
for (const method of httpMethods) {
|
|
2435
2427
|
if (!pathItem[method]) continue;
|
|
2436
2428
|
const key = createOperationKey({
|
|
2437
2429
|
method,
|
|
2438
|
-
path
|
|
2430
|
+
path
|
|
2439
2431
|
});
|
|
2440
2432
|
if (excludeOperations.regexps.some((regexp) => regexp.test(key))) excludeOperations.set.add(addNamespace("operation", key));
|
|
2441
2433
|
if (includeOperations.regexps.some((regexp) => regexp.test(key))) includeOperations.set.add(addNamespace("operation", key));
|
|
@@ -2450,13 +2442,13 @@ const collectFiltersSetFromRegExpsOpenApiV2 = ({ excludeOperations, excludeSchem
|
|
|
2450
2442
|
};
|
|
2451
2443
|
const collectFiltersSetFromRegExpsOpenApiV3 = ({ excludeOperations, excludeParameters, excludeRequestBodies, excludeResponses, excludeSchemas, includeOperations, includeParameters, includeRequestBodies, includeResponses, includeSchemas, spec }) => {
|
|
2452
2444
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2453
|
-
const path
|
|
2445
|
+
const path = entry[0];
|
|
2454
2446
|
const pathItem = entry[1];
|
|
2455
2447
|
for (const method of httpMethods) {
|
|
2456
2448
|
if (!pathItem[method]) continue;
|
|
2457
2449
|
const key = createOperationKey({
|
|
2458
2450
|
method,
|
|
2459
|
-
path
|
|
2451
|
+
path
|
|
2460
2452
|
});
|
|
2461
2453
|
if (excludeOperations.regexps.some((regexp) => regexp.test(key))) excludeOperations.set.add(addNamespace("operation", key));
|
|
2462
2454
|
if (includeOperations.regexps.some((regexp) => regexp.test(key))) includeOperations.set.add(addNamespace("operation", key));
|
|
@@ -2568,8 +2560,8 @@ const collectOperations = ({ filters, parameters, requestBodies, resourceMetadat
|
|
|
2568
2560
|
if (filters.tags.exclude.size && node.tags.size && [...filters.tags.exclude].some((tag) => node.tags.has(tag))) continue;
|
|
2569
2561
|
if (filters.tags.include.size && !new Set([...filters.tags.include].filter((tag) => node.tags.has(tag))).size) continue;
|
|
2570
2562
|
if ([...node.dependencies].some((dependency) => {
|
|
2571
|
-
const { namespace
|
|
2572
|
-
switch (namespace
|
|
2563
|
+
const { namespace } = removeNamespace(dependency);
|
|
2564
|
+
switch (namespace) {
|
|
2573
2565
|
case "body": return !requestBodies.has(dependency);
|
|
2574
2566
|
case "parameter": return !parameters.has(dependency);
|
|
2575
2567
|
case "response": return !responses.has(dependency);
|
|
@@ -2596,8 +2588,8 @@ const collectParameters = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2596
2588
|
finalSet.add(key);
|
|
2597
2589
|
if (!node.dependencies.size) continue;
|
|
2598
2590
|
for (const dependency of node.dependencies) {
|
|
2599
|
-
const { namespace
|
|
2600
|
-
switch (namespace
|
|
2591
|
+
const { namespace } = removeNamespace(dependency);
|
|
2592
|
+
switch (namespace) {
|
|
2601
2593
|
case "body":
|
|
2602
2594
|
if (filters.requestBodies.exclude.has(dependency)) finalSet.delete(key);
|
|
2603
2595
|
else if (!finalSet.has(dependency)) stack.push(dependency);
|
|
@@ -2626,8 +2618,8 @@ const collectRequestBodies = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2626
2618
|
finalSet.add(key);
|
|
2627
2619
|
if (!node.dependencies.size) continue;
|
|
2628
2620
|
for (const dependency of node.dependencies) {
|
|
2629
|
-
const { namespace
|
|
2630
|
-
switch (namespace
|
|
2621
|
+
const { namespace } = removeNamespace(dependency);
|
|
2622
|
+
switch (namespace) {
|
|
2631
2623
|
case "body":
|
|
2632
2624
|
if (filters.requestBodies.exclude.has(dependency)) finalSet.delete(key);
|
|
2633
2625
|
else if (!finalSet.has(dependency)) stack.push(dependency);
|
|
@@ -2656,8 +2648,8 @@ const collectResponses = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2656
2648
|
finalSet.add(key);
|
|
2657
2649
|
if (!node.dependencies.size) continue;
|
|
2658
2650
|
for (const dependency of node.dependencies) {
|
|
2659
|
-
const { namespace
|
|
2660
|
-
switch (namespace
|
|
2651
|
+
const { namespace } = removeNamespace(dependency);
|
|
2652
|
+
switch (namespace) {
|
|
2661
2653
|
case "body":
|
|
2662
2654
|
if (filters.requestBodies.exclude.has(dependency)) finalSet.delete(key);
|
|
2663
2655
|
else if (!finalSet.has(dependency)) stack.push(dependency);
|
|
@@ -2686,8 +2678,8 @@ const collectSchemas = ({ filters, resourceMetadata }) => {
|
|
|
2686
2678
|
finalSet.add(key);
|
|
2687
2679
|
if (!node.dependencies.size) continue;
|
|
2688
2680
|
for (const dependency of node.dependencies) {
|
|
2689
|
-
const { namespace
|
|
2690
|
-
switch (namespace
|
|
2681
|
+
const { namespace } = removeNamespace(dependency);
|
|
2682
|
+
switch (namespace) {
|
|
2691
2683
|
case "schema":
|
|
2692
2684
|
if (!finalSet.has(dependency) && !filters.schemas.exclude.has(dependency)) stack.push(dependency);
|
|
2693
2685
|
break;
|
|
@@ -2765,13 +2757,13 @@ const collectOperationDependencies = ({ operations, resourceMetadata }) => {
|
|
|
2765
2757
|
const key = stack.pop();
|
|
2766
2758
|
if (finalSet.has(key)) continue;
|
|
2767
2759
|
finalSet.add(key);
|
|
2768
|
-
const { namespace
|
|
2760
|
+
const { namespace } = removeNamespace(key);
|
|
2769
2761
|
let dependencies;
|
|
2770
|
-
if (namespace
|
|
2771
|
-
else if (namespace
|
|
2772
|
-
else if (namespace
|
|
2773
|
-
else if (namespace
|
|
2774
|
-
else if (namespace
|
|
2762
|
+
if (namespace === "body") dependencies = resourceMetadata.requestBodies.get(key)?.dependencies;
|
|
2763
|
+
else if (namespace === "operation") dependencies = resourceMetadata.operations.get(key)?.dependencies;
|
|
2764
|
+
else if (namespace === "parameter") dependencies = resourceMetadata.parameters.get(key)?.dependencies;
|
|
2765
|
+
else if (namespace === "response") dependencies = resourceMetadata.responses.get(key)?.dependencies;
|
|
2766
|
+
else if (namespace === "schema") dependencies = resourceMetadata.schemas.get(key)?.dependencies;
|
|
2775
2767
|
if (!dependencies?.size) continue;
|
|
2776
2768
|
for (const dependency of dependencies) if (!finalSet.has(dependency)) stack.push(dependency);
|
|
2777
2769
|
}
|
|
@@ -2855,7 +2847,7 @@ const createFilteredDependencies = ({ filters, logger, resourceMetadata }) => {
|
|
|
2855
2847
|
* Builds a resource metadata map from a Graph, matching the old Graph interface
|
|
2856
2848
|
* for compatibility with filtering code.
|
|
2857
2849
|
*/
|
|
2858
|
-
const buildResourceMetadata = (graph
|
|
2850
|
+
const buildResourceMetadata = (graph, logger) => {
|
|
2859
2851
|
const eventBuildResourceMetadata = logger.timeEvent("build-resource-metadata");
|
|
2860
2852
|
const resourceMetadata = {
|
|
2861
2853
|
operations: /* @__PURE__ */ new Map(),
|
|
@@ -2866,43 +2858,43 @@ const buildResourceMetadata = (graph$1, logger) => {
|
|
|
2866
2858
|
};
|
|
2867
2859
|
const getDependencies = (pointer) => {
|
|
2868
2860
|
const dependencies = /* @__PURE__ */ new Set();
|
|
2869
|
-
const nodeDependencies = graph
|
|
2861
|
+
const nodeDependencies = graph.transitiveDependencies.get(pointer);
|
|
2870
2862
|
if (nodeDependencies?.size) for (const dependency of nodeDependencies) {
|
|
2871
|
-
const path
|
|
2872
|
-
const type = path
|
|
2873
|
-
const name = path
|
|
2863
|
+
const path = jsonPointerToPath(dependency);
|
|
2864
|
+
const type = path[path.length - 2];
|
|
2865
|
+
const name = path[path.length - 1];
|
|
2874
2866
|
if (type && name) {
|
|
2875
|
-
const namespace
|
|
2876
|
-
if (namespace
|
|
2877
|
-
dependencies.add(addNamespace(namespace
|
|
2867
|
+
const namespace = stringToNamespace(type);
|
|
2868
|
+
if (namespace === "unknown") console.warn(`unsupported type: ${type}`);
|
|
2869
|
+
dependencies.add(addNamespace(namespace, name));
|
|
2878
2870
|
}
|
|
2879
2871
|
}
|
|
2880
2872
|
return dependencies;
|
|
2881
2873
|
};
|
|
2882
|
-
for (const [pointer, nodeInfo] of graph
|
|
2883
|
-
const path
|
|
2884
|
-
if (path
|
|
2885
|
-
if (path
|
|
2886
|
-
if (path
|
|
2887
|
-
const name = path
|
|
2874
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
2875
|
+
const path = jsonPointerToPath(pointer);
|
|
2876
|
+
if (path[0] === "components") {
|
|
2877
|
+
if (path.length === 3) {
|
|
2878
|
+
if (path[1] === "schemas") {
|
|
2879
|
+
const name = path[path.length - 1];
|
|
2888
2880
|
resourceMetadata.schemas.set(addNamespace("schema", name), {
|
|
2889
2881
|
dependencies: getDependencies(pointer),
|
|
2890
2882
|
deprecated: nodeInfo.deprecated ?? false
|
|
2891
2883
|
});
|
|
2892
|
-
} else if (path
|
|
2893
|
-
const name = path
|
|
2884
|
+
} else if (path[1] === "parameters") {
|
|
2885
|
+
const name = path[path.length - 1];
|
|
2894
2886
|
resourceMetadata.parameters.set(addNamespace("parameter", name), {
|
|
2895
2887
|
dependencies: getDependencies(pointer),
|
|
2896
2888
|
deprecated: nodeInfo.deprecated ?? false
|
|
2897
2889
|
});
|
|
2898
|
-
} else if (path
|
|
2899
|
-
const name = path
|
|
2890
|
+
} else if (path[1] === "requestBodies") {
|
|
2891
|
+
const name = path[path.length - 1];
|
|
2900
2892
|
resourceMetadata.requestBodies.set(addNamespace("body", name), {
|
|
2901
2893
|
dependencies: getDependencies(pointer),
|
|
2902
2894
|
deprecated: nodeInfo.deprecated ?? false
|
|
2903
2895
|
});
|
|
2904
|
-
} else if (path
|
|
2905
|
-
const name = path
|
|
2896
|
+
} else if (path[1] === "responses") {
|
|
2897
|
+
const name = path[path.length - 1];
|
|
2906
2898
|
resourceMetadata.responses.set(addNamespace("response", name), {
|
|
2907
2899
|
dependencies: getDependencies(pointer),
|
|
2908
2900
|
deprecated: nodeInfo.deprecated ?? false
|
|
@@ -2911,12 +2903,12 @@ const buildResourceMetadata = (graph$1, logger) => {
|
|
|
2911
2903
|
}
|
|
2912
2904
|
continue;
|
|
2913
2905
|
}
|
|
2914
|
-
if (path
|
|
2915
|
-
if (path
|
|
2916
|
-
const method = path
|
|
2906
|
+
if (path[0] === "paths") {
|
|
2907
|
+
if (path.length === 3 && httpMethods.includes(path[2])) {
|
|
2908
|
+
const method = path[path.length - 1];
|
|
2917
2909
|
const operationKey = createOperationKey({
|
|
2918
2910
|
method,
|
|
2919
|
-
path: path
|
|
2911
|
+
path: path.slice(1, -1).join("/")
|
|
2920
2912
|
});
|
|
2921
2913
|
resourceMetadata.operations.set(addNamespace("operation", operationKey), {
|
|
2922
2914
|
dependencies: getDependencies(pointer),
|
|
@@ -2926,9 +2918,9 @@ const buildResourceMetadata = (graph$1, logger) => {
|
|
|
2926
2918
|
}
|
|
2927
2919
|
continue;
|
|
2928
2920
|
}
|
|
2929
|
-
if (path
|
|
2930
|
-
if (path
|
|
2931
|
-
const name = path
|
|
2921
|
+
if (path[0] === "definitions") {
|
|
2922
|
+
if (path.length === 2) {
|
|
2923
|
+
const name = path[path.length - 1];
|
|
2932
2924
|
resourceMetadata.schemas.set(addNamespace("schema", name), {
|
|
2933
2925
|
dependencies: getDependencies(pointer),
|
|
2934
2926
|
deprecated: nodeInfo.deprecated ?? false
|
|
@@ -2997,7 +2989,7 @@ const getUniqueComponentName = ({ base, components, extraComponents }) => {
|
|
|
2997
2989
|
}
|
|
2998
2990
|
return name;
|
|
2999
2991
|
};
|
|
3000
|
-
const isPathRootSchema = (path
|
|
2992
|
+
const isPathRootSchema = (path) => path.length === 3 && path[0] === "components" && path[1] === "schemas" || path.length === 2 && path[0] === "definitions";
|
|
3001
2993
|
const specToSchemasPointerNamespace = (spec) => {
|
|
3002
2994
|
if (spec && typeof spec === "object") {
|
|
3003
2995
|
if ("swagger" in spec) return "#/definitions/";
|
|
@@ -3034,21 +3026,21 @@ const getEnumSignature = (schema) => {
|
|
|
3034
3026
|
* @param path - The path to the current node
|
|
3035
3027
|
* @param visitor - Function to call for each visited node
|
|
3036
3028
|
*/
|
|
3037
|
-
const walkSchemas$1 = ({ key, node, parent, path
|
|
3029
|
+
const walkSchemas$1 = ({ key, node, parent, path, visitor }) => {
|
|
3038
3030
|
if (!node || typeof node !== "object" || node instanceof Array) return;
|
|
3039
3031
|
const value = node;
|
|
3040
3032
|
if ("type" in value || "enum" in value || childSchemaRelationships.some(([keyword]) => keyword in value)) visitor({
|
|
3041
3033
|
key,
|
|
3042
3034
|
node,
|
|
3043
3035
|
parent,
|
|
3044
|
-
path
|
|
3036
|
+
path
|
|
3045
3037
|
});
|
|
3046
3038
|
for (const [k, v] of Object.entries(value)) if (typeof v === "object" && v !== null) if (v instanceof Array) v.forEach((item, index) => walkSchemas$1({
|
|
3047
3039
|
key: index,
|
|
3048
3040
|
node: item,
|
|
3049
3041
|
parent: v,
|
|
3050
3042
|
path: [
|
|
3051
|
-
...path
|
|
3043
|
+
...path,
|
|
3052
3044
|
k,
|
|
3053
3045
|
index
|
|
3054
3046
|
],
|
|
@@ -3058,7 +3050,7 @@ const walkSchemas$1 = ({ key, node, parent, path: path$1, visitor }) => {
|
|
|
3058
3050
|
key: k,
|
|
3059
3051
|
node: v,
|
|
3060
3052
|
parent: node,
|
|
3061
|
-
path: [...path
|
|
3053
|
+
path: [...path, k],
|
|
3062
3054
|
visitor
|
|
3063
3055
|
});
|
|
3064
3056
|
};
|
|
@@ -3083,8 +3075,8 @@ const inlineMode = ({ spec }) => {
|
|
|
3083
3075
|
};
|
|
3084
3076
|
replaceEnumRefs(spec);
|
|
3085
3077
|
for (const pointer of Object.keys(rootEnums)) {
|
|
3086
|
-
const path
|
|
3087
|
-
const name = path
|
|
3078
|
+
const path = jsonPointerToPath(pointer);
|
|
3079
|
+
const name = path[path.length - 1];
|
|
3088
3080
|
if (name) delete schemasObj[name];
|
|
3089
3081
|
}
|
|
3090
3082
|
};
|
|
@@ -3182,21 +3174,21 @@ const enumsTransform = ({ config, spec }) => {
|
|
|
3182
3174
|
* @param path - The path to the current node
|
|
3183
3175
|
* @param visitor - Function to call for each visited node
|
|
3184
3176
|
*/
|
|
3185
|
-
const walkSchemas = ({ key, node, parent, path
|
|
3177
|
+
const walkSchemas = ({ key, node, parent, path, visitor }) => {
|
|
3186
3178
|
if (!node || typeof node !== "object" || node instanceof Array) return;
|
|
3187
3179
|
const value = node;
|
|
3188
3180
|
if ("type" in value || childSchemaRelationships.some(([keyword]) => keyword in value)) visitor({
|
|
3189
3181
|
key,
|
|
3190
3182
|
node,
|
|
3191
3183
|
parent,
|
|
3192
|
-
path
|
|
3184
|
+
path
|
|
3193
3185
|
});
|
|
3194
3186
|
for (const [k, v] of Object.entries(value)) if (typeof v === "object" && v !== null) if (v instanceof Array) v.forEach((item, index) => walkSchemas({
|
|
3195
3187
|
key: index,
|
|
3196
3188
|
node: item,
|
|
3197
3189
|
parent: v,
|
|
3198
3190
|
path: [
|
|
3199
|
-
...path
|
|
3191
|
+
...path,
|
|
3200
3192
|
k,
|
|
3201
3193
|
index
|
|
3202
3194
|
],
|
|
@@ -3206,7 +3198,7 @@ const walkSchemas = ({ key, node, parent, path: path$1, visitor }) => {
|
|
|
3206
3198
|
key: k,
|
|
3207
3199
|
node: v,
|
|
3208
3200
|
parent: node,
|
|
3209
|
-
path: [...path
|
|
3201
|
+
path: [...path, k],
|
|
3210
3202
|
visitor
|
|
3211
3203
|
});
|
|
3212
3204
|
};
|
|
@@ -3257,7 +3249,6 @@ const deepEqual = (a, b) => {
|
|
|
3257
3249
|
for (const key of keysA) if (!deepEqual(objA[key], objB[key])) return false;
|
|
3258
3250
|
return true;
|
|
3259
3251
|
};
|
|
3260
|
-
var deepEqual_default = deepEqual;
|
|
3261
3252
|
|
|
3262
3253
|
//#endregion
|
|
3263
3254
|
//#region src/openApi/shared/utils/graph.ts
|
|
@@ -3279,7 +3270,7 @@ const annotateChildScopes = (nodes) => {
|
|
|
3279
3270
|
/**
|
|
3280
3271
|
* Recursively collects all $ref dependencies in the subtree rooted at `pointer`.
|
|
3281
3272
|
*/
|
|
3282
|
-
const collectPointerDependencies = ({ cache, graph
|
|
3273
|
+
const collectPointerDependencies = ({ cache, graph, pointer, visited }) => {
|
|
3283
3274
|
const cached = cache.transitiveDependencies.get(pointer);
|
|
3284
3275
|
if (cached) return {
|
|
3285
3276
|
subtreeDependencies: cache.subtreeDependencies.get(pointer),
|
|
@@ -3290,19 +3281,19 @@ const collectPointerDependencies = ({ cache, graph: graph$1, pointer, visited })
|
|
|
3290
3281
|
transitiveDependencies: /* @__PURE__ */ new Set()
|
|
3291
3282
|
};
|
|
3292
3283
|
visited.add(pointer);
|
|
3293
|
-
if (!graph
|
|
3284
|
+
if (!graph.nodes.get(pointer)) return {
|
|
3294
3285
|
subtreeDependencies: /* @__PURE__ */ new Set(),
|
|
3295
3286
|
transitiveDependencies: /* @__PURE__ */ new Set()
|
|
3296
3287
|
};
|
|
3297
3288
|
const transitiveDependencies = /* @__PURE__ */ new Set();
|
|
3298
3289
|
const subtreeDependencies = /* @__PURE__ */ new Set();
|
|
3299
|
-
const nodeDependencies = graph
|
|
3290
|
+
const nodeDependencies = graph.nodeDependencies.get(pointer);
|
|
3300
3291
|
if (nodeDependencies) for (const depPointer of nodeDependencies) {
|
|
3301
3292
|
transitiveDependencies.add(depPointer);
|
|
3302
3293
|
subtreeDependencies.add(depPointer);
|
|
3303
3294
|
const depResult = collectPointerDependencies({
|
|
3304
3295
|
cache,
|
|
3305
|
-
graph
|
|
3296
|
+
graph,
|
|
3306
3297
|
pointer: depPointer,
|
|
3307
3298
|
visited
|
|
3308
3299
|
});
|
|
@@ -3317,7 +3308,7 @@ const collectPointerDependencies = ({ cache, graph: graph$1, pointer, visited })
|
|
|
3317
3308
|
if (!childResult.subtreeDependencies || !childResult.transitiveDependencies) {
|
|
3318
3309
|
childResult = collectPointerDependencies({
|
|
3319
3310
|
cache,
|
|
3320
|
-
graph
|
|
3311
|
+
graph,
|
|
3321
3312
|
pointer: childPointer,
|
|
3322
3313
|
visited
|
|
3323
3314
|
});
|
|
@@ -3346,8 +3337,8 @@ const collectPointerDependencies = ({ cache, graph: graph$1, pointer, visited })
|
|
|
3346
3337
|
*
|
|
3347
3338
|
* @param graph - The Graph structure containing nodes, dependencies, and reverseNodeDependencies.
|
|
3348
3339
|
*/
|
|
3349
|
-
const propagateScopes = (graph
|
|
3350
|
-
const worklist = new Set(Array.from(graph
|
|
3340
|
+
const propagateScopes = (graph) => {
|
|
3341
|
+
const worklist = new Set(Array.from(graph.nodes.entries()).filter(([, nodeInfo]) => nodeInfo.scopes && nodeInfo.scopes.size > 0).map(([pointer]) => pointer));
|
|
3351
3342
|
/**
|
|
3352
3343
|
* Notifies all dependents of a node that its scopes may have changed.
|
|
3353
3344
|
* Dependents include:
|
|
@@ -3361,7 +3352,7 @@ const propagateScopes = (graph$1) => {
|
|
|
3361
3352
|
*/
|
|
3362
3353
|
const notifyAllDependents = (pointer, nodeInfo, childPointer) => {
|
|
3363
3354
|
if (nodeInfo.parentPointer) worklist.add(nodeInfo.parentPointer);
|
|
3364
|
-
const reverseNodeDependencies = graph
|
|
3355
|
+
const reverseNodeDependencies = graph.reverseNodeDependencies.get(pointer);
|
|
3365
3356
|
if (reverseNodeDependencies) for (const dependentPointer of reverseNodeDependencies) worklist.add(dependentPointer);
|
|
3366
3357
|
if (childPointer) {
|
|
3367
3358
|
const combinatorChildMatch = childPointer.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);
|
|
@@ -3381,14 +3372,14 @@ const propagateScopes = (graph$1) => {
|
|
|
3381
3372
|
*/
|
|
3382
3373
|
const propagateChildScopes = (pointer, nodeInfo, childPointer) => {
|
|
3383
3374
|
if (!nodeInfo?.scopes) return;
|
|
3384
|
-
const childInfo = graph
|
|
3375
|
+
const childInfo = graph.nodes.get(childPointer);
|
|
3385
3376
|
if (!childInfo?.scopes) return;
|
|
3386
3377
|
if (propagateScopesToNode(childInfo, nodeInfo)) notifyAllDependents(pointer, nodeInfo, childPointer);
|
|
3387
3378
|
};
|
|
3388
3379
|
while (worklist.size > 0) {
|
|
3389
3380
|
const pointer = worklist.values().next().value;
|
|
3390
3381
|
worklist.delete(pointer);
|
|
3391
|
-
const nodeInfo = graph
|
|
3382
|
+
const nodeInfo = graph.nodes.get(pointer);
|
|
3392
3383
|
if (!nodeInfo) continue;
|
|
3393
3384
|
if (!nodeInfo.scopes) nodeInfo.scopes = /* @__PURE__ */ new Set();
|
|
3394
3385
|
const node = nodeInfo.node;
|
|
@@ -3403,15 +3394,15 @@ const propagateScopes = (graph$1) => {
|
|
|
3403
3394
|
else if (typeof value === "object" && value !== null) propagateChildScopes(pointer, nodeInfo, `${pointer}/${keyword}`);
|
|
3404
3395
|
}
|
|
3405
3396
|
}
|
|
3406
|
-
const nodeDependencies = graph
|
|
3397
|
+
const nodeDependencies = graph.nodeDependencies.get(pointer);
|
|
3407
3398
|
if (nodeDependencies) for (const depPointer of nodeDependencies) {
|
|
3408
|
-
const depNode = graph
|
|
3399
|
+
const depNode = graph.nodes.get(depPointer);
|
|
3409
3400
|
if (depNode?.scopes) {
|
|
3410
3401
|
if (propagateScopesToNode(depNode, nodeInfo)) notifyAllDependents(pointer, nodeInfo);
|
|
3411
3402
|
}
|
|
3412
3403
|
}
|
|
3413
3404
|
if (nodeInfo.parentPointer) {
|
|
3414
|
-
const parentInfo = graph
|
|
3405
|
+
const parentInfo = graph.nodes.get(nodeInfo.parentPointer);
|
|
3415
3406
|
if (parentInfo) {
|
|
3416
3407
|
if (propagateScopesToNode(nodeInfo, parentInfo)) notifyAllDependents(nodeInfo.parentPointer, parentInfo);
|
|
3417
3408
|
}
|
|
@@ -3474,48 +3465,48 @@ const seedLocalScopes = (nodes) => {
|
|
|
3474
3465
|
*/
|
|
3475
3466
|
function buildGraph(root, logger) {
|
|
3476
3467
|
const eventBuildGraph = logger.timeEvent("build-graph");
|
|
3477
|
-
const graph
|
|
3468
|
+
const graph = {
|
|
3478
3469
|
nodeDependencies: /* @__PURE__ */ new Map(),
|
|
3479
3470
|
nodes: /* @__PURE__ */ new Map(),
|
|
3480
3471
|
reverseNodeDependencies: /* @__PURE__ */ new Map(),
|
|
3481
3472
|
subtreeDependencies: /* @__PURE__ */ new Map(),
|
|
3482
3473
|
transitiveDependencies: /* @__PURE__ */ new Map()
|
|
3483
3474
|
};
|
|
3484
|
-
const walk
|
|
3475
|
+
const walk = ({ key, node, parentPointer, path }) => {
|
|
3485
3476
|
if (typeof node !== "object" || node === null) return;
|
|
3486
|
-
const pointer = pathToJsonPointer(path
|
|
3477
|
+
const pointer = pathToJsonPointer(path);
|
|
3487
3478
|
let deprecated;
|
|
3488
3479
|
let tags;
|
|
3489
3480
|
if (typeof node === "object" && node !== null) {
|
|
3490
3481
|
if ("deprecated" in node && typeof node.deprecated === "boolean") deprecated = Boolean(node.deprecated);
|
|
3491
3482
|
if ("$ref" in node && typeof node.$ref === "string") {
|
|
3492
3483
|
const refPointer = normalizeJsonPointer(node.$ref);
|
|
3493
|
-
if (!graph
|
|
3494
|
-
graph
|
|
3484
|
+
if (!graph.nodeDependencies.has(pointer)) graph.nodeDependencies.set(pointer, /* @__PURE__ */ new Set());
|
|
3485
|
+
graph.nodeDependencies.get(pointer).add(refPointer);
|
|
3495
3486
|
}
|
|
3496
3487
|
if ("tags" in node && node.tags instanceof Array) tags = new Set(node.tags.filter((tag) => typeof tag === "string"));
|
|
3497
3488
|
}
|
|
3498
|
-
graph
|
|
3489
|
+
graph.nodes.set(pointer, {
|
|
3499
3490
|
deprecated,
|
|
3500
3491
|
key,
|
|
3501
3492
|
node,
|
|
3502
3493
|
parentPointer,
|
|
3503
3494
|
tags
|
|
3504
3495
|
});
|
|
3505
|
-
if (node instanceof Array) node.forEach((item, index) => walk
|
|
3496
|
+
if (node instanceof Array) node.forEach((item, index) => walk({
|
|
3506
3497
|
key: index,
|
|
3507
3498
|
node: item,
|
|
3508
3499
|
parentPointer: pointer,
|
|
3509
|
-
path: [...path
|
|
3500
|
+
path: [...path, index]
|
|
3510
3501
|
}));
|
|
3511
|
-
else for (const [childKey, value] of Object.entries(node)) walk
|
|
3502
|
+
else for (const [childKey, value] of Object.entries(node)) walk({
|
|
3512
3503
|
key: childKey,
|
|
3513
3504
|
node: value,
|
|
3514
3505
|
parentPointer: pointer,
|
|
3515
|
-
path: [...path
|
|
3506
|
+
path: [...path, childKey]
|
|
3516
3507
|
});
|
|
3517
3508
|
};
|
|
3518
|
-
walk
|
|
3509
|
+
walk({
|
|
3519
3510
|
key: null,
|
|
3520
3511
|
node: root,
|
|
3521
3512
|
parentPointer: null,
|
|
@@ -3526,31 +3517,31 @@ function buildGraph(root, logger) {
|
|
|
3526
3517
|
subtreeDependencies: /* @__PURE__ */ new Map(),
|
|
3527
3518
|
transitiveDependencies: /* @__PURE__ */ new Map()
|
|
3528
3519
|
};
|
|
3529
|
-
for (const [pointer, nodeInfo] of graph
|
|
3520
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
3530
3521
|
const parent = nodeInfo.parentPointer;
|
|
3531
3522
|
if (!parent) continue;
|
|
3532
3523
|
if (!cache.parentToChildren.has(parent)) cache.parentToChildren.set(parent, []);
|
|
3533
3524
|
cache.parentToChildren.get(parent).push(pointer);
|
|
3534
3525
|
}
|
|
3535
|
-
for (const [pointerFrom, pointers] of graph
|
|
3536
|
-
if (!graph
|
|
3537
|
-
graph
|
|
3526
|
+
for (const [pointerFrom, pointers] of graph.nodeDependencies) for (const pointerTo of pointers) {
|
|
3527
|
+
if (!graph.reverseNodeDependencies.has(pointerTo)) graph.reverseNodeDependencies.set(pointerTo, /* @__PURE__ */ new Set());
|
|
3528
|
+
graph.reverseNodeDependencies.get(pointerTo).add(pointerFrom);
|
|
3538
3529
|
}
|
|
3539
|
-
seedLocalScopes(graph
|
|
3540
|
-
propagateScopes(graph
|
|
3541
|
-
annotateChildScopes(graph
|
|
3542
|
-
for (const pointer of graph
|
|
3530
|
+
seedLocalScopes(graph.nodes);
|
|
3531
|
+
propagateScopes(graph);
|
|
3532
|
+
annotateChildScopes(graph.nodes);
|
|
3533
|
+
for (const pointer of graph.nodes.keys()) {
|
|
3543
3534
|
const result = collectPointerDependencies({
|
|
3544
3535
|
cache,
|
|
3545
|
-
graph
|
|
3536
|
+
graph,
|
|
3546
3537
|
pointer,
|
|
3547
3538
|
visited: /* @__PURE__ */ new Set()
|
|
3548
3539
|
});
|
|
3549
|
-
graph
|
|
3550
|
-
graph
|
|
3540
|
+
graph.transitiveDependencies.set(pointer, result.transitiveDependencies);
|
|
3541
|
+
graph.subtreeDependencies.set(pointer, result.subtreeDependencies);
|
|
3551
3542
|
}
|
|
3552
3543
|
eventBuildGraph.timeEnd();
|
|
3553
|
-
return { graph
|
|
3544
|
+
return { graph };
|
|
3554
3545
|
}
|
|
3555
3546
|
|
|
3556
3547
|
//#endregion
|
|
@@ -3567,16 +3558,16 @@ const schemaKeys = new Set([
|
|
|
3567
3558
|
"schema",
|
|
3568
3559
|
"unevaluatedProperties"
|
|
3569
3560
|
]);
|
|
3570
|
-
const getComponentContext = (path
|
|
3571
|
-
if (path
|
|
3572
|
-
const type = path
|
|
3561
|
+
const getComponentContext = (path) => {
|
|
3562
|
+
if (path.length === 3 && path[0] === "components") {
|
|
3563
|
+
const type = path[1];
|
|
3573
3564
|
if (type === "parameters") return "write";
|
|
3574
3565
|
if (type === "requestBodies") return "write";
|
|
3575
3566
|
if (type === "responses") return "read";
|
|
3576
3567
|
if (type === "headers") return "read";
|
|
3577
3568
|
}
|
|
3578
|
-
if (path
|
|
3579
|
-
const type = path
|
|
3569
|
+
if (path.length === 2) {
|
|
3570
|
+
const type = path[0];
|
|
3580
3571
|
if (type === "parameters") return "write";
|
|
3581
3572
|
if (type === "responses") return "read";
|
|
3582
3573
|
}
|
|
@@ -3621,10 +3612,10 @@ const insertSplitSchemasIntoSpec = ({ logger, spec, split }) => {
|
|
|
3621
3612
|
* @param scope - The scope to exclude ('readOnly' or 'writeOnly')
|
|
3622
3613
|
* @returns boolean - Whether the schema should be removed from its parent
|
|
3623
3614
|
*/
|
|
3624
|
-
const pruneSchemaByScope = (graph
|
|
3615
|
+
const pruneSchemaByScope = (graph, schema, scope) => {
|
|
3625
3616
|
if (schema && typeof schema === "object") {
|
|
3626
3617
|
if ("$ref" in schema && typeof schema.$ref === "string") {
|
|
3627
|
-
const nodeInfo = graph
|
|
3618
|
+
const nodeInfo = graph.nodes.get(schema.$ref);
|
|
3628
3619
|
if (nodeInfo?.scopes) {
|
|
3629
3620
|
if (scope === "writeOnly" && nodeInfo.scopes.size === 1 && nodeInfo.scopes.has("write") || scope === "readOnly" && nodeInfo.scopes.size === 1 && nodeInfo.scopes.has("read")) {
|
|
3630
3621
|
delete schema["$ref"];
|
|
@@ -3639,7 +3630,7 @@ const pruneSchemaByScope = (graph$1, schema, scope) => {
|
|
|
3639
3630
|
for (let index = value.length - 1; index >= 0; index--) {
|
|
3640
3631
|
const item = value[index];
|
|
3641
3632
|
if (item && typeof item === "object" && item[scope] === true) value.splice(index, 1);
|
|
3642
|
-
else if (pruneSchemaByScope(graph
|
|
3633
|
+
else if (pruneSchemaByScope(graph, item, scope)) value.splice(index, 1);
|
|
3643
3634
|
}
|
|
3644
3635
|
if (!value.length) delete schema[keyword];
|
|
3645
3636
|
} else if (type === "objectMap" && typeof value === "object" && value !== null && !(value instanceof Array)) {
|
|
@@ -3650,7 +3641,7 @@ const pruneSchemaByScope = (graph$1, schema, scope) => {
|
|
|
3650
3641
|
if (prop && typeof prop === "object" && prop[scope] === true) {
|
|
3651
3642
|
delete objMap[key];
|
|
3652
3643
|
if (keyword === "properties") removedProperties.add(key);
|
|
3653
|
-
} else if (pruneSchemaByScope(graph
|
|
3644
|
+
} else if (pruneSchemaByScope(graph, prop, scope)) {
|
|
3654
3645
|
delete objMap[key];
|
|
3655
3646
|
if (keyword === "properties") removedProperties.add(key);
|
|
3656
3647
|
}
|
|
@@ -3663,18 +3654,18 @@ const pruneSchemaByScope = (graph$1, schema, scope) => {
|
|
|
3663
3654
|
if (!Object.keys(objMap).length) delete schema[keyword];
|
|
3664
3655
|
} else if (type === "single" && typeof value === "object" && value !== null) {
|
|
3665
3656
|
if (value[scope] === true) delete schema[keyword];
|
|
3666
|
-
else if (pruneSchemaByScope(graph
|
|
3657
|
+
else if (pruneSchemaByScope(graph, value, scope)) delete schema[keyword];
|
|
3667
3658
|
} else if (type === "singleOrArray") {
|
|
3668
3659
|
if (value instanceof Array) {
|
|
3669
3660
|
for (let index = value.length - 1; index >= 0; index--) {
|
|
3670
3661
|
const item = value[index];
|
|
3671
3662
|
if (item && typeof item === "object" && item[scope] === true) value.splice(index, 1);
|
|
3672
|
-
else if (pruneSchemaByScope(graph
|
|
3663
|
+
else if (pruneSchemaByScope(graph, item, scope)) value.splice(index, 1);
|
|
3673
3664
|
}
|
|
3674
3665
|
if (!value.length) delete schema[keyword];
|
|
3675
3666
|
} else if (typeof value === "object" && value !== null) {
|
|
3676
3667
|
if (value[scope] === true) delete schema[keyword];
|
|
3677
|
-
else if (pruneSchemaByScope(graph
|
|
3668
|
+
else if (pruneSchemaByScope(graph, value, scope)) delete schema[keyword];
|
|
3678
3669
|
}
|
|
3679
3670
|
}
|
|
3680
3671
|
}
|
|
@@ -3694,8 +3685,8 @@ const removeOriginalSplitSchemas = ({ logger, originalSchemas, spec, split }) =>
|
|
|
3694
3685
|
const event = logger.timeEvent("remove-original-split-schemas");
|
|
3695
3686
|
const schemasObj = getSchemasObject(spec);
|
|
3696
3687
|
for (const originalPointer of Object.keys(split.mapping)) {
|
|
3697
|
-
const path
|
|
3698
|
-
const name = path
|
|
3688
|
+
const path = jsonPointerToPath(originalPointer);
|
|
3689
|
+
const name = path[path.length - 1];
|
|
3699
3690
|
if (typeof name === "string" && schemasObj && Object.prototype.hasOwnProperty.call(schemasObj, name) && schemasObj[name] === originalSchemas[originalPointer]) delete schemasObj[name];
|
|
3700
3691
|
}
|
|
3701
3692
|
event.timeEnd();
|
|
@@ -3795,7 +3786,7 @@ function splitDiscriminatorSchemas({ config, existingNames, schemasPointerNamesp
|
|
|
3795
3786
|
* @param spec - The OpenAPI spec object
|
|
3796
3787
|
* @returns SplitSchemas - The split schemas and pointer mappings
|
|
3797
3788
|
*/
|
|
3798
|
-
const splitSchemas = ({ config, graph
|
|
3789
|
+
const splitSchemas = ({ config, graph, logger, spec }) => {
|
|
3799
3790
|
const event = logger.timeEvent("split-schemas");
|
|
3800
3791
|
const existingNames = /* @__PURE__ */ new Set();
|
|
3801
3792
|
const split = {
|
|
@@ -3813,20 +3804,20 @@ const splitSchemas = ({ config, graph: graph$1, logger, spec }) => {
|
|
|
3813
3804
|
*/
|
|
3814
3805
|
const pointerToSchema = (pointer) => {
|
|
3815
3806
|
if (pointer.startsWith(schemasPointerNamespace)) {
|
|
3816
|
-
const path
|
|
3817
|
-
if (path
|
|
3807
|
+
const path = jsonPointerToPath(pointer);
|
|
3808
|
+
if (path.length === schemasNamespaceSegments) return path[schemasNamespaceSegments - 1] || "";
|
|
3818
3809
|
}
|
|
3819
3810
|
return "";
|
|
3820
3811
|
};
|
|
3821
|
-
for (const pointer of graph
|
|
3812
|
+
for (const pointer of graph.nodes.keys()) {
|
|
3822
3813
|
const name = pointerToSchema(pointer);
|
|
3823
3814
|
if (name) existingNames.add(name);
|
|
3824
3815
|
}
|
|
3825
|
-
for (const [pointer, nodeInfo] of graph
|
|
3816
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
3826
3817
|
const name = pointerToSchema(pointer);
|
|
3827
3818
|
if (!name || !(nodeInfo.scopes?.has("read") || nodeInfo.scopes?.has("write")) || !nodeInfo.scopes?.has("normal")) continue;
|
|
3828
3819
|
const readSchema = deepClone(nodeInfo.node);
|
|
3829
|
-
pruneSchemaByScope(graph
|
|
3820
|
+
pruneSchemaByScope(graph, readSchema, "writeOnly");
|
|
3830
3821
|
const readBase = applyNaming(name, config.responses);
|
|
3831
3822
|
const readName = readBase === name ? readBase : getUniqueComponentName({
|
|
3832
3823
|
base: readBase,
|
|
@@ -3836,12 +3827,12 @@ const splitSchemas = ({ config, graph: graph$1, logger, spec }) => {
|
|
|
3836
3827
|
split.schemas[readName] = readSchema;
|
|
3837
3828
|
const readPointer = `${schemasPointerNamespace}${readName}`;
|
|
3838
3829
|
const writeSchema = deepClone(nodeInfo.node);
|
|
3839
|
-
pruneSchemaByScope(graph
|
|
3840
|
-
const transitiveDeps = graph
|
|
3830
|
+
pruneSchemaByScope(graph, writeSchema, "readOnly");
|
|
3831
|
+
const transitiveDeps = graph.transitiveDependencies.get(pointer) || /* @__PURE__ */ new Set();
|
|
3841
3832
|
if (!Array.from(transitiveDeps).some((depPointer) => {
|
|
3842
|
-
const depNodeInfo = graph
|
|
3833
|
+
const depNodeInfo = graph.nodes.get(depPointer);
|
|
3843
3834
|
return depNodeInfo?.scopes?.has("normal") && (depNodeInfo.scopes.has("read") || depNodeInfo.scopes.has("write"));
|
|
3844
|
-
}) &&
|
|
3835
|
+
}) && deepEqual(readSchema, writeSchema) && deepEqual(readSchema, nodeInfo.node)) continue;
|
|
3845
3836
|
const writeBase = applyNaming(name, config.requests);
|
|
3846
3837
|
const writeName = writeBase === name && writeBase !== readName ? writeBase : getUniqueComponentName({
|
|
3847
3838
|
base: writeBase,
|
|
@@ -3877,20 +3868,20 @@ const splitSchemas = ({ config, graph: graph$1, logger, spec }) => {
|
|
|
3877
3868
|
const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
3878
3869
|
const event = logger.timeEvent("update-refs-in-spec");
|
|
3879
3870
|
const schemasPointerNamespace = specToSchemasPointerNamespace(spec);
|
|
3880
|
-
const walk
|
|
3881
|
-
if (node instanceof Array) node.forEach((item, index) => walk
|
|
3871
|
+
const walk = ({ context, currentPointer, inSchema, node, path, visited = /* @__PURE__ */ new Set() }) => {
|
|
3872
|
+
if (node instanceof Array) node.forEach((item, index) => walk({
|
|
3882
3873
|
context,
|
|
3883
3874
|
currentPointer,
|
|
3884
3875
|
inSchema,
|
|
3885
3876
|
node: item,
|
|
3886
|
-
path: [...path
|
|
3877
|
+
path: [...path, index],
|
|
3887
3878
|
visited
|
|
3888
3879
|
}));
|
|
3889
3880
|
else if (node && typeof node === "object") {
|
|
3890
3881
|
let nextPointer = currentPointer;
|
|
3891
3882
|
let nextContext = context;
|
|
3892
|
-
if (isPathRootSchema(path
|
|
3893
|
-
nextPointer = `${schemasPointerNamespace}${path
|
|
3883
|
+
if (isPathRootSchema(path)) {
|
|
3884
|
+
nextPointer = `${schemasPointerNamespace}${path[path.length - 1]}`;
|
|
3894
3885
|
const originalPointer = split.reverseMapping[nextPointer];
|
|
3895
3886
|
if (originalPointer) {
|
|
3896
3887
|
const mapping = split.mapping[originalPointer];
|
|
@@ -3898,16 +3889,16 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3898
3889
|
else if (mapping?.write === nextPointer) nextContext = "write";
|
|
3899
3890
|
}
|
|
3900
3891
|
}
|
|
3901
|
-
const compContext = getComponentContext(path
|
|
3892
|
+
const compContext = getComponentContext(path);
|
|
3902
3893
|
if (compContext !== void 0) {
|
|
3903
3894
|
for (const key in node) {
|
|
3904
3895
|
if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
|
|
3905
|
-
walk
|
|
3896
|
+
walk({
|
|
3906
3897
|
context: compContext,
|
|
3907
3898
|
currentPointer: nextPointer,
|
|
3908
3899
|
inSchema: false,
|
|
3909
3900
|
node: node[key],
|
|
3910
|
-
path: [...path
|
|
3901
|
+
path: [...path, key],
|
|
3911
3902
|
visited
|
|
3912
3903
|
});
|
|
3913
3904
|
}
|
|
@@ -3918,49 +3909,49 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3918
3909
|
const value = node[key];
|
|
3919
3910
|
if (!inSchema) {
|
|
3920
3911
|
if (key === "requestBody") {
|
|
3921
|
-
walk
|
|
3912
|
+
walk({
|
|
3922
3913
|
context: "write",
|
|
3923
3914
|
currentPointer: nextPointer,
|
|
3924
3915
|
inSchema: false,
|
|
3925
3916
|
node: value,
|
|
3926
|
-
path: [...path
|
|
3917
|
+
path: [...path, key],
|
|
3927
3918
|
visited
|
|
3928
3919
|
});
|
|
3929
3920
|
continue;
|
|
3930
3921
|
}
|
|
3931
3922
|
if (key === "responses") {
|
|
3932
|
-
walk
|
|
3923
|
+
walk({
|
|
3933
3924
|
context: "read",
|
|
3934
3925
|
currentPointer: nextPointer,
|
|
3935
3926
|
inSchema: false,
|
|
3936
3927
|
node: value,
|
|
3937
|
-
path: [...path
|
|
3928
|
+
path: [...path, key],
|
|
3938
3929
|
visited
|
|
3939
3930
|
});
|
|
3940
3931
|
continue;
|
|
3941
3932
|
}
|
|
3942
3933
|
if (key === "parameters" && Array.isArray(value)) {
|
|
3943
3934
|
value.forEach((param, index) => {
|
|
3944
|
-
if (param && typeof param === "object" && "schema" in param) walk
|
|
3935
|
+
if (param && typeof param === "object" && "schema" in param) walk({
|
|
3945
3936
|
context: "write",
|
|
3946
3937
|
currentPointer: nextPointer,
|
|
3947
3938
|
inSchema: true,
|
|
3948
3939
|
node: param.schema,
|
|
3949
3940
|
path: [
|
|
3950
|
-
...path
|
|
3941
|
+
...path,
|
|
3951
3942
|
key,
|
|
3952
3943
|
index,
|
|
3953
3944
|
"schema"
|
|
3954
3945
|
],
|
|
3955
3946
|
visited
|
|
3956
3947
|
});
|
|
3957
|
-
if (param && typeof param === "object" && "content" in param) walk
|
|
3948
|
+
if (param && typeof param === "object" && "content" in param) walk({
|
|
3958
3949
|
context: "write",
|
|
3959
3950
|
currentPointer: nextPointer,
|
|
3960
3951
|
inSchema: false,
|
|
3961
3952
|
node: param.content,
|
|
3962
3953
|
path: [
|
|
3963
|
-
...path
|
|
3954
|
+
...path,
|
|
3964
3955
|
key,
|
|
3965
3956
|
index,
|
|
3966
3957
|
"content"
|
|
@@ -3973,13 +3964,13 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3973
3964
|
if (key === "headers" && typeof value === "object" && value !== null) {
|
|
3974
3965
|
for (const headerKey in value) {
|
|
3975
3966
|
if (!Object.prototype.hasOwnProperty.call(value, headerKey)) continue;
|
|
3976
|
-
walk
|
|
3967
|
+
walk({
|
|
3977
3968
|
context: "read",
|
|
3978
3969
|
currentPointer: nextPointer,
|
|
3979
3970
|
inSchema: false,
|
|
3980
3971
|
node: value[headerKey],
|
|
3981
3972
|
path: [
|
|
3982
|
-
...path
|
|
3973
|
+
...path,
|
|
3983
3974
|
key,
|
|
3984
3975
|
headerKey
|
|
3985
3976
|
],
|
|
@@ -3989,12 +3980,12 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3989
3980
|
continue;
|
|
3990
3981
|
}
|
|
3991
3982
|
}
|
|
3992
|
-
if (schemaKeys.has(key)) walk
|
|
3983
|
+
if (schemaKeys.has(key)) walk({
|
|
3993
3984
|
context: nextContext,
|
|
3994
3985
|
currentPointer: nextPointer,
|
|
3995
3986
|
inSchema: true,
|
|
3996
3987
|
node: value,
|
|
3997
|
-
path: [...path
|
|
3988
|
+
path: [...path, key],
|
|
3998
3989
|
visited
|
|
3999
3990
|
});
|
|
4000
3991
|
else if (key === "$ref" && typeof value === "string") {
|
|
@@ -4016,26 +4007,26 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
4016
4007
|
}
|
|
4017
4008
|
value.mapping = updatedMapping;
|
|
4018
4009
|
}
|
|
4019
|
-
walk
|
|
4010
|
+
walk({
|
|
4020
4011
|
context: nextContext,
|
|
4021
4012
|
currentPointer: nextPointer,
|
|
4022
4013
|
inSchema,
|
|
4023
4014
|
node: value,
|
|
4024
|
-
path: [...path
|
|
4015
|
+
path: [...path, key],
|
|
4025
4016
|
visited
|
|
4026
4017
|
});
|
|
4027
|
-
} else walk
|
|
4018
|
+
} else walk({
|
|
4028
4019
|
context: nextContext,
|
|
4029
4020
|
currentPointer: nextPointer,
|
|
4030
4021
|
inSchema,
|
|
4031
4022
|
node: value,
|
|
4032
|
-
path: [...path
|
|
4023
|
+
path: [...path, key],
|
|
4033
4024
|
visited
|
|
4034
4025
|
});
|
|
4035
4026
|
}
|
|
4036
4027
|
}
|
|
4037
4028
|
};
|
|
4038
|
-
walk
|
|
4029
|
+
walk({
|
|
4039
4030
|
context: null,
|
|
4040
4031
|
currentPointer: null,
|
|
4041
4032
|
inSchema: false,
|
|
@@ -4056,11 +4047,11 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
4056
4047
|
* @param spec - The OpenAPI spec object
|
|
4057
4048
|
*/
|
|
4058
4049
|
const readWriteTransform = ({ config, logger, spec }) => {
|
|
4059
|
-
const { graph
|
|
4050
|
+
const { graph } = buildGraph(spec, logger);
|
|
4060
4051
|
const originalSchemas = captureOriginalSchemas(spec, logger);
|
|
4061
4052
|
const split = splitSchemas({
|
|
4062
4053
|
config,
|
|
4063
|
-
graph
|
|
4054
|
+
graph,
|
|
4064
4055
|
logger,
|
|
4065
4056
|
spec
|
|
4066
4057
|
});
|
|
@@ -4178,7 +4169,7 @@ const mergeParametersObjects = ({ source, target }) => {
|
|
|
4178
4169
|
//#endregion
|
|
4179
4170
|
//#region src/openApi/shared/utils/validator.ts
|
|
4180
4171
|
const isSimpleKey = (key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
|
|
4181
|
-
const formatPath = (path
|
|
4172
|
+
const formatPath = (path) => path.map((segment, i) => {
|
|
4182
4173
|
if (typeof segment === "number") return `[${segment}]`;
|
|
4183
4174
|
if (i === 0) return segment;
|
|
4184
4175
|
return isSimpleKey(segment) ? `.${segment}` : `['${segment.replace(/"/g, "\\'")}']`;
|
|
@@ -4221,17 +4212,17 @@ const filterSpec$2 = ({ logger, operations, preserveOrder, schemas, spec }) => {
|
|
|
4221
4212
|
spec.definitions = filtered;
|
|
4222
4213
|
}
|
|
4223
4214
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
4224
|
-
const path
|
|
4215
|
+
const path = entry[0];
|
|
4225
4216
|
const pathItem = entry[1];
|
|
4226
4217
|
for (const method of httpMethods) {
|
|
4227
4218
|
if (!pathItem[method]) continue;
|
|
4228
4219
|
const key = addNamespace("operation", createOperationKey({
|
|
4229
4220
|
method,
|
|
4230
|
-
path
|
|
4221
|
+
path
|
|
4231
4222
|
}));
|
|
4232
4223
|
if (!operations.has(key)) delete pathItem[method];
|
|
4233
4224
|
}
|
|
4234
|
-
if (!Object.keys(pathItem).length) delete spec.paths[path
|
|
4225
|
+
if (!Object.keys(pathItem).length) delete spec.paths[path];
|
|
4235
4226
|
}
|
|
4236
4227
|
eventFilterSpec.timeEnd();
|
|
4237
4228
|
};
|
|
@@ -4487,20 +4478,20 @@ const parseAllOf$2 = ({ context, schema, state }) => {
|
|
|
4487
4478
|
else irCompositionSchema.required = schema.required;
|
|
4488
4479
|
schemaItems.push(irCompositionSchema);
|
|
4489
4480
|
if (compositionSchema.$ref) {
|
|
4490
|
-
const ref
|
|
4491
|
-
if (ref
|
|
4481
|
+
const ref = context.resolveRef(compositionSchema.$ref);
|
|
4482
|
+
if (ref.discriminator && state.$ref) {
|
|
4492
4483
|
const valueSchemas = discriminatorValues(state.$ref).map((value) => ({
|
|
4493
4484
|
const: value,
|
|
4494
4485
|
type: "string"
|
|
4495
4486
|
}));
|
|
4496
4487
|
const irDiscriminatorSchema = {
|
|
4497
|
-
properties: { [ref
|
|
4488
|
+
properties: { [ref.discriminator]: valueSchemas.length > 1 ? {
|
|
4498
4489
|
items: valueSchemas,
|
|
4499
4490
|
logicalOperator: "or"
|
|
4500
4491
|
} : valueSchemas[0] },
|
|
4501
4492
|
type: "object"
|
|
4502
4493
|
};
|
|
4503
|
-
if (ref
|
|
4494
|
+
if (ref.required?.includes(ref.discriminator)) irDiscriminatorSchema.required = [ref.discriminator];
|
|
4504
4495
|
schemaItems.push(irDiscriminatorSchema);
|
|
4505
4496
|
}
|
|
4506
4497
|
}
|
|
@@ -4593,13 +4584,13 @@ const parseRef$2 = ({ context, schema, state }) => {
|
|
|
4593
4584
|
const refSchema = context.resolveRef(schema.$ref);
|
|
4594
4585
|
const originalRef = state.$ref;
|
|
4595
4586
|
state.$ref = schema.$ref;
|
|
4596
|
-
const irSchema
|
|
4587
|
+
const irSchema = schemaToIrSchema$2({
|
|
4597
4588
|
context,
|
|
4598
4589
|
schema: refSchema,
|
|
4599
4590
|
state
|
|
4600
4591
|
});
|
|
4601
4592
|
state.$ref = originalRef;
|
|
4602
|
-
return irSchema
|
|
4593
|
+
return irSchema;
|
|
4603
4594
|
}
|
|
4604
4595
|
}
|
|
4605
4596
|
irSchema.$ref = decodeURI(schema.$ref);
|
|
@@ -4766,19 +4757,19 @@ const isPaginationType$2 = (schemaType) => schemaType === "boolean" || schemaTyp
|
|
|
4766
4757
|
const paginationField$2 = ({ context, name, schema }) => {
|
|
4767
4758
|
if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) return true;
|
|
4768
4759
|
if ("$ref" in schema) {
|
|
4769
|
-
const ref
|
|
4770
|
-
if ("in" in ref
|
|
4760
|
+
const ref = context.resolveRef(schema.$ref ?? "");
|
|
4761
|
+
if ("in" in ref && ref.in) return paginationField$2({
|
|
4771
4762
|
context,
|
|
4772
4763
|
name,
|
|
4773
|
-
schema: "schema" in ref
|
|
4774
|
-
...ref
|
|
4764
|
+
schema: "schema" in ref ? ref.schema : {
|
|
4765
|
+
...ref,
|
|
4775
4766
|
in: void 0
|
|
4776
4767
|
}
|
|
4777
4768
|
});
|
|
4778
4769
|
return paginationField$2({
|
|
4779
4770
|
context,
|
|
4780
4771
|
name,
|
|
4781
|
-
schema: ref
|
|
4772
|
+
schema: ref
|
|
4782
4773
|
});
|
|
4783
4774
|
}
|
|
4784
4775
|
if ("in" in schema) {
|
|
@@ -4792,10 +4783,10 @@ const paginationField$2 = ({ context, name, schema }) => {
|
|
|
4792
4783
|
}
|
|
4793
4784
|
});
|
|
4794
4785
|
}
|
|
4795
|
-
for (const name
|
|
4796
|
-
const property = schema.properties[name
|
|
4786
|
+
for (const name in schema.properties) if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) {
|
|
4787
|
+
const property = schema.properties[name];
|
|
4797
4788
|
if (typeof property !== "boolean" && !("$ref" in property)) {
|
|
4798
|
-
if (isPaginationType$2(getSchemaType$1({ schema: property }))) return name
|
|
4789
|
+
if (isPaginationType$2(getSchemaType$1({ schema: property }))) return name;
|
|
4799
4790
|
}
|
|
4800
4791
|
}
|
|
4801
4792
|
for (const allOf of schema.allOf ?? []) {
|
|
@@ -4817,17 +4808,17 @@ const parseOperationJsDoc$2 = ({ irOperation, operation }) => {
|
|
|
4817
4808
|
if (operation.summary) irOperation.summary = operation.summary;
|
|
4818
4809
|
if (operation.tags?.length) irOperation.tags = operation.tags;
|
|
4819
4810
|
};
|
|
4820
|
-
const initIrOperation$2 = ({ context, method, operation, path
|
|
4811
|
+
const initIrOperation$2 = ({ context, method, operation, path, state }) => {
|
|
4821
4812
|
const irOperation = {
|
|
4822
4813
|
id: operationToId({
|
|
4823
4814
|
context,
|
|
4824
4815
|
id: operation.operationId,
|
|
4825
4816
|
method,
|
|
4826
|
-
path
|
|
4817
|
+
path,
|
|
4827
4818
|
state
|
|
4828
4819
|
}),
|
|
4829
4820
|
method,
|
|
4830
|
-
path
|
|
4821
|
+
path
|
|
4831
4822
|
};
|
|
4832
4823
|
if (operation.operationId) irOperation.operationId = operation.operationId;
|
|
4833
4824
|
parseOperationJsDoc$2({
|
|
@@ -4840,12 +4831,12 @@ const initIrOperation$2 = ({ context, method, operation, path: path$1, state })
|
|
|
4840
4831
|
});
|
|
4841
4832
|
return irOperation;
|
|
4842
4833
|
};
|
|
4843
|
-
const operationToIrOperation$2 = ({ context, method, operation, path
|
|
4834
|
+
const operationToIrOperation$2 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
4844
4835
|
const irOperation = initIrOperation$2({
|
|
4845
4836
|
context,
|
|
4846
4837
|
method,
|
|
4847
4838
|
operation,
|
|
4848
|
-
path
|
|
4839
|
+
path,
|
|
4849
4840
|
state
|
|
4850
4841
|
});
|
|
4851
4842
|
if (operation.parameters) irOperation.parameters = operation.parameters;
|
|
@@ -4876,7 +4867,7 @@ const operationToIrOperation$2 = ({ context, method, operation, path: path$1, se
|
|
|
4876
4867
|
mimeTypes,
|
|
4877
4868
|
response: { schema }
|
|
4878
4869
|
});
|
|
4879
|
-
const content = contents.find((content
|
|
4870
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
4880
4871
|
if (content) {
|
|
4881
4872
|
const pagination = paginationField$2({
|
|
4882
4873
|
context,
|
|
@@ -4932,7 +4923,7 @@ const operationToIrOperation$2 = ({ context, method, operation, path: path$1, se
|
|
|
4932
4923
|
mimeTypes: operation.produces ? operation.produces : ["application/json"],
|
|
4933
4924
|
response: responseObject
|
|
4934
4925
|
});
|
|
4935
|
-
const content = contents.find((content
|
|
4926
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
4936
4927
|
if (content) irOperation.responses[name] = {
|
|
4937
4928
|
mediaType: content.mediaType,
|
|
4938
4929
|
schema: schemaToIrSchema$2({
|
|
@@ -5002,14 +4993,14 @@ const operationToIrOperation$2 = ({ context, method, operation, path: path$1, se
|
|
|
5002
4993
|
}
|
|
5003
4994
|
return irOperation;
|
|
5004
4995
|
};
|
|
5005
|
-
const parsePathOperation$2 = ({ context, method, operation, path
|
|
4996
|
+
const parsePathOperation$2 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
5006
4997
|
if (!context.ir.paths) context.ir.paths = {};
|
|
5007
|
-
if (!context.ir.paths[path
|
|
5008
|
-
context.ir.paths[path
|
|
4998
|
+
if (!context.ir.paths[path]) context.ir.paths[path] = {};
|
|
4999
|
+
context.ir.paths[path][method] = operationToIrOperation$2({
|
|
5009
5000
|
context,
|
|
5010
5001
|
method,
|
|
5011
5002
|
operation,
|
|
5012
|
-
path
|
|
5003
|
+
path,
|
|
5013
5004
|
securitySchemesMap,
|
|
5014
5005
|
state
|
|
5015
5006
|
});
|
|
@@ -5023,10 +5014,6 @@ const parsePathOperation$2 = ({ context, method, operation, path: path$1, securi
|
|
|
5023
5014
|
const defaultExplode$2 = (collectionFormat) => {
|
|
5024
5015
|
switch (collectionFormat) {
|
|
5025
5016
|
case "multi": return true;
|
|
5026
|
-
case "csv":
|
|
5027
|
-
case "pipes":
|
|
5028
|
-
case "ssv":
|
|
5029
|
-
case "tsv":
|
|
5030
5017
|
default: return false;
|
|
5031
5018
|
}
|
|
5032
5019
|
};
|
|
@@ -5037,7 +5024,6 @@ const defaultStyle$2 = (_in) => {
|
|
|
5037
5024
|
switch (_in) {
|
|
5038
5025
|
case "header":
|
|
5039
5026
|
case "path": return "simple";
|
|
5040
|
-
case "query":
|
|
5041
5027
|
default: return "form";
|
|
5042
5028
|
}
|
|
5043
5029
|
};
|
|
@@ -5122,12 +5108,12 @@ function parseUrl(value) {
|
|
|
5122
5108
|
if (!match) return errorResponse;
|
|
5123
5109
|
const host = match[5] || "";
|
|
5124
5110
|
if (host === "." || host === "..") return errorResponse;
|
|
5125
|
-
const path
|
|
5111
|
+
const path = match[8] || "";
|
|
5126
5112
|
const protocol = match[2] || "";
|
|
5127
5113
|
if (protocol.length === 1) return errorResponse;
|
|
5128
5114
|
return {
|
|
5129
5115
|
host,
|
|
5130
|
-
path: path
|
|
5116
|
+
path: path === "/" ? "" : path,
|
|
5131
5117
|
port: match[7] || "",
|
|
5132
5118
|
protocol
|
|
5133
5119
|
};
|
|
@@ -5138,7 +5124,7 @@ function parseUrl(value) {
|
|
|
5138
5124
|
const parseServers$2 = ({ context }) => {
|
|
5139
5125
|
let schemes = context.spec.schemes ?? [];
|
|
5140
5126
|
let host = context.spec.host ?? "";
|
|
5141
|
-
const path
|
|
5127
|
+
const path = context.spec.basePath ?? "";
|
|
5142
5128
|
for (const input of context.config.input) if (typeof input.path === "string") {
|
|
5143
5129
|
const url = parseUrl(input.path);
|
|
5144
5130
|
if (!schemes.length) {
|
|
@@ -5147,7 +5133,7 @@ const parseServers$2 = ({ context }) => {
|
|
|
5147
5133
|
if (!host) host = `${url.host}${url.port ? `:${url.port}` : ""}`;
|
|
5148
5134
|
}
|
|
5149
5135
|
if (!schemes.length) schemes = [""];
|
|
5150
|
-
const servers = schemes.map((scheme) => `${scheme ? `${scheme}://` : ""}${host}${path
|
|
5136
|
+
const servers = schemes.map((scheme) => `${scheme ? `${scheme}://` : ""}${host}${path}`).filter(Boolean);
|
|
5151
5137
|
if (servers.length) context.ir.servers = servers.map((url) => ({ url }));
|
|
5152
5138
|
};
|
|
5153
5139
|
|
|
@@ -5158,7 +5144,7 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5158
5144
|
const issues = [];
|
|
5159
5145
|
const operationIds = /* @__PURE__ */ new Map();
|
|
5160
5146
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
5161
|
-
const path
|
|
5147
|
+
const path = entry[0];
|
|
5162
5148
|
const pathItem = entry[1];
|
|
5163
5149
|
for (const method of httpMethods) {
|
|
5164
5150
|
if (method === "trace") continue;
|
|
@@ -5166,7 +5152,7 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5166
5152
|
if (!operation) continue;
|
|
5167
5153
|
const operationKey = createOperationKey({
|
|
5168
5154
|
method,
|
|
5169
|
-
path
|
|
5155
|
+
path
|
|
5170
5156
|
});
|
|
5171
5157
|
if (operation.operationId) if (!operationIds.has(operation.operationId)) operationIds.set(operation.operationId, operationKey);
|
|
5172
5158
|
else issues.push({
|
|
@@ -5178,7 +5164,7 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5178
5164
|
message: "Duplicate `operationId` found. Each `operationId` must be unique.",
|
|
5179
5165
|
path: [
|
|
5180
5166
|
"paths",
|
|
5181
|
-
path
|
|
5167
|
+
path,
|
|
5182
5168
|
method,
|
|
5183
5169
|
"operationId"
|
|
5184
5170
|
],
|
|
@@ -5202,8 +5188,8 @@ const parseV2_0_X = (context) => {
|
|
|
5202
5188
|
});
|
|
5203
5189
|
if (hasFilters(context.config.parser.filters)) {
|
|
5204
5190
|
const filters = createFilters(context.config.parser.filters, context.spec, context.logger);
|
|
5205
|
-
const { graph
|
|
5206
|
-
const { resourceMetadata } = buildResourceMetadata(graph
|
|
5191
|
+
const { graph } = buildGraph(context.spec, context.logger);
|
|
5192
|
+
const { resourceMetadata } = buildResourceMetadata(graph, context.logger);
|
|
5207
5193
|
filterSpec$2({
|
|
5208
5194
|
...createFilteredDependencies({
|
|
5209
5195
|
filters,
|
|
@@ -5232,9 +5218,9 @@ const parseV2_0_X = (context) => {
|
|
|
5232
5218
|
});
|
|
5233
5219
|
}
|
|
5234
5220
|
parseServers$2({ context });
|
|
5235
|
-
for (const path
|
|
5236
|
-
if (path
|
|
5237
|
-
const pathItem = context.spec.paths[path
|
|
5221
|
+
for (const path in context.spec.paths) {
|
|
5222
|
+
if (path.startsWith("x-")) continue;
|
|
5223
|
+
const pathItem = context.spec.paths[path];
|
|
5238
5224
|
const finalPathItem = pathItem.$ref ? {
|
|
5239
5225
|
...context.resolveRef(pathItem.$ref),
|
|
5240
5226
|
...pathItem
|
|
@@ -5255,7 +5241,7 @@ const parseV2_0_X = (context) => {
|
|
|
5255
5241
|
parameters: finalPathItem.parameters
|
|
5256
5242
|
})
|
|
5257
5243
|
},
|
|
5258
|
-
path
|
|
5244
|
+
path,
|
|
5259
5245
|
securitySchemesMap,
|
|
5260
5246
|
state
|
|
5261
5247
|
};
|
|
@@ -5449,17 +5435,17 @@ const filterSpec$1 = ({ logger, operations, parameters, preserveOrder, requestBo
|
|
|
5449
5435
|
}
|
|
5450
5436
|
}
|
|
5451
5437
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
5452
|
-
const path
|
|
5438
|
+
const path = entry[0];
|
|
5453
5439
|
const pathItem = entry[1];
|
|
5454
5440
|
for (const method of httpMethods) {
|
|
5455
5441
|
if (!pathItem[method]) continue;
|
|
5456
5442
|
const key = addNamespace("operation", createOperationKey({
|
|
5457
5443
|
method,
|
|
5458
|
-
path
|
|
5444
|
+
path
|
|
5459
5445
|
}));
|
|
5460
5446
|
if (!operations.has(key)) delete pathItem[method];
|
|
5461
5447
|
}
|
|
5462
|
-
if (!Object.keys(pathItem).length) delete spec.paths[path
|
|
5448
|
+
if (!Object.keys(pathItem).length) delete spec.paths[path];
|
|
5463
5449
|
}
|
|
5464
5450
|
eventFilterSpec.timeEnd();
|
|
5465
5451
|
};
|
|
@@ -5632,6 +5618,25 @@ const parseObject$1 = ({ context, irSchema = {}, schema, state }) => {
|
|
|
5632
5618
|
state
|
|
5633
5619
|
});
|
|
5634
5620
|
if (schema.required) irSchema.required = schema.required;
|
|
5621
|
+
if (schema.discriminator && state.$ref) {
|
|
5622
|
+
const values = getAllDiscriminatorValues$1({
|
|
5623
|
+
discriminator: schema.discriminator,
|
|
5624
|
+
schemaRef: state.$ref
|
|
5625
|
+
});
|
|
5626
|
+
if (values.length) {
|
|
5627
|
+
const propertyType = findDiscriminatorPropertyType$1({
|
|
5628
|
+
context,
|
|
5629
|
+
propertyName: schema.discriminator.propertyName,
|
|
5630
|
+
schemas: [schema]
|
|
5631
|
+
});
|
|
5632
|
+
const valueSchemas = values.map((value) => convertDiscriminatorValue(value, propertyType));
|
|
5633
|
+
if (!irSchema.properties) irSchema.properties = {};
|
|
5634
|
+
irSchema.properties[schema.discriminator.propertyName] = valueSchemas.length > 1 ? {
|
|
5635
|
+
items: valueSchemas,
|
|
5636
|
+
logicalOperator: "or"
|
|
5637
|
+
} : valueSchemas[0];
|
|
5638
|
+
}
|
|
5639
|
+
}
|
|
5635
5640
|
return irSchema;
|
|
5636
5641
|
};
|
|
5637
5642
|
const parseString$1 = ({ irSchema = {} }) => {
|
|
@@ -5673,11 +5678,11 @@ const parseAllOf$1 = ({ context, schema, state }) => {
|
|
|
5673
5678
|
else irCompositionSchema.required = schema.required;
|
|
5674
5679
|
schemaItems.push(irCompositionSchema);
|
|
5675
5680
|
if ("$ref" in compositionSchema) {
|
|
5676
|
-
const ref
|
|
5681
|
+
const ref = context.resolveRef(compositionSchema.$ref);
|
|
5677
5682
|
if (state.$ref) {
|
|
5678
5683
|
const discriminators = findDiscriminatorsInSchema$1({
|
|
5679
5684
|
context,
|
|
5680
|
-
schema: ref
|
|
5685
|
+
schema: ref
|
|
5681
5686
|
});
|
|
5682
5687
|
for (const { discriminator, oneOf } of discriminators) {
|
|
5683
5688
|
const values = discriminatorValues(state.$ref, discriminator.mapping, oneOf ? () => oneOf.some((o) => "$ref" in o && o.$ref === state.$ref) : void 0);
|
|
@@ -5686,7 +5691,7 @@ const parseAllOf$1 = ({ context, schema, state }) => {
|
|
|
5686
5691
|
const existingIndex = discriminatorsToAdd.findIndex((d) => d.discriminator.propertyName === discriminator.propertyName);
|
|
5687
5692
|
if (existingIndex !== -1) if (isExplicitMapping && !discriminatorsToAdd[existingIndex].isExplicitMapping) discriminatorsToAdd.splice(existingIndex, 1);
|
|
5688
5693
|
else continue;
|
|
5689
|
-
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref
|
|
5694
|
+
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref.required?.includes(d.discriminator.propertyName) || ref.allOf && ref.allOf.some((item) => {
|
|
5690
5695
|
return ("$ref" in item ? context.resolveRef(item.$ref) : item).required?.includes(d.discriminator.propertyName);
|
|
5691
5696
|
})));
|
|
5692
5697
|
discriminatorsToAdd.push({
|
|
@@ -5950,13 +5955,13 @@ const parseRef$1 = ({ context, schema, state }) => {
|
|
|
5950
5955
|
const refSchema = context.resolveRef(schema.$ref);
|
|
5951
5956
|
const originalRef = state.$ref;
|
|
5952
5957
|
state.$ref = schema.$ref;
|
|
5953
|
-
const irSchema
|
|
5958
|
+
const irSchema = schemaToIrSchema$1({
|
|
5954
5959
|
context,
|
|
5955
5960
|
schema: refSchema,
|
|
5956
5961
|
state
|
|
5957
5962
|
});
|
|
5958
5963
|
state.$ref = originalRef;
|
|
5959
|
-
return irSchema
|
|
5964
|
+
return irSchema;
|
|
5960
5965
|
}
|
|
5961
5966
|
}
|
|
5962
5967
|
const irSchema = {};
|
|
@@ -6133,13 +6138,13 @@ const isPaginationType$1 = (schemaType) => schemaType === "boolean" || schemaTyp
|
|
|
6133
6138
|
const paginationField$1 = ({ context, name, schema }) => {
|
|
6134
6139
|
if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) return true;
|
|
6135
6140
|
if ("$ref" in schema) {
|
|
6136
|
-
const ref
|
|
6137
|
-
if ("content" in ref
|
|
6141
|
+
const ref = context.resolveRef(schema.$ref);
|
|
6142
|
+
if ("content" in ref || "in" in ref) {
|
|
6138
6143
|
let refSchema;
|
|
6139
|
-
if ("in" in ref
|
|
6144
|
+
if ("in" in ref) refSchema = ref.schema;
|
|
6140
6145
|
if (!refSchema) {
|
|
6141
|
-
const contents = mediaTypeObjects$1({ content: ref
|
|
6142
|
-
const content = contents.find((content
|
|
6146
|
+
const contents = mediaTypeObjects$1({ content: ref.content });
|
|
6147
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6143
6148
|
if (content?.schema) refSchema = content.schema;
|
|
6144
6149
|
}
|
|
6145
6150
|
if (!refSchema) return false;
|
|
@@ -6152,13 +6157,13 @@ const paginationField$1 = ({ context, name, schema }) => {
|
|
|
6152
6157
|
return paginationField$1({
|
|
6153
6158
|
context,
|
|
6154
6159
|
name,
|
|
6155
|
-
schema: ref
|
|
6160
|
+
schema: ref
|
|
6156
6161
|
});
|
|
6157
6162
|
}
|
|
6158
|
-
for (const name
|
|
6159
|
-
const property = schema.properties[name
|
|
6163
|
+
for (const name in schema.properties) if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) {
|
|
6164
|
+
const property = schema.properties[name];
|
|
6160
6165
|
if (typeof property !== "boolean" && !("$ref" in property)) {
|
|
6161
|
-
if (isPaginationType$1(getSchemaType({ schema: property }))) return name
|
|
6166
|
+
if (isPaginationType$1(getSchemaType({ schema: property }))) return name;
|
|
6162
6167
|
}
|
|
6163
6168
|
}
|
|
6164
6169
|
for (const allOf of schema.allOf ?? []) {
|
|
@@ -6180,17 +6185,17 @@ const parseOperationJsDoc$1 = ({ irOperation, operation }) => {
|
|
|
6180
6185
|
if (operation.summary) irOperation.summary = operation.summary;
|
|
6181
6186
|
if (operation.tags?.length) irOperation.tags = operation.tags;
|
|
6182
6187
|
};
|
|
6183
|
-
const initIrOperation$1 = ({ context, method, operation, path
|
|
6188
|
+
const initIrOperation$1 = ({ context, method, operation, path, state }) => {
|
|
6184
6189
|
const irOperation = {
|
|
6185
6190
|
id: operationToId({
|
|
6186
6191
|
context,
|
|
6187
6192
|
id: operation.operationId,
|
|
6188
6193
|
method,
|
|
6189
|
-
path
|
|
6194
|
+
path,
|
|
6190
6195
|
state
|
|
6191
6196
|
}),
|
|
6192
6197
|
method,
|
|
6193
|
-
path
|
|
6198
|
+
path
|
|
6194
6199
|
};
|
|
6195
6200
|
if (operation.operationId) irOperation.operationId = operation.operationId;
|
|
6196
6201
|
parseOperationJsDoc$1({
|
|
@@ -6203,19 +6208,19 @@ const initIrOperation$1 = ({ context, method, operation, path: path$1, state })
|
|
|
6203
6208
|
});
|
|
6204
6209
|
return irOperation;
|
|
6205
6210
|
};
|
|
6206
|
-
const operationToIrOperation$1 = ({ context, method, operation, path
|
|
6211
|
+
const operationToIrOperation$1 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
6207
6212
|
const irOperation = initIrOperation$1({
|
|
6208
6213
|
context,
|
|
6209
6214
|
method,
|
|
6210
6215
|
operation,
|
|
6211
|
-
path
|
|
6216
|
+
path,
|
|
6212
6217
|
state
|
|
6213
6218
|
});
|
|
6214
6219
|
if (operation.parameters) irOperation.parameters = operation.parameters;
|
|
6215
6220
|
if (operation.requestBody) {
|
|
6216
6221
|
const requestBody = "$ref" in operation.requestBody ? context.resolveRef(operation.requestBody.$ref) : operation.requestBody;
|
|
6217
6222
|
const contents = mediaTypeObjects$1({ content: requestBody.content });
|
|
6218
|
-
const content = contents.find((content
|
|
6223
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6219
6224
|
if (content) {
|
|
6220
6225
|
const pagination = paginationField$1({
|
|
6221
6226
|
context,
|
|
@@ -6256,7 +6261,7 @@ const operationToIrOperation$1 = ({ context, method, operation, path: path$1, se
|
|
|
6256
6261
|
const response = operation.responses[name];
|
|
6257
6262
|
const responseObject = "$ref" in response ? context.resolveRef(response.$ref) : response;
|
|
6258
6263
|
const contents = mediaTypeObjects$1({ content: responseObject.content });
|
|
6259
|
-
const content = contents.find((content
|
|
6264
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6260
6265
|
if (content) irOperation.responses[name] = {
|
|
6261
6266
|
mediaType: content.mediaType,
|
|
6262
6267
|
schema: schemaToIrSchema$1({
|
|
@@ -6284,15 +6289,15 @@ const operationToIrOperation$1 = ({ context, method, operation, path: path$1, se
|
|
|
6284
6289
|
}
|
|
6285
6290
|
return irOperation;
|
|
6286
6291
|
};
|
|
6287
|
-
const parsePathOperation$1 = ({ context, method, operation, path
|
|
6292
|
+
const parsePathOperation$1 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
6288
6293
|
if (!context.ir.paths) context.ir.paths = {};
|
|
6289
|
-
if (!context.ir.paths[path
|
|
6294
|
+
if (!context.ir.paths[path]) context.ir.paths[path] = {};
|
|
6290
6295
|
if (operation.servers) context.ir.servers = [...context.ir.servers ?? [], ...operation.servers];
|
|
6291
|
-
context.ir.paths[path
|
|
6296
|
+
context.ir.paths[path][method] = operationToIrOperation$1({
|
|
6292
6297
|
context,
|
|
6293
6298
|
method,
|
|
6294
6299
|
operation,
|
|
6295
|
-
path
|
|
6300
|
+
path,
|
|
6296
6301
|
securitySchemesMap,
|
|
6297
6302
|
state
|
|
6298
6303
|
});
|
|
@@ -6348,7 +6353,7 @@ const parameterToIrParameter$1 = ({ $ref, context, parameter }) => {
|
|
|
6348
6353
|
let schema = parameter.schema;
|
|
6349
6354
|
if (!schema) {
|
|
6350
6355
|
const contents = mediaTypeObjects$1({ content: parameter.content });
|
|
6351
|
-
const content = contents.find((content
|
|
6356
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6352
6357
|
if (content) schema = content.schema;
|
|
6353
6358
|
}
|
|
6354
6359
|
const finalSchema = schema && "$ref" in schema ? {
|
|
@@ -6406,7 +6411,7 @@ const parseParameter$1 = ({ $ref, context, parameter }) => {
|
|
|
6406
6411
|
//#region src/openApi/3.0.x/parser/requestBody.ts
|
|
6407
6412
|
const requestBodyToIrRequestBody$1 = ({ $ref, context, requestBody }) => {
|
|
6408
6413
|
const contents = mediaTypeObjects$1({ content: requestBody.content });
|
|
6409
|
-
const content = contents.find((content
|
|
6414
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6410
6415
|
const schema = content ? content.schema : void 0;
|
|
6411
6416
|
const irRequestBody = { schema: schemaToIrSchema$1({
|
|
6412
6417
|
context,
|
|
@@ -6454,14 +6459,14 @@ const validateOpenApiSpec$1 = (spec, logger) => {
|
|
|
6454
6459
|
const issues = [];
|
|
6455
6460
|
const operationIds = /* @__PURE__ */ new Map();
|
|
6456
6461
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
6457
|
-
const path
|
|
6462
|
+
const path = entry[0];
|
|
6458
6463
|
const pathItem = entry[1];
|
|
6459
6464
|
for (const method of httpMethods) {
|
|
6460
6465
|
const operation = pathItem[method];
|
|
6461
6466
|
if (!operation) continue;
|
|
6462
6467
|
const operationKey = createOperationKey({
|
|
6463
6468
|
method,
|
|
6464
|
-
path
|
|
6469
|
+
path
|
|
6465
6470
|
});
|
|
6466
6471
|
if (operation.operationId) if (!operationIds.has(operation.operationId)) operationIds.set(operation.operationId, operationKey);
|
|
6467
6472
|
else issues.push({
|
|
@@ -6473,7 +6478,7 @@ const validateOpenApiSpec$1 = (spec, logger) => {
|
|
|
6473
6478
|
message: "Duplicate `operationId` found. Each `operationId` must be unique.",
|
|
6474
6479
|
path: [
|
|
6475
6480
|
"paths",
|
|
6476
|
-
path
|
|
6481
|
+
path,
|
|
6477
6482
|
method,
|
|
6478
6483
|
"operationId"
|
|
6479
6484
|
],
|
|
@@ -6525,8 +6530,8 @@ const parseV3_0_X = (context) => {
|
|
|
6525
6530
|
});
|
|
6526
6531
|
if (hasFilters(context.config.parser.filters)) {
|
|
6527
6532
|
const filters = createFilters(context.config.parser.filters, context.spec, context.logger);
|
|
6528
|
-
const { graph
|
|
6529
|
-
const { resourceMetadata } = buildResourceMetadata(graph
|
|
6533
|
+
const { graph } = buildGraph(context.spec, context.logger);
|
|
6534
|
+
const { resourceMetadata } = buildResourceMetadata(graph, context.logger);
|
|
6530
6535
|
filterSpec$1({
|
|
6531
6536
|
...createFilteredDependencies({
|
|
6532
6537
|
filters,
|
|
@@ -6576,9 +6581,9 @@ const parseV3_0_X = (context) => {
|
|
|
6576
6581
|
}
|
|
6577
6582
|
}
|
|
6578
6583
|
parseServers$1({ context });
|
|
6579
|
-
for (const path
|
|
6580
|
-
if (path
|
|
6581
|
-
const pathItem = context.spec.paths[path
|
|
6584
|
+
for (const path in context.spec.paths) {
|
|
6585
|
+
if (path.startsWith("x-")) continue;
|
|
6586
|
+
const pathItem = context.spec.paths[path];
|
|
6582
6587
|
const finalPathItem = pathItem.$ref ? {
|
|
6583
6588
|
...context.resolveRef(pathItem.$ref),
|
|
6584
6589
|
...pathItem
|
|
@@ -6595,7 +6600,7 @@ const parseV3_0_X = (context) => {
|
|
|
6595
6600
|
servers: finalPathItem.servers,
|
|
6596
6601
|
summary: finalPathItem.summary
|
|
6597
6602
|
},
|
|
6598
|
-
path
|
|
6603
|
+
path,
|
|
6599
6604
|
securitySchemesMap,
|
|
6600
6605
|
state
|
|
6601
6606
|
};
|
|
@@ -6776,17 +6781,17 @@ const filterSpec = ({ logger, operations, parameters, preserveOrder, requestBodi
|
|
|
6776
6781
|
}
|
|
6777
6782
|
}
|
|
6778
6783
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
6779
|
-
const path
|
|
6784
|
+
const path = entry[0];
|
|
6780
6785
|
const pathItem = entry[1];
|
|
6781
6786
|
for (const method of httpMethods) {
|
|
6782
6787
|
if (!pathItem[method]) continue;
|
|
6783
6788
|
const key = addNamespace("operation", createOperationKey({
|
|
6784
6789
|
method,
|
|
6785
|
-
path
|
|
6790
|
+
path
|
|
6786
6791
|
}));
|
|
6787
6792
|
if (!operations.has(key)) delete pathItem[method];
|
|
6788
6793
|
}
|
|
6789
|
-
if (!Object.keys(pathItem).length) delete spec.paths[path
|
|
6794
|
+
if (!Object.keys(pathItem).length) delete spec.paths[path];
|
|
6790
6795
|
}
|
|
6791
6796
|
eventFilterSpec.timeEnd();
|
|
6792
6797
|
};
|
|
@@ -7005,6 +7010,25 @@ const parseObject = ({ context, irSchema = {}, schema, state }) => {
|
|
|
7005
7010
|
state
|
|
7006
7011
|
});
|
|
7007
7012
|
if (schema.required) irSchema.required = schema.required;
|
|
7013
|
+
if (schema.discriminator && state.$ref) {
|
|
7014
|
+
const values = getAllDiscriminatorValues({
|
|
7015
|
+
discriminator: schema.discriminator,
|
|
7016
|
+
schemaRef: state.$ref
|
|
7017
|
+
});
|
|
7018
|
+
if (values.length) {
|
|
7019
|
+
const propertyType = findDiscriminatorPropertyType({
|
|
7020
|
+
context,
|
|
7021
|
+
propertyName: schema.discriminator.propertyName,
|
|
7022
|
+
schemas: [schema]
|
|
7023
|
+
});
|
|
7024
|
+
const valueSchemas = values.map((value) => convertDiscriminatorValue(value, propertyType));
|
|
7025
|
+
if (!irSchema.properties) irSchema.properties = {};
|
|
7026
|
+
irSchema.properties[schema.discriminator.propertyName] = valueSchemas.length > 1 ? {
|
|
7027
|
+
items: valueSchemas,
|
|
7028
|
+
logicalOperator: "or"
|
|
7029
|
+
} : valueSchemas[0];
|
|
7030
|
+
}
|
|
7031
|
+
}
|
|
7008
7032
|
return irSchema;
|
|
7009
7033
|
};
|
|
7010
7034
|
const parseString = ({ irSchema = {} }) => {
|
|
@@ -7050,11 +7074,11 @@ const parseAllOf = ({ context, schema, state }) => {
|
|
|
7050
7074
|
else irCompositionSchema.required = schema.required;
|
|
7051
7075
|
schemaItems.push(irCompositionSchema);
|
|
7052
7076
|
if (compositionSchema.$ref) {
|
|
7053
|
-
const ref
|
|
7077
|
+
const ref = context.resolveRef(compositionSchema.$ref);
|
|
7054
7078
|
if (state.$ref) {
|
|
7055
7079
|
const discriminators = findDiscriminatorsInSchema({
|
|
7056
7080
|
context,
|
|
7057
|
-
schema: ref
|
|
7081
|
+
schema: ref
|
|
7058
7082
|
});
|
|
7059
7083
|
for (const { discriminator, oneOf } of discriminators) {
|
|
7060
7084
|
const values = discriminatorValues(state.$ref, discriminator.mapping, oneOf ? () => oneOf.some((o) => "$ref" in o && o.$ref === state.$ref) : void 0);
|
|
@@ -7063,7 +7087,7 @@ const parseAllOf = ({ context, schema, state }) => {
|
|
|
7063
7087
|
const existingIndex = discriminatorsToAdd.findIndex((d) => d.discriminator.propertyName === discriminator.propertyName);
|
|
7064
7088
|
if (existingIndex !== -1) if (isExplicitMapping && !discriminatorsToAdd[existingIndex].isExplicitMapping) discriminatorsToAdd.splice(existingIndex, 1);
|
|
7065
7089
|
else continue;
|
|
7066
|
-
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref
|
|
7090
|
+
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref.required?.includes(d.discriminator.propertyName) || ref.allOf && ref.allOf.some((item) => {
|
|
7067
7091
|
return (item.$ref ? context.resolveRef(item.$ref) : item).required?.includes(d.discriminator.propertyName);
|
|
7068
7092
|
})));
|
|
7069
7093
|
discriminatorsToAdd.push({
|
|
@@ -7332,13 +7356,13 @@ const parseRef = ({ context, schema, state }) => {
|
|
|
7332
7356
|
const refSchema = context.resolveRef(schema.$ref);
|
|
7333
7357
|
const originalRef = state.$ref;
|
|
7334
7358
|
state.$ref = schema.$ref;
|
|
7335
|
-
const irSchema
|
|
7359
|
+
const irSchema = schemaToIrSchema({
|
|
7336
7360
|
context,
|
|
7337
7361
|
schema: refSchema,
|
|
7338
7362
|
state
|
|
7339
7363
|
});
|
|
7340
7364
|
state.$ref = originalRef;
|
|
7341
|
-
return irSchema
|
|
7365
|
+
return irSchema;
|
|
7342
7366
|
}
|
|
7343
7367
|
}
|
|
7344
7368
|
let irSchema = initIrSchema({ schema });
|
|
@@ -7548,13 +7572,13 @@ const isPaginationType = (schemaTypes) => schemaTypes.includes("boolean") || sch
|
|
|
7548
7572
|
const paginationField = ({ context, name, schema }) => {
|
|
7549
7573
|
if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) return true;
|
|
7550
7574
|
if (schema.$ref) {
|
|
7551
|
-
const ref
|
|
7552
|
-
if ("content" in ref
|
|
7575
|
+
const ref = context.resolveRef(schema.$ref);
|
|
7576
|
+
if ("content" in ref || "in" in ref) {
|
|
7553
7577
|
let refSchema;
|
|
7554
|
-
if ("in" in ref
|
|
7578
|
+
if ("in" in ref) refSchema = ref.schema;
|
|
7555
7579
|
if (!refSchema) {
|
|
7556
|
-
const contents = mediaTypeObjects({ content: ref
|
|
7557
|
-
const content = contents.find((content
|
|
7580
|
+
const contents = mediaTypeObjects({ content: ref.content });
|
|
7581
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7558
7582
|
if (content?.schema) refSchema = content.schema;
|
|
7559
7583
|
}
|
|
7560
7584
|
if (!refSchema) return false;
|
|
@@ -7567,20 +7591,20 @@ const paginationField = ({ context, name, schema }) => {
|
|
|
7567
7591
|
return paginationField({
|
|
7568
7592
|
context,
|
|
7569
7593
|
name,
|
|
7570
|
-
schema: ref
|
|
7594
|
+
schema: ref
|
|
7571
7595
|
});
|
|
7572
7596
|
}
|
|
7573
|
-
for (const name
|
|
7574
|
-
const property = schema.properties[name
|
|
7597
|
+
for (const name in schema.properties) if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) {
|
|
7598
|
+
const property = schema.properties[name];
|
|
7575
7599
|
if (typeof property !== "boolean") {
|
|
7576
7600
|
const schemaTypes = getSchemaTypes({ schema: property });
|
|
7577
7601
|
if (!schemaTypes.length) {
|
|
7578
|
-
const nonNullCompositionSchemas = (property.anyOf ?? property.oneOf ?? []).filter((schema
|
|
7602
|
+
const nonNullCompositionSchemas = (property.anyOf ?? property.oneOf ?? []).filter((schema) => schema.type !== "null");
|
|
7579
7603
|
if (nonNullCompositionSchemas.length === 1) {
|
|
7580
|
-
if (isPaginationType(getSchemaTypes({ schema: nonNullCompositionSchemas[0] }))) return name
|
|
7604
|
+
if (isPaginationType(getSchemaTypes({ schema: nonNullCompositionSchemas[0] }))) return name;
|
|
7581
7605
|
}
|
|
7582
7606
|
}
|
|
7583
|
-
if (isPaginationType(schemaTypes)) return name
|
|
7607
|
+
if (isPaginationType(schemaTypes)) return name;
|
|
7584
7608
|
}
|
|
7585
7609
|
}
|
|
7586
7610
|
for (const allOf of schema.allOf ?? []) {
|
|
@@ -7602,17 +7626,17 @@ const parseOperationJsDoc = ({ irOperation, operation }) => {
|
|
|
7602
7626
|
if (operation.summary) irOperation.summary = operation.summary;
|
|
7603
7627
|
if (operation.tags?.length) irOperation.tags = operation.tags;
|
|
7604
7628
|
};
|
|
7605
|
-
const initIrOperation = ({ context, method, operation, path
|
|
7629
|
+
const initIrOperation = ({ context, method, operation, path, state }) => {
|
|
7606
7630
|
const irOperation = {
|
|
7607
7631
|
id: operationToId({
|
|
7608
7632
|
context,
|
|
7609
7633
|
id: operation.operationId,
|
|
7610
7634
|
method,
|
|
7611
|
-
path
|
|
7635
|
+
path,
|
|
7612
7636
|
state
|
|
7613
7637
|
}),
|
|
7614
7638
|
method,
|
|
7615
|
-
path
|
|
7639
|
+
path
|
|
7616
7640
|
};
|
|
7617
7641
|
if (operation.operationId) irOperation.operationId = operation.operationId;
|
|
7618
7642
|
parseOperationJsDoc({
|
|
@@ -7625,19 +7649,19 @@ const initIrOperation = ({ context, method, operation, path: path$1, state }) =>
|
|
|
7625
7649
|
});
|
|
7626
7650
|
return irOperation;
|
|
7627
7651
|
};
|
|
7628
|
-
const operationToIrOperation = ({ context, method, operation, path
|
|
7652
|
+
const operationToIrOperation = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
7629
7653
|
const irOperation = initIrOperation({
|
|
7630
7654
|
context,
|
|
7631
7655
|
method,
|
|
7632
7656
|
operation,
|
|
7633
|
-
path
|
|
7657
|
+
path,
|
|
7634
7658
|
state
|
|
7635
7659
|
});
|
|
7636
7660
|
if (operation.parameters) irOperation.parameters = operation.parameters;
|
|
7637
7661
|
if (operation.requestBody) {
|
|
7638
7662
|
const requestBody = "$ref" in operation.requestBody ? context.resolveRef(operation.requestBody.$ref) : operation.requestBody;
|
|
7639
7663
|
const contents = mediaTypeObjects({ content: requestBody.content });
|
|
7640
|
-
const content = contents.find((content
|
|
7664
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7641
7665
|
if (content) {
|
|
7642
7666
|
const pagination = paginationField({
|
|
7643
7667
|
context,
|
|
@@ -7669,7 +7693,7 @@ const operationToIrOperation = ({ context, method, operation, path: path$1, secu
|
|
|
7669
7693
|
const response = operation.responses[name];
|
|
7670
7694
|
const responseObject = "$ref" in response ? context.resolveRef(response.$ref) : response;
|
|
7671
7695
|
const contents = mediaTypeObjects({ content: responseObject.content });
|
|
7672
|
-
const content = contents.find((content
|
|
7696
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7673
7697
|
if (content) irOperation.responses[name] = {
|
|
7674
7698
|
mediaType: content.mediaType,
|
|
7675
7699
|
schema: schemaToIrSchema({
|
|
@@ -7697,27 +7721,27 @@ const operationToIrOperation = ({ context, method, operation, path: path$1, secu
|
|
|
7697
7721
|
}
|
|
7698
7722
|
return irOperation;
|
|
7699
7723
|
};
|
|
7700
|
-
const parseOperationObject = ({ context, method, operation, path
|
|
7724
|
+
const parseOperationObject = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
7701
7725
|
if (operation.servers) context.ir.servers = [...context.ir.servers ?? [], ...operation.servers];
|
|
7702
7726
|
return { parsed: operationToIrOperation({
|
|
7703
7727
|
context,
|
|
7704
7728
|
method,
|
|
7705
7729
|
operation,
|
|
7706
|
-
path
|
|
7730
|
+
path,
|
|
7707
7731
|
securitySchemesMap,
|
|
7708
7732
|
state
|
|
7709
7733
|
}) };
|
|
7710
7734
|
};
|
|
7711
|
-
const parsePathOperation = ({ context, method, path
|
|
7735
|
+
const parsePathOperation = ({ context, method, path, ...options }) => {
|
|
7712
7736
|
if (!context.ir.paths) context.ir.paths = {};
|
|
7713
|
-
if (!context.ir.paths[path
|
|
7737
|
+
if (!context.ir.paths[path]) context.ir.paths[path] = {};
|
|
7714
7738
|
const { parsed } = parseOperationObject({
|
|
7715
7739
|
context,
|
|
7716
7740
|
method,
|
|
7717
|
-
path
|
|
7741
|
+
path,
|
|
7718
7742
|
...options
|
|
7719
7743
|
});
|
|
7720
|
-
context.ir.paths[path
|
|
7744
|
+
context.ir.paths[path][method] = parsed;
|
|
7721
7745
|
};
|
|
7722
7746
|
const parseWebhookOperation = ({ context, key, method, ...options }) => {
|
|
7723
7747
|
if (!context.ir.webhooks) context.ir.webhooks = {};
|
|
@@ -7781,7 +7805,7 @@ const parameterToIrParameter = ({ $ref, context, parameter }) => {
|
|
|
7781
7805
|
let schema = parameter.schema;
|
|
7782
7806
|
if (!schema) {
|
|
7783
7807
|
const contents = mediaTypeObjects({ content: parameter.content });
|
|
7784
|
-
const content = contents.find((content
|
|
7808
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7785
7809
|
if (content) schema = content.schema;
|
|
7786
7810
|
}
|
|
7787
7811
|
const finalSchema = {
|
|
@@ -7835,7 +7859,7 @@ const parseParameter = ({ $ref, context, parameter }) => {
|
|
|
7835
7859
|
//#region src/openApi/3.1.x/parser/requestBody.ts
|
|
7836
7860
|
const requestBodyToIrRequestBody = ({ $ref, context, requestBody }) => {
|
|
7837
7861
|
const contents = mediaTypeObjects({ content: requestBody.content });
|
|
7838
|
-
const content = contents.find((content
|
|
7862
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7839
7863
|
const schema = content ? content.schema : void 0;
|
|
7840
7864
|
const irRequestBody = { schema: schemaToIrSchema({
|
|
7841
7865
|
context,
|
|
@@ -7883,14 +7907,14 @@ const validateOpenApiSpec = (spec, logger) => {
|
|
|
7883
7907
|
const issues = [];
|
|
7884
7908
|
const operationIds = /* @__PURE__ */ new Map();
|
|
7885
7909
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
7886
|
-
const path
|
|
7910
|
+
const path = entry[0];
|
|
7887
7911
|
const pathItem = entry[1];
|
|
7888
7912
|
for (const method of httpMethods) {
|
|
7889
7913
|
const operation = pathItem[method];
|
|
7890
7914
|
if (!operation) continue;
|
|
7891
7915
|
const operationKey = createOperationKey({
|
|
7892
7916
|
method,
|
|
7893
|
-
path
|
|
7917
|
+
path
|
|
7894
7918
|
});
|
|
7895
7919
|
if (operation.operationId) if (!operationIds.has(operation.operationId)) operationIds.set(operation.operationId, operationKey);
|
|
7896
7920
|
else issues.push({
|
|
@@ -7902,7 +7926,7 @@ const validateOpenApiSpec = (spec, logger) => {
|
|
|
7902
7926
|
message: "Duplicate `operationId` found. Each `operationId` must be unique.",
|
|
7903
7927
|
path: [
|
|
7904
7928
|
"paths",
|
|
7905
|
-
path
|
|
7929
|
+
path,
|
|
7906
7930
|
method,
|
|
7907
7931
|
"operationId"
|
|
7908
7932
|
],
|
|
@@ -8103,8 +8127,8 @@ const parseV3_1_X = (context) => {
|
|
|
8103
8127
|
});
|
|
8104
8128
|
if (hasFilters(context.config.parser.filters)) {
|
|
8105
8129
|
const filters = createFilters(context.config.parser.filters, context.spec, context.logger);
|
|
8106
|
-
const { graph
|
|
8107
|
-
const { resourceMetadata } = buildResourceMetadata(graph
|
|
8130
|
+
const { graph } = buildGraph(context.spec, context.logger);
|
|
8131
|
+
const { resourceMetadata } = buildResourceMetadata(graph, context.logger);
|
|
8108
8132
|
filterSpec({
|
|
8109
8133
|
...createFilteredDependencies({
|
|
8110
8134
|
filters,
|
|
@@ -8154,9 +8178,9 @@ const parseV3_1_X = (context) => {
|
|
|
8154
8178
|
}
|
|
8155
8179
|
}
|
|
8156
8180
|
parseServers({ context });
|
|
8157
|
-
for (const path
|
|
8158
|
-
if (path
|
|
8159
|
-
const pathItem = context.spec.paths[path
|
|
8181
|
+
for (const path in context.spec.paths) {
|
|
8182
|
+
if (path.startsWith("x-")) continue;
|
|
8183
|
+
const pathItem = context.spec.paths[path];
|
|
8160
8184
|
const finalPathItem = pathItem.$ref ? {
|
|
8161
8185
|
...context.resolveRef(pathItem.$ref),
|
|
8162
8186
|
...pathItem
|
|
@@ -8173,7 +8197,7 @@ const parseV3_1_X = (context) => {
|
|
|
8173
8197
|
servers: finalPathItem.servers,
|
|
8174
8198
|
summary: finalPathItem.summary
|
|
8175
8199
|
},
|
|
8176
|
-
path
|
|
8200
|
+
path,
|
|
8177
8201
|
securitySchemesMap,
|
|
8178
8202
|
state
|
|
8179
8203
|
};
|
|
@@ -8396,7 +8420,7 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8396
8420
|
const patchFn = patchOptions.schemas[key];
|
|
8397
8421
|
await patchFn(schema);
|
|
8398
8422
|
}
|
|
8399
|
-
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path
|
|
8423
|
+
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
8400
8424
|
if (!pathItem || typeof pathItem !== "object") continue;
|
|
8401
8425
|
for (const method of [
|
|
8402
8426
|
"get",
|
|
@@ -8410,13 +8434,13 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8410
8434
|
]) {
|
|
8411
8435
|
const operation = pathItem[method];
|
|
8412
8436
|
if (!operation || typeof operation !== "object") continue;
|
|
8413
|
-
await patchOptions.operations(method, path
|
|
8437
|
+
await patchOptions.operations(method, path, operation);
|
|
8414
8438
|
}
|
|
8415
8439
|
}
|
|
8416
8440
|
else for (const key in patchOptions.operations) {
|
|
8417
|
-
const [method, path
|
|
8418
|
-
if (!method || !path
|
|
8419
|
-
const pathItem = spec.paths[path
|
|
8441
|
+
const [method, path] = key.split(" ");
|
|
8442
|
+
if (!method || !path) continue;
|
|
8443
|
+
const pathItem = spec.paths[path];
|
|
8420
8444
|
if (!pathItem) continue;
|
|
8421
8445
|
const operation = pathItem[method.toLocaleLowerCase()] || pathItem[method.toLocaleUpperCase()];
|
|
8422
8446
|
if (!operation || typeof operation !== "object") continue;
|
|
@@ -8455,7 +8479,7 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8455
8479
|
patchFn(schema);
|
|
8456
8480
|
}
|
|
8457
8481
|
}
|
|
8458
|
-
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path
|
|
8482
|
+
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
8459
8483
|
if (!pathItem || typeof pathItem !== "object") continue;
|
|
8460
8484
|
for (const method of [
|
|
8461
8485
|
"get",
|
|
@@ -8469,13 +8493,13 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8469
8493
|
]) {
|
|
8470
8494
|
const operation = pathItem[method];
|
|
8471
8495
|
if (!operation || typeof operation !== "object") continue;
|
|
8472
|
-
await patchOptions.operations(method, path
|
|
8496
|
+
await patchOptions.operations(method, path, operation);
|
|
8473
8497
|
}
|
|
8474
8498
|
}
|
|
8475
8499
|
else for (const key in patchOptions.operations) {
|
|
8476
|
-
const [method, path
|
|
8477
|
-
if (!method || !path
|
|
8478
|
-
const pathItem = spec.paths[path
|
|
8500
|
+
const [method, path] = key.split(" ");
|
|
8501
|
+
if (!method || !path) continue;
|
|
8502
|
+
const pathItem = spec.paths[path];
|
|
8479
8503
|
if (!pathItem) continue;
|
|
8480
8504
|
const operation = pathItem[method.toLocaleLowerCase()] || pathItem[method.toLocaleUpperCase()];
|
|
8481
8505
|
if (!operation || typeof operation !== "object") continue;
|
|
@@ -8552,9 +8576,14 @@ const utils = {
|
|
|
8552
8576
|
/**
|
|
8553
8577
|
* Converts an {@link OutputHeader} value to a string prefix for file content.
|
|
8554
8578
|
*/
|
|
8555
|
-
function outputHeaderToPrefix(
|
|
8556
|
-
|
|
8557
|
-
|
|
8579
|
+
function outputHeaderToPrefix(ctx) {
|
|
8580
|
+
const { defaultValue, header, project } = ctx;
|
|
8581
|
+
let lines = typeof header === "function" ? header({
|
|
8582
|
+
defaultValue,
|
|
8583
|
+
project
|
|
8584
|
+
}) : header;
|
|
8585
|
+
if (lines === void 0) lines = defaultValue;
|
|
8586
|
+
if (lines === null) return "";
|
|
8558
8587
|
lines = typeof lines === "string" ? lines.split(/\r?\n/) : lines.flatMap((line) => line.split(/\r?\n/));
|
|
8559
8588
|
const content = lines.join("\n");
|
|
8560
8589
|
return content ? `${content}\n\n` : "";
|
|
@@ -8628,35 +8657,35 @@ function sanitizeSegment(segment) {
|
|
|
8628
8657
|
* paths//event/get/properties/query, { anchor: 'event.subscribe' }
|
|
8629
8658
|
* → 'event.subscribe-Query'
|
|
8630
8659
|
*/
|
|
8631
|
-
function pathToName(path
|
|
8660
|
+
function pathToName(path, options) {
|
|
8632
8661
|
const names = [];
|
|
8633
8662
|
let index = 0;
|
|
8634
|
-
const rootContext = ROOT_CONTEXT[path
|
|
8663
|
+
const rootContext = ROOT_CONTEXT[path[0]];
|
|
8635
8664
|
if (rootContext) {
|
|
8636
8665
|
index = rootContext.skip;
|
|
8637
8666
|
if (options?.anchor) {
|
|
8638
8667
|
names.push(options.anchor);
|
|
8639
8668
|
index += rootContext.names;
|
|
8640
|
-
} else for (let n = 0; n < rootContext.names && index < path
|
|
8641
|
-
names.push(sanitizeSegment(path
|
|
8669
|
+
} else for (let n = 0; n < rootContext.names && index < path.length; n++) {
|
|
8670
|
+
names.push(sanitizeSegment(path[index]));
|
|
8642
8671
|
index++;
|
|
8643
8672
|
}
|
|
8644
8673
|
} else if (options?.anchor) {
|
|
8645
8674
|
names.push(options.anchor);
|
|
8646
8675
|
index++;
|
|
8647
|
-
} else if (index < path
|
|
8648
|
-
names.push(sanitizeSegment(path
|
|
8676
|
+
} else if (index < path.length) {
|
|
8677
|
+
names.push(sanitizeSegment(path[index]));
|
|
8649
8678
|
index++;
|
|
8650
8679
|
}
|
|
8651
|
-
while (index < path
|
|
8652
|
-
const segment = String(path
|
|
8680
|
+
while (index < path.length) {
|
|
8681
|
+
const segment = String(path[index]);
|
|
8653
8682
|
const role = STRUCTURAL_ROLE[segment];
|
|
8654
8683
|
if (role === "name") {
|
|
8655
8684
|
index++;
|
|
8656
|
-
if (index < path
|
|
8685
|
+
if (index < path.length) names.push(sanitizeSegment(path[index]));
|
|
8657
8686
|
} else if (role === "index") {
|
|
8658
8687
|
index++;
|
|
8659
|
-
if (index < path
|
|
8688
|
+
if (index < path.length && typeof path[index] === "number") index++;
|
|
8660
8689
|
continue;
|
|
8661
8690
|
} else if (STRUCTURAL_SUFFIX[segment]) names.push(STRUCTURAL_SUFFIX[segment]);
|
|
8662
8691
|
index++;
|
|
@@ -8665,5 +8694,5 @@ function pathToName(path$1, options) {
|
|
|
8665
8694
|
}
|
|
8666
8695
|
|
|
8667
8696
|
//#endregion
|
|
8668
|
-
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,
|
|
8697
|
+
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 };
|
|
8669
8698
|
//# sourceMappingURL=index.mjs.map
|