@hey-api/shared 0.2.2 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.d.mts +109 -84
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +436 -410
- 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
|
|
@@ -91,6 +85,12 @@ const asciiToLines = (ascii, options) => {
|
|
|
91
85
|
maxLineLength
|
|
92
86
|
};
|
|
93
87
|
};
|
|
88
|
+
/**
|
|
89
|
+
* Checks the current environment based on the HEYAPI_CODEGEN_ENV environment variable.
|
|
90
|
+
*/
|
|
91
|
+
function isEnvironment(value) {
|
|
92
|
+
return process.env.HEYAPI_CODEGEN_ENV === value;
|
|
93
|
+
}
|
|
94
94
|
function printCliIntro(initialDir, showLogo = false) {
|
|
95
95
|
const packageJson = loadPackageJson(initialDir);
|
|
96
96
|
if (packageJson) {
|
|
@@ -98,15 +98,16 @@ function printCliIntro(initialDir, showLogo = false) {
|
|
|
98
98
|
const text = asciiToLines(textAscii, { padding: 1 });
|
|
99
99
|
for (const line of text.lines) console.log(colors.cyan(line));
|
|
100
100
|
}
|
|
101
|
-
|
|
101
|
+
const versionString = isEnvironment("development") ? "[DEVELOPMENT]" : `v${packageJson.version}`;
|
|
102
|
+
console.log(colors.gray(`${packageJson.name} ${versionString}`));
|
|
102
103
|
}
|
|
103
104
|
console.log("");
|
|
104
105
|
}
|
|
105
106
|
|
|
106
107
|
//#endregion
|
|
107
108
|
//#region src/fs.ts
|
|
108
|
-
function ensureDirSync(path
|
|
109
|
-
if (!fs.existsSync(path
|
|
109
|
+
function ensureDirSync(path) {
|
|
110
|
+
if (!fs.existsSync(path)) fs.mkdirSync(path, { recursive: true });
|
|
110
111
|
}
|
|
111
112
|
|
|
112
113
|
//#endregion
|
|
@@ -200,9 +201,7 @@ async function openGitHubIssueWithCrashReport(error, initialDir) {
|
|
|
200
201
|
labels: "bug 🔥",
|
|
201
202
|
title: "Crash Report"
|
|
202
203
|
});
|
|
203
|
-
|
|
204
|
-
const open = (await import("open")).default;
|
|
205
|
-
await open(url);
|
|
204
|
+
await open(`${packageJson.bugs.url}new?${search.toString()}`);
|
|
206
205
|
}
|
|
207
206
|
function printCrashReport({ error, logPath }) {
|
|
208
207
|
if (error instanceof ConfigValidationError && error.errors.length) {
|
|
@@ -422,7 +421,7 @@ function inputToApiRegistry(input) {
|
|
|
422
421
|
return;
|
|
423
422
|
}
|
|
424
423
|
if (input.path.startsWith(".")) return;
|
|
425
|
-
if (input.path.startsWith(
|
|
424
|
+
if (input.path.startsWith("https://get.heyapi.dev")) {
|
|
426
425
|
input.path = input.path.slice(heyApiRegistryBaseUrl.length + 1);
|
|
427
426
|
Object.assign(input, inputToHeyApiPath(input));
|
|
428
427
|
return;
|
|
@@ -497,9 +496,9 @@ function compileInputPath(input) {
|
|
|
497
496
|
}
|
|
498
497
|
const [basePath, baseQuery] = input.path.split("?");
|
|
499
498
|
const queryPath = (baseQuery || "").split("&").map((part) => part.split("="));
|
|
500
|
-
let path
|
|
501
|
-
if (path
|
|
502
|
-
const [, pathUrl] = path
|
|
499
|
+
let path = basePath || "";
|
|
500
|
+
if (path.endsWith("/")) path = path.slice(0, path.length - 1);
|
|
501
|
+
const [, pathUrl] = path.split("://");
|
|
503
502
|
const [baseUrl, organization, project] = (pathUrl || "").split("/");
|
|
504
503
|
result.organization = organization || input.organization;
|
|
505
504
|
result.project = project || input.project;
|
|
@@ -622,36 +621,36 @@ const mergeResult = (result, mapped) => {
|
|
|
622
621
|
for (const [key, value] of Object.entries(mapped)) if (value !== void 0 && value !== "") result[key] = value;
|
|
623
622
|
return result;
|
|
624
623
|
};
|
|
625
|
-
const valueToObject = ({ defaultValue, mappers
|
|
624
|
+
const valueToObject = ({ defaultValue, mappers, value }) => {
|
|
626
625
|
let result = { ...defaultValue };
|
|
627
626
|
switch (typeof value) {
|
|
628
627
|
case "boolean":
|
|
629
|
-
if (mappers
|
|
630
|
-
const mapper = mappers
|
|
628
|
+
if (mappers && "boolean" in mappers) {
|
|
629
|
+
const mapper = mappers.boolean;
|
|
631
630
|
result = mergeResult(result, mapper(value));
|
|
632
631
|
}
|
|
633
632
|
break;
|
|
634
633
|
case "function":
|
|
635
|
-
if (mappers
|
|
636
|
-
const mapper = mappers
|
|
634
|
+
if (mappers && "function" in mappers) {
|
|
635
|
+
const mapper = mappers.function;
|
|
637
636
|
result = mergeResult(result, mapper(value));
|
|
638
637
|
}
|
|
639
638
|
break;
|
|
640
639
|
case "number":
|
|
641
|
-
if (mappers
|
|
642
|
-
const mapper = mappers
|
|
640
|
+
if (mappers && "number" in mappers) {
|
|
641
|
+
const mapper = mappers.number;
|
|
643
642
|
result = mergeResult(result, mapper(value));
|
|
644
643
|
}
|
|
645
644
|
break;
|
|
646
645
|
case "string":
|
|
647
|
-
if (mappers
|
|
648
|
-
const mapper = mappers
|
|
646
|
+
if (mappers && "string" in mappers) {
|
|
647
|
+
const mapper = mappers.string;
|
|
649
648
|
result = mergeResult(result, mapper(value));
|
|
650
649
|
}
|
|
651
650
|
break;
|
|
652
651
|
case "object":
|
|
653
|
-
if (isPlainObject(value)) if (mappers
|
|
654
|
-
const mapper = mappers
|
|
652
|
+
if (isPlainObject(value)) if (mappers && "object" in mappers && typeof mappers.object === "function") {
|
|
653
|
+
const mapper = mappers.object;
|
|
655
654
|
result = mergeResult(result, mapper(value, defaultValue));
|
|
656
655
|
} else result = mergeResult(result, value);
|
|
657
656
|
break;
|
|
@@ -723,50 +722,50 @@ function getParser(userConfig) {
|
|
|
723
722
|
}),
|
|
724
723
|
transforms: valueToObject({
|
|
725
724
|
defaultValue: { ...defaultValue.transforms },
|
|
726
|
-
mappers: { object: (fields
|
|
727
|
-
...fields
|
|
725
|
+
mappers: { object: (fields, defaultValue) => ({
|
|
726
|
+
...fields,
|
|
728
727
|
enums: valueToObject({
|
|
729
728
|
defaultValue: {
|
|
730
|
-
...defaultValue
|
|
731
|
-
enabled: fields
|
|
729
|
+
...defaultValue.enums,
|
|
730
|
+
enabled: fields.enums !== void 0 ? Boolean(fields.enums) : defaultValue.enums.enabled
|
|
732
731
|
},
|
|
733
732
|
mappers: {
|
|
734
733
|
boolean: (enabled) => ({ enabled }),
|
|
735
734
|
string: (mode) => ({ mode })
|
|
736
735
|
},
|
|
737
|
-
value: fields
|
|
736
|
+
value: fields.enums
|
|
738
737
|
}),
|
|
739
|
-
propertiesRequiredByDefault: fields
|
|
738
|
+
propertiesRequiredByDefault: fields.propertiesRequiredByDefault !== void 0 ? fields.propertiesRequiredByDefault : defaultValue.propertiesRequiredByDefault,
|
|
740
739
|
readWrite: valueToObject({
|
|
741
740
|
defaultValue: {
|
|
742
|
-
...defaultValue
|
|
743
|
-
enabled: fields
|
|
741
|
+
...defaultValue.readWrite,
|
|
742
|
+
enabled: fields.readWrite !== void 0 ? Boolean(fields.readWrite) : defaultValue.readWrite.enabled
|
|
744
743
|
},
|
|
745
744
|
mappers: {
|
|
746
745
|
boolean: (enabled) => ({ enabled }),
|
|
747
|
-
object: (fields
|
|
748
|
-
...fields
|
|
746
|
+
object: (fields, defaultValue) => ({
|
|
747
|
+
...fields,
|
|
749
748
|
requests: valueToObject({
|
|
750
|
-
defaultValue: { ...defaultValue
|
|
749
|
+
defaultValue: { ...defaultValue.requests },
|
|
751
750
|
mappers: {
|
|
752
751
|
function: (name) => ({ name }),
|
|
753
752
|
string: (name) => ({ name })
|
|
754
753
|
},
|
|
755
|
-
value: fields
|
|
754
|
+
value: fields.requests
|
|
756
755
|
}),
|
|
757
756
|
responses: valueToObject({
|
|
758
|
-
defaultValue: { ...defaultValue
|
|
757
|
+
defaultValue: { ...defaultValue.responses },
|
|
759
758
|
mappers: {
|
|
760
759
|
function: (name) => ({ name }),
|
|
761
760
|
string: (name) => ({ name })
|
|
762
761
|
},
|
|
763
|
-
value: fields
|
|
762
|
+
value: fields.responses
|
|
764
763
|
})
|
|
765
764
|
})
|
|
766
765
|
},
|
|
767
|
-
value: fields
|
|
766
|
+
value: fields.readWrite
|
|
768
767
|
}),
|
|
769
|
-
schemaName: fields
|
|
768
|
+
schemaName: fields.schemaName !== void 0 ? fields.schemaName : defaultValue.schemaName
|
|
770
769
|
}) },
|
|
771
770
|
value: fields.transforms
|
|
772
771
|
}),
|
|
@@ -803,31 +802,31 @@ function dependencyFactory(dependencies) {
|
|
|
803
802
|
|
|
804
803
|
//#endregion
|
|
805
804
|
//#region src/debug/graph.ts
|
|
806
|
-
const analyzeStructure = (graph
|
|
805
|
+
const analyzeStructure = (graph) => {
|
|
807
806
|
let maxDepth = 0;
|
|
808
807
|
let maxChildren = 0;
|
|
809
808
|
const computeDepth = (pointer, depth) => {
|
|
810
809
|
maxDepth = Math.max(maxDepth, depth);
|
|
811
|
-
const children = Array.from(graph
|
|
810
|
+
const children = Array.from(graph.nodes.entries()).filter(([, nodeInfo]) => nodeInfo.parentPointer === pointer).map(([childPointer]) => childPointer);
|
|
812
811
|
maxChildren = Math.max(maxChildren, children.length);
|
|
813
812
|
for (const childPointer of children) computeDepth(childPointer, depth + 1);
|
|
814
813
|
};
|
|
815
|
-
const totalNodes = graph
|
|
816
|
-
if (graph
|
|
814
|
+
const totalNodes = graph.nodes.size;
|
|
815
|
+
if (graph.nodes.has("#")) computeDepth("#", 1);
|
|
817
816
|
return {
|
|
818
817
|
maxChildren,
|
|
819
818
|
maxDepth,
|
|
820
819
|
totalNodes
|
|
821
820
|
};
|
|
822
821
|
};
|
|
823
|
-
const exportForVisualization = (graph
|
|
822
|
+
const exportForVisualization = (graph) => {
|
|
824
823
|
const childrenMap = /* @__PURE__ */ new Map();
|
|
825
|
-
for (const [pointer, nodeInfo] of graph
|
|
824
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
826
825
|
if (!nodeInfo.parentPointer) continue;
|
|
827
826
|
if (!childrenMap.has(nodeInfo.parentPointer)) childrenMap.set(nodeInfo.parentPointer, []);
|
|
828
827
|
childrenMap.get(nodeInfo.parentPointer).push(pointer);
|
|
829
828
|
}
|
|
830
|
-
return Array.from(graph
|
|
829
|
+
return Array.from(graph.nodes.keys()).map((pointer) => ({
|
|
831
830
|
children: childrenMap.get(pointer)?.length ?? 0,
|
|
832
831
|
childrenPointers: childrenMap.get(pointer) || [],
|
|
833
832
|
pointer
|
|
@@ -994,7 +993,7 @@ const hasOperationDataRequired = (operation) => {
|
|
|
994
993
|
if (operation.body?.required) return true;
|
|
995
994
|
return false;
|
|
996
995
|
};
|
|
997
|
-
const createOperationKey = ({ method, path
|
|
996
|
+
const createOperationKey = ({ method, path }) => `${method.toUpperCase()} ${path}`;
|
|
998
997
|
const operationPagination = ({ context, operation }) => {
|
|
999
998
|
const body = operation.body;
|
|
1000
999
|
if (!body || !body.pagination) return parameterWithPagination({
|
|
@@ -1110,7 +1109,7 @@ const uppercaseRegExp = /[\p{Lu}]/u;
|
|
|
1110
1109
|
const lowercaseRegExp = /[\p{Ll}]/u;
|
|
1111
1110
|
const identifierRegExp = /([\p{Alpha}\p{N}_]|$)/u;
|
|
1112
1111
|
const separatorsRegExp = /[_.$+:\- `\\[\](){}\\/]+/;
|
|
1113
|
-
const leadingSeparatorsRegExp =
|
|
1112
|
+
const leadingSeparatorsRegExp = new RegExp(`^${separatorsRegExp.source}`);
|
|
1114
1113
|
const separatorsAndIdentifierRegExp = new RegExp(`${separatorsRegExp.source}${identifierRegExp.source}`, "gu");
|
|
1115
1114
|
const numbersAndIdentifierRegExp = new RegExp(`\\d+${identifierRegExp.source}`, "gu");
|
|
1116
1115
|
const preserveCase = (value, casing) => {
|
|
@@ -1258,24 +1257,24 @@ const sanitizeNamespaceIdentifier = (name) => name.replace(/^[^\p{ID_Start}]+/u,
|
|
|
1258
1257
|
*
|
|
1259
1258
|
* @deprecated
|
|
1260
1259
|
*/
|
|
1261
|
-
function operationToId({ context, count = 1, id, method, path
|
|
1260
|
+
function operationToId({ context, count = 1, id, method, path, state }) {
|
|
1262
1261
|
let result;
|
|
1263
1262
|
const { output } = context.config;
|
|
1264
1263
|
const targetCase = (output !== void 0 && typeof output === "object" && "case" in output ? output.case : void 0) ?? "camelCase";
|
|
1265
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);
|
|
1266
|
-
else result = toCase(`${method}-${path
|
|
1265
|
+
else result = toCase(`${method}-${path.replace(/{(.*?)}/g, "by-$1").replace(/[/:+]/g, "-")}`, targetCase);
|
|
1267
1266
|
if (count > 1) result = `${result}${count}`;
|
|
1268
1267
|
if (state.ids.has(result)) return operationToId({
|
|
1269
1268
|
context,
|
|
1270
1269
|
count: count + 1,
|
|
1271
1270
|
id,
|
|
1272
1271
|
method,
|
|
1273
|
-
path
|
|
1272
|
+
path,
|
|
1274
1273
|
state
|
|
1275
1274
|
});
|
|
1276
1275
|
state.ids.set(result, createOperationKey({
|
|
1277
1276
|
method,
|
|
1278
|
-
path
|
|
1277
|
+
path
|
|
1279
1278
|
}));
|
|
1280
1279
|
return result;
|
|
1281
1280
|
}
|
|
@@ -1284,7 +1283,7 @@ function operationToId({ context, count = 1, id, method, path: path$1, state })
|
|
|
1284
1283
|
//#region src/debug/ir.ts
|
|
1285
1284
|
const indent = (level) => " ".repeat(level);
|
|
1286
1285
|
const log = (message, level) => console.log(`${indent(level ?? 0)}${message}`);
|
|
1287
|
-
const print = (ir
|
|
1286
|
+
const print = (ir, options = {}) => {
|
|
1288
1287
|
const { depth = 2, section = "all", verbosity = "summary" } = options;
|
|
1289
1288
|
const printObject = (obj, level, kind = "generic") => {
|
|
1290
1289
|
if (verbosity === "summary" && obj && typeof obj === "object") if (kind === "responses") {
|
|
@@ -1309,25 +1308,25 @@ const print = (ir$1, options = {}) => {
|
|
|
1309
1308
|
if (operation.responses) printObject(operation.responses, base + 1, "responses");
|
|
1310
1309
|
}
|
|
1311
1310
|
};
|
|
1312
|
-
const sections = section === "all" ? Object.keys(ir
|
|
1313
|
-
for (const section
|
|
1311
|
+
const sections = section === "all" ? Object.keys(ir) : [section];
|
|
1312
|
+
for (const section of sections) switch (section) {
|
|
1314
1313
|
case "components":
|
|
1315
|
-
if (ir
|
|
1316
|
-
log(`Components: ${Object.keys(ir
|
|
1317
|
-
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");
|
|
1318
1317
|
}
|
|
1319
1318
|
break;
|
|
1320
1319
|
case "paths": {
|
|
1321
|
-
const paths = ir
|
|
1320
|
+
const paths = ir.paths || {};
|
|
1322
1321
|
log(`paths (${Object.keys(paths).length} items):`);
|
|
1323
|
-
for (const [path
|
|
1322
|
+
for (const [path, item] of Object.entries(paths)) printPathItem(path, item);
|
|
1324
1323
|
break;
|
|
1325
1324
|
}
|
|
1326
1325
|
case "servers": break;
|
|
1327
1326
|
case "webhooks": {
|
|
1328
|
-
const webhooks = ir
|
|
1327
|
+
const webhooks = ir.webhooks || {};
|
|
1329
1328
|
log(`webhooks (${Object.keys(webhooks).length} items):`);
|
|
1330
|
-
for (const [path
|
|
1329
|
+
for (const [path, item] of Object.entries(webhooks)) printPathItem(path, item);
|
|
1331
1330
|
break;
|
|
1332
1331
|
}
|
|
1333
1332
|
}
|
|
@@ -1533,8 +1532,8 @@ var MinHeap = class {
|
|
|
1533
1532
|
* is not required and the caller only wants nodes in the order they were
|
|
1534
1533
|
* added to the graph.
|
|
1535
1534
|
*/
|
|
1536
|
-
const walkDeclarations = (graph
|
|
1537
|
-
const pointers = Array.from(graph
|
|
1535
|
+
const walkDeclarations = (graph, callback, options) => {
|
|
1536
|
+
const pointers = Array.from(graph.nodes.keys());
|
|
1538
1537
|
if (options?.preferGroups && options.preferGroups.length > 0) {
|
|
1539
1538
|
const emitted = /* @__PURE__ */ new Set();
|
|
1540
1539
|
if (options.matchPointerToGroup) for (const kind of options.preferGroups) for (const pointer of pointers) {
|
|
@@ -1542,16 +1541,16 @@ const walkDeclarations = (graph$1, callback, options) => {
|
|
|
1542
1541
|
if (!result.matched) continue;
|
|
1543
1542
|
if (result.kind === kind) {
|
|
1544
1543
|
emitted.add(pointer);
|
|
1545
|
-
callback(pointer, graph
|
|
1544
|
+
callback(pointer, graph.nodes.get(pointer));
|
|
1546
1545
|
}
|
|
1547
1546
|
}
|
|
1548
1547
|
for (const pointer of pointers) {
|
|
1549
1548
|
if (emitted.has(pointer)) continue;
|
|
1550
|
-
callback(pointer, graph
|
|
1549
|
+
callback(pointer, graph.nodes.get(pointer));
|
|
1551
1550
|
}
|
|
1552
1551
|
return;
|
|
1553
1552
|
}
|
|
1554
|
-
for (const pointer of pointers) callback(pointer, graph
|
|
1553
|
+
for (const pointer of pointers) callback(pointer, graph.nodes.get(pointer));
|
|
1555
1554
|
};
|
|
1556
1555
|
/**
|
|
1557
1556
|
* Walks the nodes of the graph in topological order (dependencies before dependents).
|
|
@@ -1561,8 +1560,8 @@ const walkDeclarations = (graph$1, callback, options) => {
|
|
|
1561
1560
|
* @param graph - The dependency graph
|
|
1562
1561
|
* @param callback - Function to call for each node pointer
|
|
1563
1562
|
*/
|
|
1564
|
-
const walkTopological = (graph
|
|
1565
|
-
const pointers = Array.from(graph
|
|
1563
|
+
const walkTopological = (graph, callback, options) => {
|
|
1564
|
+
const pointers = Array.from(graph.nodes.keys());
|
|
1566
1565
|
const baseIndex = /* @__PURE__ */ new Map();
|
|
1567
1566
|
pointers.forEach((pointer, index) => baseIndex.set(pointer, index));
|
|
1568
1567
|
const declIndex = /* @__PURE__ */ new Map();
|
|
@@ -1572,11 +1571,11 @@ const walkTopological = (graph$1, callback, options) => {
|
|
|
1572
1571
|
}
|
|
1573
1572
|
const depsOf = /* @__PURE__ */ new Map();
|
|
1574
1573
|
for (const pointer of pointers) {
|
|
1575
|
-
const raw = graph
|
|
1574
|
+
const raw = graph.subtreeDependencies?.get(pointer) ?? /* @__PURE__ */ new Set();
|
|
1576
1575
|
const filtered = /* @__PURE__ */ new Set();
|
|
1577
1576
|
for (const rawPointer of raw) {
|
|
1578
1577
|
if (rawPointer === pointer) continue;
|
|
1579
|
-
if (graph
|
|
1578
|
+
if (graph.nodes.has(rawPointer)) filtered.add(rawPointer);
|
|
1580
1579
|
}
|
|
1581
1580
|
depsOf.set(pointer, filtered);
|
|
1582
1581
|
}
|
|
@@ -1643,11 +1642,11 @@ const walkTopological = (graph$1, callback, options) => {
|
|
|
1643
1642
|
return false;
|
|
1644
1643
|
})()) finalOrder = proposed;
|
|
1645
1644
|
}
|
|
1646
|
-
for (const pointer of finalOrder) callback(pointer, graph
|
|
1645
|
+
for (const pointer of finalOrder) callback(pointer, graph.nodes.get(pointer));
|
|
1647
1646
|
};
|
|
1648
|
-
const walk = (graph
|
|
1649
|
-
if (options?.order === "topological") return walkTopological(graph
|
|
1650
|
-
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);
|
|
1651
1650
|
};
|
|
1652
1651
|
|
|
1653
1652
|
//#endregion
|
|
@@ -1681,9 +1680,9 @@ const matchIrPointerToGroup = (pointer, kind) => {
|
|
|
1681
1680
|
matched: true
|
|
1682
1681
|
} : { matched: false };
|
|
1683
1682
|
for (const key of Object.keys(patterns)) {
|
|
1684
|
-
const kind
|
|
1685
|
-
if (patterns[kind
|
|
1686
|
-
kind
|
|
1683
|
+
const kind = key;
|
|
1684
|
+
if (patterns[kind].test(pointer)) return {
|
|
1685
|
+
kind,
|
|
1687
1686
|
matched: true
|
|
1688
1687
|
};
|
|
1689
1688
|
}
|
|
@@ -1721,8 +1720,8 @@ const jsonPointerTilde = /~0/g;
|
|
|
1721
1720
|
* Returns the reusable component name from `$ref`.
|
|
1722
1721
|
*/
|
|
1723
1722
|
function refToName($ref) {
|
|
1724
|
-
const path
|
|
1725
|
-
const name = path
|
|
1723
|
+
const path = jsonPointerToPath($ref);
|
|
1724
|
+
const name = path[path.length - 1];
|
|
1726
1725
|
return decodeURI(name);
|
|
1727
1726
|
}
|
|
1728
1727
|
/**
|
|
@@ -1782,8 +1781,8 @@ function normalizeJsonPointer(pointer) {
|
|
|
1782
1781
|
* @param path
|
|
1783
1782
|
* @returns
|
|
1784
1783
|
*/
|
|
1785
|
-
function pathToJsonPointer(path
|
|
1786
|
-
const segments = path
|
|
1784
|
+
function pathToJsonPointer(path) {
|
|
1785
|
+
const segments = path.map(encodeJsonPointerSegment).join("/");
|
|
1787
1786
|
return "#" + (segments ? `/${segments}` : "");
|
|
1788
1787
|
}
|
|
1789
1788
|
/**
|
|
@@ -1800,15 +1799,15 @@ function pathToJsonPointer(path$1) {
|
|
|
1800
1799
|
* @returns true if the ref points to a top-level component, false otherwise
|
|
1801
1800
|
*/
|
|
1802
1801
|
function isTopLevelComponent(refOrPath) {
|
|
1803
|
-
const path
|
|
1804
|
-
if (path
|
|
1805
|
-
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;
|
|
1806
1805
|
return false;
|
|
1807
1806
|
}
|
|
1808
1807
|
function resolveRef({ $ref, spec }) {
|
|
1809
|
-
const path
|
|
1808
|
+
const path = jsonPointerToPath(decodeURI($ref));
|
|
1810
1809
|
let current = spec;
|
|
1811
|
-
for (const part of path
|
|
1810
|
+
for (const part of path) {
|
|
1812
1811
|
const segment = part;
|
|
1813
1812
|
if (current[segment] === void 0) throw new Error(`Reference not found: ${$ref}`);
|
|
1814
1813
|
current = current[segment];
|
|
@@ -1822,6 +1821,7 @@ const defaultGetFilePath = (symbol) => {
|
|
|
1822
1821
|
if (!symbol.meta?.pluginName || typeof symbol.meta.pluginName !== "string") return;
|
|
1823
1822
|
if (symbol.meta.pluginName.startsWith("@hey-api/client-")) return "client";
|
|
1824
1823
|
if (symbol.meta.pluginName === "@hey-api/typescript") return "types";
|
|
1824
|
+
if (symbol.meta.pluginName === "@hey-api/python-sdk") return "sdk";
|
|
1825
1825
|
if (symbol.meta.pluginName.startsWith("@hey-api/")) return symbol.meta.pluginName.split("/")[1];
|
|
1826
1826
|
return symbol.meta.pluginName;
|
|
1827
1827
|
};
|
|
@@ -2027,7 +2027,7 @@ var PluginInstance = class {
|
|
|
2027
2027
|
return this.gen.symbols.reference(meta);
|
|
2028
2028
|
}
|
|
2029
2029
|
/**
|
|
2030
|
-
*
|
|
2030
|
+
* Alias for `symbol()` method with single argument.
|
|
2031
2031
|
*/
|
|
2032
2032
|
registerSymbol(symbol) {
|
|
2033
2033
|
return this.symbol(symbol.name, symbol);
|
|
@@ -2264,10 +2264,10 @@ var IntentContext = class {
|
|
|
2264
2264
|
constructor(spec) {
|
|
2265
2265
|
this.spec = spec;
|
|
2266
2266
|
}
|
|
2267
|
-
getOperation(path
|
|
2267
|
+
getOperation(path, method) {
|
|
2268
2268
|
const paths = this.spec.paths;
|
|
2269
2269
|
if (!paths) return;
|
|
2270
|
-
return paths[path
|
|
2270
|
+
return paths[path]?.[method];
|
|
2271
2271
|
}
|
|
2272
2272
|
setExample(operation, example) {
|
|
2273
2273
|
const source = this.getOperation(operation.path, operation.method);
|
|
@@ -2290,11 +2290,11 @@ function createSchemaProcessor() {
|
|
|
2290
2290
|
tags: contextTags
|
|
2291
2291
|
};
|
|
2292
2292
|
},
|
|
2293
|
-
hasEmitted(path
|
|
2294
|
-
return emitted.has(pathToJsonPointer(path
|
|
2293
|
+
hasEmitted(path) {
|
|
2294
|
+
return emitted.has(pathToJsonPointer(path));
|
|
2295
2295
|
},
|
|
2296
|
-
markEmitted(path
|
|
2297
|
-
const pointer = pathToJsonPointer(path
|
|
2296
|
+
markEmitted(path) {
|
|
2297
|
+
const pointer = pathToJsonPointer(path);
|
|
2298
2298
|
if (emitted.has(pointer)) return false;
|
|
2299
2299
|
emitted.add(pointer);
|
|
2300
2300
|
return true;
|
|
@@ -2325,21 +2325,21 @@ function createSchemaProcessor() {
|
|
|
2325
2325
|
* - Path tracking for child schemas
|
|
2326
2326
|
*/
|
|
2327
2327
|
function createSchemaWalker(visitor) {
|
|
2328
|
-
const walk
|
|
2328
|
+
const walk = (schema, ctx) => {
|
|
2329
2329
|
if (visitor.intercept) {
|
|
2330
|
-
const intercepted = visitor.intercept(schema, ctx, walk
|
|
2330
|
+
const intercepted = visitor.intercept(schema, ctx, walk);
|
|
2331
2331
|
if (intercepted !== void 0) return intercepted;
|
|
2332
2332
|
}
|
|
2333
2333
|
if (schema.$ref) return visitor.reference(schema.$ref, schema, ctx);
|
|
2334
2334
|
if (schema.type) {
|
|
2335
|
-
let result = visitTyped(schema, ctx, visitor, walk
|
|
2335
|
+
let result = visitTyped(schema, ctx, visitor, walk);
|
|
2336
2336
|
if (visitor.postProcess) result = visitor.postProcess(result, schema, ctx);
|
|
2337
2337
|
return result;
|
|
2338
2338
|
}
|
|
2339
2339
|
if (schema.items) {
|
|
2340
2340
|
const deduplicated = deduplicateSchema({ schema });
|
|
2341
|
-
if (!deduplicated.items) return walk
|
|
2342
|
-
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, {
|
|
2343
2343
|
...ctx,
|
|
2344
2344
|
path: ref([
|
|
2345
2345
|
...fromRef(ctx.path),
|
|
@@ -2351,23 +2351,23 @@ function createSchemaWalker(visitor) {
|
|
|
2351
2351
|
}
|
|
2352
2352
|
return visitor.unknown({ type: "unknown" }, ctx);
|
|
2353
2353
|
};
|
|
2354
|
-
return walk
|
|
2354
|
+
return walk;
|
|
2355
2355
|
}
|
|
2356
2356
|
/**
|
|
2357
2357
|
* Dispatch to the appropriate visitor method based on schema type.
|
|
2358
2358
|
*/
|
|
2359
|
-
function visitTyped(schema, ctx, visitor, walk
|
|
2359
|
+
function visitTyped(schema, ctx, visitor, walk) {
|
|
2360
2360
|
switch (schema.type) {
|
|
2361
|
-
case "array": return visitor.array(schema, ctx, walk
|
|
2361
|
+
case "array": return visitor.array(schema, ctx, walk);
|
|
2362
2362
|
case "boolean": return visitor.boolean(schema, ctx);
|
|
2363
|
-
case "enum": return visitor.enum(schema, ctx, walk
|
|
2363
|
+
case "enum": return visitor.enum(schema, ctx, walk);
|
|
2364
2364
|
case "integer": return visitor.integer(schema, ctx);
|
|
2365
2365
|
case "never": return visitor.never(schema, ctx);
|
|
2366
2366
|
case "null": return visitor.null(schema, ctx);
|
|
2367
2367
|
case "number": return visitor.number(schema, ctx);
|
|
2368
|
-
case "object": return visitor.object(schema, ctx, walk
|
|
2368
|
+
case "object": return visitor.object(schema, ctx, walk);
|
|
2369
2369
|
case "string": return visitor.string(schema, ctx);
|
|
2370
|
-
case "tuple": return visitor.tuple(schema, ctx, walk
|
|
2370
|
+
case "tuple": return visitor.tuple(schema, ctx, walk);
|
|
2371
2371
|
case "undefined": return visitor.undefined(schema, ctx);
|
|
2372
2372
|
case "unknown": return visitor.unknown(schema, ctx);
|
|
2373
2373
|
case "void": return visitor.void(schema, ctx);
|
|
@@ -2386,7 +2386,7 @@ function childContext(ctx, ...segments) {
|
|
|
2386
2386
|
//#endregion
|
|
2387
2387
|
//#region src/openApi/shared/utils/filter.ts
|
|
2388
2388
|
const namespaceNeedle = "/";
|
|
2389
|
-
const addNamespace = (namespace
|
|
2389
|
+
const addNamespace = (namespace, value = "") => `${namespace}${namespaceNeedle}${value}`;
|
|
2390
2390
|
const removeNamespace = (key) => {
|
|
2391
2391
|
const index = key.indexOf(namespaceNeedle);
|
|
2392
2392
|
return {
|
|
@@ -2421,13 +2421,13 @@ const createFiltersSetAndRegExps = (type, filters) => {
|
|
|
2421
2421
|
};
|
|
2422
2422
|
const collectFiltersSetFromRegExpsOpenApiV2 = ({ excludeOperations, excludeSchemas, includeOperations, includeSchemas, spec }) => {
|
|
2423
2423
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2424
|
-
const path
|
|
2424
|
+
const path = entry[0];
|
|
2425
2425
|
const pathItem = entry[1];
|
|
2426
2426
|
for (const method of httpMethods) {
|
|
2427
2427
|
if (!pathItem[method]) continue;
|
|
2428
2428
|
const key = createOperationKey({
|
|
2429
2429
|
method,
|
|
2430
|
-
path
|
|
2430
|
+
path
|
|
2431
2431
|
});
|
|
2432
2432
|
if (excludeOperations.regexps.some((regexp) => regexp.test(key))) excludeOperations.set.add(addNamespace("operation", key));
|
|
2433
2433
|
if (includeOperations.regexps.some((regexp) => regexp.test(key))) includeOperations.set.add(addNamespace("operation", key));
|
|
@@ -2442,13 +2442,13 @@ const collectFiltersSetFromRegExpsOpenApiV2 = ({ excludeOperations, excludeSchem
|
|
|
2442
2442
|
};
|
|
2443
2443
|
const collectFiltersSetFromRegExpsOpenApiV3 = ({ excludeOperations, excludeParameters, excludeRequestBodies, excludeResponses, excludeSchemas, includeOperations, includeParameters, includeRequestBodies, includeResponses, includeSchemas, spec }) => {
|
|
2444
2444
|
if ((excludeOperations.regexps.length || includeOperations.regexps.length) && spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
2445
|
-
const path
|
|
2445
|
+
const path = entry[0];
|
|
2446
2446
|
const pathItem = entry[1];
|
|
2447
2447
|
for (const method of httpMethods) {
|
|
2448
2448
|
if (!pathItem[method]) continue;
|
|
2449
2449
|
const key = createOperationKey({
|
|
2450
2450
|
method,
|
|
2451
|
-
path
|
|
2451
|
+
path
|
|
2452
2452
|
});
|
|
2453
2453
|
if (excludeOperations.regexps.some((regexp) => regexp.test(key))) excludeOperations.set.add(addNamespace("operation", key));
|
|
2454
2454
|
if (includeOperations.regexps.some((regexp) => regexp.test(key))) includeOperations.set.add(addNamespace("operation", key));
|
|
@@ -2560,8 +2560,8 @@ const collectOperations = ({ filters, parameters, requestBodies, resourceMetadat
|
|
|
2560
2560
|
if (filters.tags.exclude.size && node.tags.size && [...filters.tags.exclude].some((tag) => node.tags.has(tag))) continue;
|
|
2561
2561
|
if (filters.tags.include.size && !new Set([...filters.tags.include].filter((tag) => node.tags.has(tag))).size) continue;
|
|
2562
2562
|
if ([...node.dependencies].some((dependency) => {
|
|
2563
|
-
const { namespace
|
|
2564
|
-
switch (namespace
|
|
2563
|
+
const { namespace } = removeNamespace(dependency);
|
|
2564
|
+
switch (namespace) {
|
|
2565
2565
|
case "body": return !requestBodies.has(dependency);
|
|
2566
2566
|
case "parameter": return !parameters.has(dependency);
|
|
2567
2567
|
case "response": return !responses.has(dependency);
|
|
@@ -2588,8 +2588,8 @@ const collectParameters = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2588
2588
|
finalSet.add(key);
|
|
2589
2589
|
if (!node.dependencies.size) continue;
|
|
2590
2590
|
for (const dependency of node.dependencies) {
|
|
2591
|
-
const { namespace
|
|
2592
|
-
switch (namespace
|
|
2591
|
+
const { namespace } = removeNamespace(dependency);
|
|
2592
|
+
switch (namespace) {
|
|
2593
2593
|
case "body":
|
|
2594
2594
|
if (filters.requestBodies.exclude.has(dependency)) finalSet.delete(key);
|
|
2595
2595
|
else if (!finalSet.has(dependency)) stack.push(dependency);
|
|
@@ -2618,8 +2618,8 @@ const collectRequestBodies = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2618
2618
|
finalSet.add(key);
|
|
2619
2619
|
if (!node.dependencies.size) continue;
|
|
2620
2620
|
for (const dependency of node.dependencies) {
|
|
2621
|
-
const { namespace
|
|
2622
|
-
switch (namespace
|
|
2621
|
+
const { namespace } = removeNamespace(dependency);
|
|
2622
|
+
switch (namespace) {
|
|
2623
2623
|
case "body":
|
|
2624
2624
|
if (filters.requestBodies.exclude.has(dependency)) finalSet.delete(key);
|
|
2625
2625
|
else if (!finalSet.has(dependency)) stack.push(dependency);
|
|
@@ -2648,8 +2648,8 @@ const collectResponses = ({ filters, resourceMetadata, schemas }) => {
|
|
|
2648
2648
|
finalSet.add(key);
|
|
2649
2649
|
if (!node.dependencies.size) continue;
|
|
2650
2650
|
for (const dependency of node.dependencies) {
|
|
2651
|
-
const { namespace
|
|
2652
|
-
switch (namespace
|
|
2651
|
+
const { namespace } = removeNamespace(dependency);
|
|
2652
|
+
switch (namespace) {
|
|
2653
2653
|
case "body":
|
|
2654
2654
|
if (filters.requestBodies.exclude.has(dependency)) finalSet.delete(key);
|
|
2655
2655
|
else if (!finalSet.has(dependency)) stack.push(dependency);
|
|
@@ -2678,8 +2678,8 @@ const collectSchemas = ({ filters, resourceMetadata }) => {
|
|
|
2678
2678
|
finalSet.add(key);
|
|
2679
2679
|
if (!node.dependencies.size) continue;
|
|
2680
2680
|
for (const dependency of node.dependencies) {
|
|
2681
|
-
const { namespace
|
|
2682
|
-
switch (namespace
|
|
2681
|
+
const { namespace } = removeNamespace(dependency);
|
|
2682
|
+
switch (namespace) {
|
|
2683
2683
|
case "schema":
|
|
2684
2684
|
if (!finalSet.has(dependency) && !filters.schemas.exclude.has(dependency)) stack.push(dependency);
|
|
2685
2685
|
break;
|
|
@@ -2757,13 +2757,13 @@ const collectOperationDependencies = ({ operations, resourceMetadata }) => {
|
|
|
2757
2757
|
const key = stack.pop();
|
|
2758
2758
|
if (finalSet.has(key)) continue;
|
|
2759
2759
|
finalSet.add(key);
|
|
2760
|
-
const { namespace
|
|
2760
|
+
const { namespace } = removeNamespace(key);
|
|
2761
2761
|
let dependencies;
|
|
2762
|
-
if (namespace
|
|
2763
|
-
else if (namespace
|
|
2764
|
-
else if (namespace
|
|
2765
|
-
else if (namespace
|
|
2766
|
-
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;
|
|
2767
2767
|
if (!dependencies?.size) continue;
|
|
2768
2768
|
for (const dependency of dependencies) if (!finalSet.has(dependency)) stack.push(dependency);
|
|
2769
2769
|
}
|
|
@@ -2847,7 +2847,7 @@ const createFilteredDependencies = ({ filters, logger, resourceMetadata }) => {
|
|
|
2847
2847
|
* Builds a resource metadata map from a Graph, matching the old Graph interface
|
|
2848
2848
|
* for compatibility with filtering code.
|
|
2849
2849
|
*/
|
|
2850
|
-
const buildResourceMetadata = (graph
|
|
2850
|
+
const buildResourceMetadata = (graph, logger) => {
|
|
2851
2851
|
const eventBuildResourceMetadata = logger.timeEvent("build-resource-metadata");
|
|
2852
2852
|
const resourceMetadata = {
|
|
2853
2853
|
operations: /* @__PURE__ */ new Map(),
|
|
@@ -2858,43 +2858,43 @@ const buildResourceMetadata = (graph$1, logger) => {
|
|
|
2858
2858
|
};
|
|
2859
2859
|
const getDependencies = (pointer) => {
|
|
2860
2860
|
const dependencies = /* @__PURE__ */ new Set();
|
|
2861
|
-
const nodeDependencies = graph
|
|
2861
|
+
const nodeDependencies = graph.transitiveDependencies.get(pointer);
|
|
2862
2862
|
if (nodeDependencies?.size) for (const dependency of nodeDependencies) {
|
|
2863
|
-
const path
|
|
2864
|
-
const type = path
|
|
2865
|
-
const name = path
|
|
2863
|
+
const path = jsonPointerToPath(dependency);
|
|
2864
|
+
const type = path[path.length - 2];
|
|
2865
|
+
const name = path[path.length - 1];
|
|
2866
2866
|
if (type && name) {
|
|
2867
|
-
const namespace
|
|
2868
|
-
if (namespace
|
|
2869
|
-
dependencies.add(addNamespace(namespace
|
|
2867
|
+
const namespace = stringToNamespace(type);
|
|
2868
|
+
if (namespace === "unknown") console.warn(`unsupported type: ${type}`);
|
|
2869
|
+
dependencies.add(addNamespace(namespace, name));
|
|
2870
2870
|
}
|
|
2871
2871
|
}
|
|
2872
2872
|
return dependencies;
|
|
2873
2873
|
};
|
|
2874
|
-
for (const [pointer, nodeInfo] of graph
|
|
2875
|
-
const path
|
|
2876
|
-
if (path
|
|
2877
|
-
if (path
|
|
2878
|
-
if (path
|
|
2879
|
-
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];
|
|
2880
2880
|
resourceMetadata.schemas.set(addNamespace("schema", name), {
|
|
2881
2881
|
dependencies: getDependencies(pointer),
|
|
2882
2882
|
deprecated: nodeInfo.deprecated ?? false
|
|
2883
2883
|
});
|
|
2884
|
-
} else if (path
|
|
2885
|
-
const name = path
|
|
2884
|
+
} else if (path[1] === "parameters") {
|
|
2885
|
+
const name = path[path.length - 1];
|
|
2886
2886
|
resourceMetadata.parameters.set(addNamespace("parameter", name), {
|
|
2887
2887
|
dependencies: getDependencies(pointer),
|
|
2888
2888
|
deprecated: nodeInfo.deprecated ?? false
|
|
2889
2889
|
});
|
|
2890
|
-
} else if (path
|
|
2891
|
-
const name = path
|
|
2890
|
+
} else if (path[1] === "requestBodies") {
|
|
2891
|
+
const name = path[path.length - 1];
|
|
2892
2892
|
resourceMetadata.requestBodies.set(addNamespace("body", name), {
|
|
2893
2893
|
dependencies: getDependencies(pointer),
|
|
2894
2894
|
deprecated: nodeInfo.deprecated ?? false
|
|
2895
2895
|
});
|
|
2896
|
-
} else if (path
|
|
2897
|
-
const name = path
|
|
2896
|
+
} else if (path[1] === "responses") {
|
|
2897
|
+
const name = path[path.length - 1];
|
|
2898
2898
|
resourceMetadata.responses.set(addNamespace("response", name), {
|
|
2899
2899
|
dependencies: getDependencies(pointer),
|
|
2900
2900
|
deprecated: nodeInfo.deprecated ?? false
|
|
@@ -2903,12 +2903,12 @@ const buildResourceMetadata = (graph$1, logger) => {
|
|
|
2903
2903
|
}
|
|
2904
2904
|
continue;
|
|
2905
2905
|
}
|
|
2906
|
-
if (path
|
|
2907
|
-
if (path
|
|
2908
|
-
const method = path
|
|
2906
|
+
if (path[0] === "paths") {
|
|
2907
|
+
if (path.length === 3 && httpMethods.includes(path[2])) {
|
|
2908
|
+
const method = path[path.length - 1];
|
|
2909
2909
|
const operationKey = createOperationKey({
|
|
2910
2910
|
method,
|
|
2911
|
-
path: path
|
|
2911
|
+
path: path.slice(1, -1).join("/")
|
|
2912
2912
|
});
|
|
2913
2913
|
resourceMetadata.operations.set(addNamespace("operation", operationKey), {
|
|
2914
2914
|
dependencies: getDependencies(pointer),
|
|
@@ -2918,9 +2918,9 @@ const buildResourceMetadata = (graph$1, logger) => {
|
|
|
2918
2918
|
}
|
|
2919
2919
|
continue;
|
|
2920
2920
|
}
|
|
2921
|
-
if (path
|
|
2922
|
-
if (path
|
|
2923
|
-
const name = path
|
|
2921
|
+
if (path[0] === "definitions") {
|
|
2922
|
+
if (path.length === 2) {
|
|
2923
|
+
const name = path[path.length - 1];
|
|
2924
2924
|
resourceMetadata.schemas.set(addNamespace("schema", name), {
|
|
2925
2925
|
dependencies: getDependencies(pointer),
|
|
2926
2926
|
deprecated: nodeInfo.deprecated ?? false
|
|
@@ -2989,7 +2989,7 @@ const getUniqueComponentName = ({ base, components, extraComponents }) => {
|
|
|
2989
2989
|
}
|
|
2990
2990
|
return name;
|
|
2991
2991
|
};
|
|
2992
|
-
const isPathRootSchema = (path
|
|
2992
|
+
const isPathRootSchema = (path) => path.length === 3 && path[0] === "components" && path[1] === "schemas" || path.length === 2 && path[0] === "definitions";
|
|
2993
2993
|
const specToSchemasPointerNamespace = (spec) => {
|
|
2994
2994
|
if (spec && typeof spec === "object") {
|
|
2995
2995
|
if ("swagger" in spec) return "#/definitions/";
|
|
@@ -3026,21 +3026,21 @@ const getEnumSignature = (schema) => {
|
|
|
3026
3026
|
* @param path - The path to the current node
|
|
3027
3027
|
* @param visitor - Function to call for each visited node
|
|
3028
3028
|
*/
|
|
3029
|
-
const walkSchemas$1 = ({ key, node, parent, path
|
|
3029
|
+
const walkSchemas$1 = ({ key, node, parent, path, visitor }) => {
|
|
3030
3030
|
if (!node || typeof node !== "object" || node instanceof Array) return;
|
|
3031
3031
|
const value = node;
|
|
3032
3032
|
if ("type" in value || "enum" in value || childSchemaRelationships.some(([keyword]) => keyword in value)) visitor({
|
|
3033
3033
|
key,
|
|
3034
3034
|
node,
|
|
3035
3035
|
parent,
|
|
3036
|
-
path
|
|
3036
|
+
path
|
|
3037
3037
|
});
|
|
3038
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({
|
|
3039
3039
|
key: index,
|
|
3040
3040
|
node: item,
|
|
3041
3041
|
parent: v,
|
|
3042
3042
|
path: [
|
|
3043
|
-
...path
|
|
3043
|
+
...path,
|
|
3044
3044
|
k,
|
|
3045
3045
|
index
|
|
3046
3046
|
],
|
|
@@ -3050,7 +3050,7 @@ const walkSchemas$1 = ({ key, node, parent, path: path$1, visitor }) => {
|
|
|
3050
3050
|
key: k,
|
|
3051
3051
|
node: v,
|
|
3052
3052
|
parent: node,
|
|
3053
|
-
path: [...path
|
|
3053
|
+
path: [...path, k],
|
|
3054
3054
|
visitor
|
|
3055
3055
|
});
|
|
3056
3056
|
};
|
|
@@ -3075,8 +3075,8 @@ const inlineMode = ({ spec }) => {
|
|
|
3075
3075
|
};
|
|
3076
3076
|
replaceEnumRefs(spec);
|
|
3077
3077
|
for (const pointer of Object.keys(rootEnums)) {
|
|
3078
|
-
const path
|
|
3079
|
-
const name = path
|
|
3078
|
+
const path = jsonPointerToPath(pointer);
|
|
3079
|
+
const name = path[path.length - 1];
|
|
3080
3080
|
if (name) delete schemasObj[name];
|
|
3081
3081
|
}
|
|
3082
3082
|
};
|
|
@@ -3174,21 +3174,21 @@ const enumsTransform = ({ config, spec }) => {
|
|
|
3174
3174
|
* @param path - The path to the current node
|
|
3175
3175
|
* @param visitor - Function to call for each visited node
|
|
3176
3176
|
*/
|
|
3177
|
-
const walkSchemas = ({ key, node, parent, path
|
|
3177
|
+
const walkSchemas = ({ key, node, parent, path, visitor }) => {
|
|
3178
3178
|
if (!node || typeof node !== "object" || node instanceof Array) return;
|
|
3179
3179
|
const value = node;
|
|
3180
3180
|
if ("type" in value || childSchemaRelationships.some(([keyword]) => keyword in value)) visitor({
|
|
3181
3181
|
key,
|
|
3182
3182
|
node,
|
|
3183
3183
|
parent,
|
|
3184
|
-
path
|
|
3184
|
+
path
|
|
3185
3185
|
});
|
|
3186
3186
|
for (const [k, v] of Object.entries(value)) if (typeof v === "object" && v !== null) if (v instanceof Array) v.forEach((item, index) => walkSchemas({
|
|
3187
3187
|
key: index,
|
|
3188
3188
|
node: item,
|
|
3189
3189
|
parent: v,
|
|
3190
3190
|
path: [
|
|
3191
|
-
...path
|
|
3191
|
+
...path,
|
|
3192
3192
|
k,
|
|
3193
3193
|
index
|
|
3194
3194
|
],
|
|
@@ -3198,7 +3198,7 @@ const walkSchemas = ({ key, node, parent, path: path$1, visitor }) => {
|
|
|
3198
3198
|
key: k,
|
|
3199
3199
|
node: v,
|
|
3200
3200
|
parent: node,
|
|
3201
|
-
path: [...path
|
|
3201
|
+
path: [...path, k],
|
|
3202
3202
|
visitor
|
|
3203
3203
|
});
|
|
3204
3204
|
};
|
|
@@ -3249,7 +3249,6 @@ const deepEqual = (a, b) => {
|
|
|
3249
3249
|
for (const key of keysA) if (!deepEqual(objA[key], objB[key])) return false;
|
|
3250
3250
|
return true;
|
|
3251
3251
|
};
|
|
3252
|
-
var deepEqual_default = deepEqual;
|
|
3253
3252
|
|
|
3254
3253
|
//#endregion
|
|
3255
3254
|
//#region src/openApi/shared/utils/graph.ts
|
|
@@ -3271,7 +3270,7 @@ const annotateChildScopes = (nodes) => {
|
|
|
3271
3270
|
/**
|
|
3272
3271
|
* Recursively collects all $ref dependencies in the subtree rooted at `pointer`.
|
|
3273
3272
|
*/
|
|
3274
|
-
const collectPointerDependencies = ({ cache, graph
|
|
3273
|
+
const collectPointerDependencies = ({ cache, graph, pointer, visited }) => {
|
|
3275
3274
|
const cached = cache.transitiveDependencies.get(pointer);
|
|
3276
3275
|
if (cached) return {
|
|
3277
3276
|
subtreeDependencies: cache.subtreeDependencies.get(pointer),
|
|
@@ -3282,19 +3281,19 @@ const collectPointerDependencies = ({ cache, graph: graph$1, pointer, visited })
|
|
|
3282
3281
|
transitiveDependencies: /* @__PURE__ */ new Set()
|
|
3283
3282
|
};
|
|
3284
3283
|
visited.add(pointer);
|
|
3285
|
-
if (!graph
|
|
3284
|
+
if (!graph.nodes.get(pointer)) return {
|
|
3286
3285
|
subtreeDependencies: /* @__PURE__ */ new Set(),
|
|
3287
3286
|
transitiveDependencies: /* @__PURE__ */ new Set()
|
|
3288
3287
|
};
|
|
3289
3288
|
const transitiveDependencies = /* @__PURE__ */ new Set();
|
|
3290
3289
|
const subtreeDependencies = /* @__PURE__ */ new Set();
|
|
3291
|
-
const nodeDependencies = graph
|
|
3290
|
+
const nodeDependencies = graph.nodeDependencies.get(pointer);
|
|
3292
3291
|
if (nodeDependencies) for (const depPointer of nodeDependencies) {
|
|
3293
3292
|
transitiveDependencies.add(depPointer);
|
|
3294
3293
|
subtreeDependencies.add(depPointer);
|
|
3295
3294
|
const depResult = collectPointerDependencies({
|
|
3296
3295
|
cache,
|
|
3297
|
-
graph
|
|
3296
|
+
graph,
|
|
3298
3297
|
pointer: depPointer,
|
|
3299
3298
|
visited
|
|
3300
3299
|
});
|
|
@@ -3309,7 +3308,7 @@ const collectPointerDependencies = ({ cache, graph: graph$1, pointer, visited })
|
|
|
3309
3308
|
if (!childResult.subtreeDependencies || !childResult.transitiveDependencies) {
|
|
3310
3309
|
childResult = collectPointerDependencies({
|
|
3311
3310
|
cache,
|
|
3312
|
-
graph
|
|
3311
|
+
graph,
|
|
3313
3312
|
pointer: childPointer,
|
|
3314
3313
|
visited
|
|
3315
3314
|
});
|
|
@@ -3338,8 +3337,8 @@ const collectPointerDependencies = ({ cache, graph: graph$1, pointer, visited })
|
|
|
3338
3337
|
*
|
|
3339
3338
|
* @param graph - The Graph structure containing nodes, dependencies, and reverseNodeDependencies.
|
|
3340
3339
|
*/
|
|
3341
|
-
const propagateScopes = (graph
|
|
3342
|
-
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));
|
|
3343
3342
|
/**
|
|
3344
3343
|
* Notifies all dependents of a node that its scopes may have changed.
|
|
3345
3344
|
* Dependents include:
|
|
@@ -3353,7 +3352,7 @@ const propagateScopes = (graph$1) => {
|
|
|
3353
3352
|
*/
|
|
3354
3353
|
const notifyAllDependents = (pointer, nodeInfo, childPointer) => {
|
|
3355
3354
|
if (nodeInfo.parentPointer) worklist.add(nodeInfo.parentPointer);
|
|
3356
|
-
const reverseNodeDependencies = graph
|
|
3355
|
+
const reverseNodeDependencies = graph.reverseNodeDependencies.get(pointer);
|
|
3357
3356
|
if (reverseNodeDependencies) for (const dependentPointer of reverseNodeDependencies) worklist.add(dependentPointer);
|
|
3358
3357
|
if (childPointer) {
|
|
3359
3358
|
const combinatorChildMatch = childPointer.match(/(.*)\/(allOf|anyOf|oneOf)\/\d+$/);
|
|
@@ -3373,14 +3372,14 @@ const propagateScopes = (graph$1) => {
|
|
|
3373
3372
|
*/
|
|
3374
3373
|
const propagateChildScopes = (pointer, nodeInfo, childPointer) => {
|
|
3375
3374
|
if (!nodeInfo?.scopes) return;
|
|
3376
|
-
const childInfo = graph
|
|
3375
|
+
const childInfo = graph.nodes.get(childPointer);
|
|
3377
3376
|
if (!childInfo?.scopes) return;
|
|
3378
3377
|
if (propagateScopesToNode(childInfo, nodeInfo)) notifyAllDependents(pointer, nodeInfo, childPointer);
|
|
3379
3378
|
};
|
|
3380
3379
|
while (worklist.size > 0) {
|
|
3381
3380
|
const pointer = worklist.values().next().value;
|
|
3382
3381
|
worklist.delete(pointer);
|
|
3383
|
-
const nodeInfo = graph
|
|
3382
|
+
const nodeInfo = graph.nodes.get(pointer);
|
|
3384
3383
|
if (!nodeInfo) continue;
|
|
3385
3384
|
if (!nodeInfo.scopes) nodeInfo.scopes = /* @__PURE__ */ new Set();
|
|
3386
3385
|
const node = nodeInfo.node;
|
|
@@ -3395,15 +3394,15 @@ const propagateScopes = (graph$1) => {
|
|
|
3395
3394
|
else if (typeof value === "object" && value !== null) propagateChildScopes(pointer, nodeInfo, `${pointer}/${keyword}`);
|
|
3396
3395
|
}
|
|
3397
3396
|
}
|
|
3398
|
-
const nodeDependencies = graph
|
|
3397
|
+
const nodeDependencies = graph.nodeDependencies.get(pointer);
|
|
3399
3398
|
if (nodeDependencies) for (const depPointer of nodeDependencies) {
|
|
3400
|
-
const depNode = graph
|
|
3399
|
+
const depNode = graph.nodes.get(depPointer);
|
|
3401
3400
|
if (depNode?.scopes) {
|
|
3402
3401
|
if (propagateScopesToNode(depNode, nodeInfo)) notifyAllDependents(pointer, nodeInfo);
|
|
3403
3402
|
}
|
|
3404
3403
|
}
|
|
3405
3404
|
if (nodeInfo.parentPointer) {
|
|
3406
|
-
const parentInfo = graph
|
|
3405
|
+
const parentInfo = graph.nodes.get(nodeInfo.parentPointer);
|
|
3407
3406
|
if (parentInfo) {
|
|
3408
3407
|
if (propagateScopesToNode(nodeInfo, parentInfo)) notifyAllDependents(nodeInfo.parentPointer, parentInfo);
|
|
3409
3408
|
}
|
|
@@ -3466,48 +3465,48 @@ const seedLocalScopes = (nodes) => {
|
|
|
3466
3465
|
*/
|
|
3467
3466
|
function buildGraph(root, logger) {
|
|
3468
3467
|
const eventBuildGraph = logger.timeEvent("build-graph");
|
|
3469
|
-
const graph
|
|
3468
|
+
const graph = {
|
|
3470
3469
|
nodeDependencies: /* @__PURE__ */ new Map(),
|
|
3471
3470
|
nodes: /* @__PURE__ */ new Map(),
|
|
3472
3471
|
reverseNodeDependencies: /* @__PURE__ */ new Map(),
|
|
3473
3472
|
subtreeDependencies: /* @__PURE__ */ new Map(),
|
|
3474
3473
|
transitiveDependencies: /* @__PURE__ */ new Map()
|
|
3475
3474
|
};
|
|
3476
|
-
const walk
|
|
3475
|
+
const walk = ({ key, node, parentPointer, path }) => {
|
|
3477
3476
|
if (typeof node !== "object" || node === null) return;
|
|
3478
|
-
const pointer = pathToJsonPointer(path
|
|
3477
|
+
const pointer = pathToJsonPointer(path);
|
|
3479
3478
|
let deprecated;
|
|
3480
3479
|
let tags;
|
|
3481
3480
|
if (typeof node === "object" && node !== null) {
|
|
3482
3481
|
if ("deprecated" in node && typeof node.deprecated === "boolean") deprecated = Boolean(node.deprecated);
|
|
3483
3482
|
if ("$ref" in node && typeof node.$ref === "string") {
|
|
3484
3483
|
const refPointer = normalizeJsonPointer(node.$ref);
|
|
3485
|
-
if (!graph
|
|
3486
|
-
graph
|
|
3484
|
+
if (!graph.nodeDependencies.has(pointer)) graph.nodeDependencies.set(pointer, /* @__PURE__ */ new Set());
|
|
3485
|
+
graph.nodeDependencies.get(pointer).add(refPointer);
|
|
3487
3486
|
}
|
|
3488
3487
|
if ("tags" in node && node.tags instanceof Array) tags = new Set(node.tags.filter((tag) => typeof tag === "string"));
|
|
3489
3488
|
}
|
|
3490
|
-
graph
|
|
3489
|
+
graph.nodes.set(pointer, {
|
|
3491
3490
|
deprecated,
|
|
3492
3491
|
key,
|
|
3493
3492
|
node,
|
|
3494
3493
|
parentPointer,
|
|
3495
3494
|
tags
|
|
3496
3495
|
});
|
|
3497
|
-
if (node instanceof Array) node.forEach((item, index) => walk
|
|
3496
|
+
if (node instanceof Array) node.forEach((item, index) => walk({
|
|
3498
3497
|
key: index,
|
|
3499
3498
|
node: item,
|
|
3500
3499
|
parentPointer: pointer,
|
|
3501
|
-
path: [...path
|
|
3500
|
+
path: [...path, index]
|
|
3502
3501
|
}));
|
|
3503
|
-
else for (const [childKey, value] of Object.entries(node)) walk
|
|
3502
|
+
else for (const [childKey, value] of Object.entries(node)) walk({
|
|
3504
3503
|
key: childKey,
|
|
3505
3504
|
node: value,
|
|
3506
3505
|
parentPointer: pointer,
|
|
3507
|
-
path: [...path
|
|
3506
|
+
path: [...path, childKey]
|
|
3508
3507
|
});
|
|
3509
3508
|
};
|
|
3510
|
-
walk
|
|
3509
|
+
walk({
|
|
3511
3510
|
key: null,
|
|
3512
3511
|
node: root,
|
|
3513
3512
|
parentPointer: null,
|
|
@@ -3518,31 +3517,31 @@ function buildGraph(root, logger) {
|
|
|
3518
3517
|
subtreeDependencies: /* @__PURE__ */ new Map(),
|
|
3519
3518
|
transitiveDependencies: /* @__PURE__ */ new Map()
|
|
3520
3519
|
};
|
|
3521
|
-
for (const [pointer, nodeInfo] of graph
|
|
3520
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
3522
3521
|
const parent = nodeInfo.parentPointer;
|
|
3523
3522
|
if (!parent) continue;
|
|
3524
3523
|
if (!cache.parentToChildren.has(parent)) cache.parentToChildren.set(parent, []);
|
|
3525
3524
|
cache.parentToChildren.get(parent).push(pointer);
|
|
3526
3525
|
}
|
|
3527
|
-
for (const [pointerFrom, pointers] of graph
|
|
3528
|
-
if (!graph
|
|
3529
|
-
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);
|
|
3530
3529
|
}
|
|
3531
|
-
seedLocalScopes(graph
|
|
3532
|
-
propagateScopes(graph
|
|
3533
|
-
annotateChildScopes(graph
|
|
3534
|
-
for (const pointer of graph
|
|
3530
|
+
seedLocalScopes(graph.nodes);
|
|
3531
|
+
propagateScopes(graph);
|
|
3532
|
+
annotateChildScopes(graph.nodes);
|
|
3533
|
+
for (const pointer of graph.nodes.keys()) {
|
|
3535
3534
|
const result = collectPointerDependencies({
|
|
3536
3535
|
cache,
|
|
3537
|
-
graph
|
|
3536
|
+
graph,
|
|
3538
3537
|
pointer,
|
|
3539
3538
|
visited: /* @__PURE__ */ new Set()
|
|
3540
3539
|
});
|
|
3541
|
-
graph
|
|
3542
|
-
graph
|
|
3540
|
+
graph.transitiveDependencies.set(pointer, result.transitiveDependencies);
|
|
3541
|
+
graph.subtreeDependencies.set(pointer, result.subtreeDependencies);
|
|
3543
3542
|
}
|
|
3544
3543
|
eventBuildGraph.timeEnd();
|
|
3545
|
-
return { graph
|
|
3544
|
+
return { graph };
|
|
3546
3545
|
}
|
|
3547
3546
|
|
|
3548
3547
|
//#endregion
|
|
@@ -3559,16 +3558,16 @@ const schemaKeys = new Set([
|
|
|
3559
3558
|
"schema",
|
|
3560
3559
|
"unevaluatedProperties"
|
|
3561
3560
|
]);
|
|
3562
|
-
const getComponentContext = (path
|
|
3563
|
-
if (path
|
|
3564
|
-
const type = path
|
|
3561
|
+
const getComponentContext = (path) => {
|
|
3562
|
+
if (path.length === 3 && path[0] === "components") {
|
|
3563
|
+
const type = path[1];
|
|
3565
3564
|
if (type === "parameters") return "write";
|
|
3566
3565
|
if (type === "requestBodies") return "write";
|
|
3567
3566
|
if (type === "responses") return "read";
|
|
3568
3567
|
if (type === "headers") return "read";
|
|
3569
3568
|
}
|
|
3570
|
-
if (path
|
|
3571
|
-
const type = path
|
|
3569
|
+
if (path.length === 2) {
|
|
3570
|
+
const type = path[0];
|
|
3572
3571
|
if (type === "parameters") return "write";
|
|
3573
3572
|
if (type === "responses") return "read";
|
|
3574
3573
|
}
|
|
@@ -3613,10 +3612,10 @@ const insertSplitSchemasIntoSpec = ({ logger, spec, split }) => {
|
|
|
3613
3612
|
* @param scope - The scope to exclude ('readOnly' or 'writeOnly')
|
|
3614
3613
|
* @returns boolean - Whether the schema should be removed from its parent
|
|
3615
3614
|
*/
|
|
3616
|
-
const pruneSchemaByScope = (graph
|
|
3615
|
+
const pruneSchemaByScope = (graph, schema, scope) => {
|
|
3617
3616
|
if (schema && typeof schema === "object") {
|
|
3618
3617
|
if ("$ref" in schema && typeof schema.$ref === "string") {
|
|
3619
|
-
const nodeInfo = graph
|
|
3618
|
+
const nodeInfo = graph.nodes.get(schema.$ref);
|
|
3620
3619
|
if (nodeInfo?.scopes) {
|
|
3621
3620
|
if (scope === "writeOnly" && nodeInfo.scopes.size === 1 && nodeInfo.scopes.has("write") || scope === "readOnly" && nodeInfo.scopes.size === 1 && nodeInfo.scopes.has("read")) {
|
|
3622
3621
|
delete schema["$ref"];
|
|
@@ -3631,7 +3630,7 @@ const pruneSchemaByScope = (graph$1, schema, scope) => {
|
|
|
3631
3630
|
for (let index = value.length - 1; index >= 0; index--) {
|
|
3632
3631
|
const item = value[index];
|
|
3633
3632
|
if (item && typeof item === "object" && item[scope] === true) value.splice(index, 1);
|
|
3634
|
-
else if (pruneSchemaByScope(graph
|
|
3633
|
+
else if (pruneSchemaByScope(graph, item, scope)) value.splice(index, 1);
|
|
3635
3634
|
}
|
|
3636
3635
|
if (!value.length) delete schema[keyword];
|
|
3637
3636
|
} else if (type === "objectMap" && typeof value === "object" && value !== null && !(value instanceof Array)) {
|
|
@@ -3642,7 +3641,7 @@ const pruneSchemaByScope = (graph$1, schema, scope) => {
|
|
|
3642
3641
|
if (prop && typeof prop === "object" && prop[scope] === true) {
|
|
3643
3642
|
delete objMap[key];
|
|
3644
3643
|
if (keyword === "properties") removedProperties.add(key);
|
|
3645
|
-
} else if (pruneSchemaByScope(graph
|
|
3644
|
+
} else if (pruneSchemaByScope(graph, prop, scope)) {
|
|
3646
3645
|
delete objMap[key];
|
|
3647
3646
|
if (keyword === "properties") removedProperties.add(key);
|
|
3648
3647
|
}
|
|
@@ -3655,18 +3654,18 @@ const pruneSchemaByScope = (graph$1, schema, scope) => {
|
|
|
3655
3654
|
if (!Object.keys(objMap).length) delete schema[keyword];
|
|
3656
3655
|
} else if (type === "single" && typeof value === "object" && value !== null) {
|
|
3657
3656
|
if (value[scope] === true) delete schema[keyword];
|
|
3658
|
-
else if (pruneSchemaByScope(graph
|
|
3657
|
+
else if (pruneSchemaByScope(graph, value, scope)) delete schema[keyword];
|
|
3659
3658
|
} else if (type === "singleOrArray") {
|
|
3660
3659
|
if (value instanceof Array) {
|
|
3661
3660
|
for (let index = value.length - 1; index >= 0; index--) {
|
|
3662
3661
|
const item = value[index];
|
|
3663
3662
|
if (item && typeof item === "object" && item[scope] === true) value.splice(index, 1);
|
|
3664
|
-
else if (pruneSchemaByScope(graph
|
|
3663
|
+
else if (pruneSchemaByScope(graph, item, scope)) value.splice(index, 1);
|
|
3665
3664
|
}
|
|
3666
3665
|
if (!value.length) delete schema[keyword];
|
|
3667
3666
|
} else if (typeof value === "object" && value !== null) {
|
|
3668
3667
|
if (value[scope] === true) delete schema[keyword];
|
|
3669
|
-
else if (pruneSchemaByScope(graph
|
|
3668
|
+
else if (pruneSchemaByScope(graph, value, scope)) delete schema[keyword];
|
|
3670
3669
|
}
|
|
3671
3670
|
}
|
|
3672
3671
|
}
|
|
@@ -3686,8 +3685,8 @@ const removeOriginalSplitSchemas = ({ logger, originalSchemas, spec, split }) =>
|
|
|
3686
3685
|
const event = logger.timeEvent("remove-original-split-schemas");
|
|
3687
3686
|
const schemasObj = getSchemasObject(spec);
|
|
3688
3687
|
for (const originalPointer of Object.keys(split.mapping)) {
|
|
3689
|
-
const path
|
|
3690
|
-
const name = path
|
|
3688
|
+
const path = jsonPointerToPath(originalPointer);
|
|
3689
|
+
const name = path[path.length - 1];
|
|
3691
3690
|
if (typeof name === "string" && schemasObj && Object.prototype.hasOwnProperty.call(schemasObj, name) && schemasObj[name] === originalSchemas[originalPointer]) delete schemasObj[name];
|
|
3692
3691
|
}
|
|
3693
3692
|
event.timeEnd();
|
|
@@ -3787,7 +3786,7 @@ function splitDiscriminatorSchemas({ config, existingNames, schemasPointerNamesp
|
|
|
3787
3786
|
* @param spec - The OpenAPI spec object
|
|
3788
3787
|
* @returns SplitSchemas - The split schemas and pointer mappings
|
|
3789
3788
|
*/
|
|
3790
|
-
const splitSchemas = ({ config, graph
|
|
3789
|
+
const splitSchemas = ({ config, graph, logger, spec }) => {
|
|
3791
3790
|
const event = logger.timeEvent("split-schemas");
|
|
3792
3791
|
const existingNames = /* @__PURE__ */ new Set();
|
|
3793
3792
|
const split = {
|
|
@@ -3805,20 +3804,20 @@ const splitSchemas = ({ config, graph: graph$1, logger, spec }) => {
|
|
|
3805
3804
|
*/
|
|
3806
3805
|
const pointerToSchema = (pointer) => {
|
|
3807
3806
|
if (pointer.startsWith(schemasPointerNamespace)) {
|
|
3808
|
-
const path
|
|
3809
|
-
if (path
|
|
3807
|
+
const path = jsonPointerToPath(pointer);
|
|
3808
|
+
if (path.length === schemasNamespaceSegments) return path[schemasNamespaceSegments - 1] || "";
|
|
3810
3809
|
}
|
|
3811
3810
|
return "";
|
|
3812
3811
|
};
|
|
3813
|
-
for (const pointer of graph
|
|
3812
|
+
for (const pointer of graph.nodes.keys()) {
|
|
3814
3813
|
const name = pointerToSchema(pointer);
|
|
3815
3814
|
if (name) existingNames.add(name);
|
|
3816
3815
|
}
|
|
3817
|
-
for (const [pointer, nodeInfo] of graph
|
|
3816
|
+
for (const [pointer, nodeInfo] of graph.nodes) {
|
|
3818
3817
|
const name = pointerToSchema(pointer);
|
|
3819
3818
|
if (!name || !(nodeInfo.scopes?.has("read") || nodeInfo.scopes?.has("write")) || !nodeInfo.scopes?.has("normal")) continue;
|
|
3820
3819
|
const readSchema = deepClone(nodeInfo.node);
|
|
3821
|
-
pruneSchemaByScope(graph
|
|
3820
|
+
pruneSchemaByScope(graph, readSchema, "writeOnly");
|
|
3822
3821
|
const readBase = applyNaming(name, config.responses);
|
|
3823
3822
|
const readName = readBase === name ? readBase : getUniqueComponentName({
|
|
3824
3823
|
base: readBase,
|
|
@@ -3828,12 +3827,12 @@ const splitSchemas = ({ config, graph: graph$1, logger, spec }) => {
|
|
|
3828
3827
|
split.schemas[readName] = readSchema;
|
|
3829
3828
|
const readPointer = `${schemasPointerNamespace}${readName}`;
|
|
3830
3829
|
const writeSchema = deepClone(nodeInfo.node);
|
|
3831
|
-
pruneSchemaByScope(graph
|
|
3832
|
-
const transitiveDeps = graph
|
|
3830
|
+
pruneSchemaByScope(graph, writeSchema, "readOnly");
|
|
3831
|
+
const transitiveDeps = graph.transitiveDependencies.get(pointer) || /* @__PURE__ */ new Set();
|
|
3833
3832
|
if (!Array.from(transitiveDeps).some((depPointer) => {
|
|
3834
|
-
const depNodeInfo = graph
|
|
3833
|
+
const depNodeInfo = graph.nodes.get(depPointer);
|
|
3835
3834
|
return depNodeInfo?.scopes?.has("normal") && (depNodeInfo.scopes.has("read") || depNodeInfo.scopes.has("write"));
|
|
3836
|
-
}) &&
|
|
3835
|
+
}) && deepEqual(readSchema, writeSchema) && deepEqual(readSchema, nodeInfo.node)) continue;
|
|
3837
3836
|
const writeBase = applyNaming(name, config.requests);
|
|
3838
3837
|
const writeName = writeBase === name && writeBase !== readName ? writeBase : getUniqueComponentName({
|
|
3839
3838
|
base: writeBase,
|
|
@@ -3869,20 +3868,20 @@ const splitSchemas = ({ config, graph: graph$1, logger, spec }) => {
|
|
|
3869
3868
|
const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
3870
3869
|
const event = logger.timeEvent("update-refs-in-spec");
|
|
3871
3870
|
const schemasPointerNamespace = specToSchemasPointerNamespace(spec);
|
|
3872
|
-
const walk
|
|
3873
|
-
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({
|
|
3874
3873
|
context,
|
|
3875
3874
|
currentPointer,
|
|
3876
3875
|
inSchema,
|
|
3877
3876
|
node: item,
|
|
3878
|
-
path: [...path
|
|
3877
|
+
path: [...path, index],
|
|
3879
3878
|
visited
|
|
3880
3879
|
}));
|
|
3881
3880
|
else if (node && typeof node === "object") {
|
|
3882
3881
|
let nextPointer = currentPointer;
|
|
3883
3882
|
let nextContext = context;
|
|
3884
|
-
if (isPathRootSchema(path
|
|
3885
|
-
nextPointer = `${schemasPointerNamespace}${path
|
|
3883
|
+
if (isPathRootSchema(path)) {
|
|
3884
|
+
nextPointer = `${schemasPointerNamespace}${path[path.length - 1]}`;
|
|
3886
3885
|
const originalPointer = split.reverseMapping[nextPointer];
|
|
3887
3886
|
if (originalPointer) {
|
|
3888
3887
|
const mapping = split.mapping[originalPointer];
|
|
@@ -3890,16 +3889,16 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3890
3889
|
else if (mapping?.write === nextPointer) nextContext = "write";
|
|
3891
3890
|
}
|
|
3892
3891
|
}
|
|
3893
|
-
const compContext = getComponentContext(path
|
|
3892
|
+
const compContext = getComponentContext(path);
|
|
3894
3893
|
if (compContext !== void 0) {
|
|
3895
3894
|
for (const key in node) {
|
|
3896
3895
|
if (!Object.prototype.hasOwnProperty.call(node, key)) continue;
|
|
3897
|
-
walk
|
|
3896
|
+
walk({
|
|
3898
3897
|
context: compContext,
|
|
3899
3898
|
currentPointer: nextPointer,
|
|
3900
3899
|
inSchema: false,
|
|
3901
3900
|
node: node[key],
|
|
3902
|
-
path: [...path
|
|
3901
|
+
path: [...path, key],
|
|
3903
3902
|
visited
|
|
3904
3903
|
});
|
|
3905
3904
|
}
|
|
@@ -3910,49 +3909,49 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3910
3909
|
const value = node[key];
|
|
3911
3910
|
if (!inSchema) {
|
|
3912
3911
|
if (key === "requestBody") {
|
|
3913
|
-
walk
|
|
3912
|
+
walk({
|
|
3914
3913
|
context: "write",
|
|
3915
3914
|
currentPointer: nextPointer,
|
|
3916
3915
|
inSchema: false,
|
|
3917
3916
|
node: value,
|
|
3918
|
-
path: [...path
|
|
3917
|
+
path: [...path, key],
|
|
3919
3918
|
visited
|
|
3920
3919
|
});
|
|
3921
3920
|
continue;
|
|
3922
3921
|
}
|
|
3923
3922
|
if (key === "responses") {
|
|
3924
|
-
walk
|
|
3923
|
+
walk({
|
|
3925
3924
|
context: "read",
|
|
3926
3925
|
currentPointer: nextPointer,
|
|
3927
3926
|
inSchema: false,
|
|
3928
3927
|
node: value,
|
|
3929
|
-
path: [...path
|
|
3928
|
+
path: [...path, key],
|
|
3930
3929
|
visited
|
|
3931
3930
|
});
|
|
3932
3931
|
continue;
|
|
3933
3932
|
}
|
|
3934
3933
|
if (key === "parameters" && Array.isArray(value)) {
|
|
3935
3934
|
value.forEach((param, index) => {
|
|
3936
|
-
if (param && typeof param === "object" && "schema" in param) walk
|
|
3935
|
+
if (param && typeof param === "object" && "schema" in param) walk({
|
|
3937
3936
|
context: "write",
|
|
3938
3937
|
currentPointer: nextPointer,
|
|
3939
3938
|
inSchema: true,
|
|
3940
3939
|
node: param.schema,
|
|
3941
3940
|
path: [
|
|
3942
|
-
...path
|
|
3941
|
+
...path,
|
|
3943
3942
|
key,
|
|
3944
3943
|
index,
|
|
3945
3944
|
"schema"
|
|
3946
3945
|
],
|
|
3947
3946
|
visited
|
|
3948
3947
|
});
|
|
3949
|
-
if (param && typeof param === "object" && "content" in param) walk
|
|
3948
|
+
if (param && typeof param === "object" && "content" in param) walk({
|
|
3950
3949
|
context: "write",
|
|
3951
3950
|
currentPointer: nextPointer,
|
|
3952
3951
|
inSchema: false,
|
|
3953
3952
|
node: param.content,
|
|
3954
3953
|
path: [
|
|
3955
|
-
...path
|
|
3954
|
+
...path,
|
|
3956
3955
|
key,
|
|
3957
3956
|
index,
|
|
3958
3957
|
"content"
|
|
@@ -3965,13 +3964,13 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3965
3964
|
if (key === "headers" && typeof value === "object" && value !== null) {
|
|
3966
3965
|
for (const headerKey in value) {
|
|
3967
3966
|
if (!Object.prototype.hasOwnProperty.call(value, headerKey)) continue;
|
|
3968
|
-
walk
|
|
3967
|
+
walk({
|
|
3969
3968
|
context: "read",
|
|
3970
3969
|
currentPointer: nextPointer,
|
|
3971
3970
|
inSchema: false,
|
|
3972
3971
|
node: value[headerKey],
|
|
3973
3972
|
path: [
|
|
3974
|
-
...path
|
|
3973
|
+
...path,
|
|
3975
3974
|
key,
|
|
3976
3975
|
headerKey
|
|
3977
3976
|
],
|
|
@@ -3981,12 +3980,12 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
3981
3980
|
continue;
|
|
3982
3981
|
}
|
|
3983
3982
|
}
|
|
3984
|
-
if (schemaKeys.has(key)) walk
|
|
3983
|
+
if (schemaKeys.has(key)) walk({
|
|
3985
3984
|
context: nextContext,
|
|
3986
3985
|
currentPointer: nextPointer,
|
|
3987
3986
|
inSchema: true,
|
|
3988
3987
|
node: value,
|
|
3989
|
-
path: [...path
|
|
3988
|
+
path: [...path, key],
|
|
3990
3989
|
visited
|
|
3991
3990
|
});
|
|
3992
3991
|
else if (key === "$ref" && typeof value === "string") {
|
|
@@ -4008,26 +4007,26 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
4008
4007
|
}
|
|
4009
4008
|
value.mapping = updatedMapping;
|
|
4010
4009
|
}
|
|
4011
|
-
walk
|
|
4010
|
+
walk({
|
|
4012
4011
|
context: nextContext,
|
|
4013
4012
|
currentPointer: nextPointer,
|
|
4014
4013
|
inSchema,
|
|
4015
4014
|
node: value,
|
|
4016
|
-
path: [...path
|
|
4015
|
+
path: [...path, key],
|
|
4017
4016
|
visited
|
|
4018
4017
|
});
|
|
4019
|
-
} else walk
|
|
4018
|
+
} else walk({
|
|
4020
4019
|
context: nextContext,
|
|
4021
4020
|
currentPointer: nextPointer,
|
|
4022
4021
|
inSchema,
|
|
4023
4022
|
node: value,
|
|
4024
|
-
path: [...path
|
|
4023
|
+
path: [...path, key],
|
|
4025
4024
|
visited
|
|
4026
4025
|
});
|
|
4027
4026
|
}
|
|
4028
4027
|
}
|
|
4029
4028
|
};
|
|
4030
|
-
walk
|
|
4029
|
+
walk({
|
|
4031
4030
|
context: null,
|
|
4032
4031
|
currentPointer: null,
|
|
4033
4032
|
inSchema: false,
|
|
@@ -4048,11 +4047,11 @@ const updateRefsInSpec = ({ logger, spec, split }) => {
|
|
|
4048
4047
|
* @param spec - The OpenAPI spec object
|
|
4049
4048
|
*/
|
|
4050
4049
|
const readWriteTransform = ({ config, logger, spec }) => {
|
|
4051
|
-
const { graph
|
|
4050
|
+
const { graph } = buildGraph(spec, logger);
|
|
4052
4051
|
const originalSchemas = captureOriginalSchemas(spec, logger);
|
|
4053
4052
|
const split = splitSchemas({
|
|
4054
4053
|
config,
|
|
4055
|
-
graph
|
|
4054
|
+
graph,
|
|
4056
4055
|
logger,
|
|
4057
4056
|
spec
|
|
4058
4057
|
});
|
|
@@ -4170,7 +4169,7 @@ const mergeParametersObjects = ({ source, target }) => {
|
|
|
4170
4169
|
//#endregion
|
|
4171
4170
|
//#region src/openApi/shared/utils/validator.ts
|
|
4172
4171
|
const isSimpleKey = (key) => /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(key);
|
|
4173
|
-
const formatPath = (path
|
|
4172
|
+
const formatPath = (path) => path.map((segment, i) => {
|
|
4174
4173
|
if (typeof segment === "number") return `[${segment}]`;
|
|
4175
4174
|
if (i === 0) return segment;
|
|
4176
4175
|
return isSimpleKey(segment) ? `.${segment}` : `['${segment.replace(/"/g, "\\'")}']`;
|
|
@@ -4213,17 +4212,17 @@ const filterSpec$2 = ({ logger, operations, preserveOrder, schemas, spec }) => {
|
|
|
4213
4212
|
spec.definitions = filtered;
|
|
4214
4213
|
}
|
|
4215
4214
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
4216
|
-
const path
|
|
4215
|
+
const path = entry[0];
|
|
4217
4216
|
const pathItem = entry[1];
|
|
4218
4217
|
for (const method of httpMethods) {
|
|
4219
4218
|
if (!pathItem[method]) continue;
|
|
4220
4219
|
const key = addNamespace("operation", createOperationKey({
|
|
4221
4220
|
method,
|
|
4222
|
-
path
|
|
4221
|
+
path
|
|
4223
4222
|
}));
|
|
4224
4223
|
if (!operations.has(key)) delete pathItem[method];
|
|
4225
4224
|
}
|
|
4226
|
-
if (!Object.keys(pathItem).length) delete spec.paths[path
|
|
4225
|
+
if (!Object.keys(pathItem).length) delete spec.paths[path];
|
|
4227
4226
|
}
|
|
4228
4227
|
eventFilterSpec.timeEnd();
|
|
4229
4228
|
};
|
|
@@ -4479,20 +4478,20 @@ const parseAllOf$2 = ({ context, schema, state }) => {
|
|
|
4479
4478
|
else irCompositionSchema.required = schema.required;
|
|
4480
4479
|
schemaItems.push(irCompositionSchema);
|
|
4481
4480
|
if (compositionSchema.$ref) {
|
|
4482
|
-
const ref
|
|
4483
|
-
if (ref
|
|
4481
|
+
const ref = context.resolveRef(compositionSchema.$ref);
|
|
4482
|
+
if (ref.discriminator && state.$ref) {
|
|
4484
4483
|
const valueSchemas = discriminatorValues(state.$ref).map((value) => ({
|
|
4485
4484
|
const: value,
|
|
4486
4485
|
type: "string"
|
|
4487
4486
|
}));
|
|
4488
4487
|
const irDiscriminatorSchema = {
|
|
4489
|
-
properties: { [ref
|
|
4488
|
+
properties: { [ref.discriminator]: valueSchemas.length > 1 ? {
|
|
4490
4489
|
items: valueSchemas,
|
|
4491
4490
|
logicalOperator: "or"
|
|
4492
4491
|
} : valueSchemas[0] },
|
|
4493
4492
|
type: "object"
|
|
4494
4493
|
};
|
|
4495
|
-
if (ref
|
|
4494
|
+
if (ref.required?.includes(ref.discriminator)) irDiscriminatorSchema.required = [ref.discriminator];
|
|
4496
4495
|
schemaItems.push(irDiscriminatorSchema);
|
|
4497
4496
|
}
|
|
4498
4497
|
}
|
|
@@ -4585,13 +4584,13 @@ const parseRef$2 = ({ context, schema, state }) => {
|
|
|
4585
4584
|
const refSchema = context.resolveRef(schema.$ref);
|
|
4586
4585
|
const originalRef = state.$ref;
|
|
4587
4586
|
state.$ref = schema.$ref;
|
|
4588
|
-
const irSchema
|
|
4587
|
+
const irSchema = schemaToIrSchema$2({
|
|
4589
4588
|
context,
|
|
4590
4589
|
schema: refSchema,
|
|
4591
4590
|
state
|
|
4592
4591
|
});
|
|
4593
4592
|
state.$ref = originalRef;
|
|
4594
|
-
return irSchema
|
|
4593
|
+
return irSchema;
|
|
4595
4594
|
}
|
|
4596
4595
|
}
|
|
4597
4596
|
irSchema.$ref = decodeURI(schema.$ref);
|
|
@@ -4758,19 +4757,19 @@ const isPaginationType$2 = (schemaType) => schemaType === "boolean" || schemaTyp
|
|
|
4758
4757
|
const paginationField$2 = ({ context, name, schema }) => {
|
|
4759
4758
|
if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) return true;
|
|
4760
4759
|
if ("$ref" in schema) {
|
|
4761
|
-
const ref
|
|
4762
|
-
if ("in" in ref
|
|
4760
|
+
const ref = context.resolveRef(schema.$ref ?? "");
|
|
4761
|
+
if ("in" in ref && ref.in) return paginationField$2({
|
|
4763
4762
|
context,
|
|
4764
4763
|
name,
|
|
4765
|
-
schema: "schema" in ref
|
|
4766
|
-
...ref
|
|
4764
|
+
schema: "schema" in ref ? ref.schema : {
|
|
4765
|
+
...ref,
|
|
4767
4766
|
in: void 0
|
|
4768
4767
|
}
|
|
4769
4768
|
});
|
|
4770
4769
|
return paginationField$2({
|
|
4771
4770
|
context,
|
|
4772
4771
|
name,
|
|
4773
|
-
schema: ref
|
|
4772
|
+
schema: ref
|
|
4774
4773
|
});
|
|
4775
4774
|
}
|
|
4776
4775
|
if ("in" in schema) {
|
|
@@ -4784,10 +4783,10 @@ const paginationField$2 = ({ context, name, schema }) => {
|
|
|
4784
4783
|
}
|
|
4785
4784
|
});
|
|
4786
4785
|
}
|
|
4787
|
-
for (const name
|
|
4788
|
-
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];
|
|
4789
4788
|
if (typeof property !== "boolean" && !("$ref" in property)) {
|
|
4790
|
-
if (isPaginationType$2(getSchemaType$1({ schema: property }))) return name
|
|
4789
|
+
if (isPaginationType$2(getSchemaType$1({ schema: property }))) return name;
|
|
4791
4790
|
}
|
|
4792
4791
|
}
|
|
4793
4792
|
for (const allOf of schema.allOf ?? []) {
|
|
@@ -4809,17 +4808,17 @@ const parseOperationJsDoc$2 = ({ irOperation, operation }) => {
|
|
|
4809
4808
|
if (operation.summary) irOperation.summary = operation.summary;
|
|
4810
4809
|
if (operation.tags?.length) irOperation.tags = operation.tags;
|
|
4811
4810
|
};
|
|
4812
|
-
const initIrOperation$2 = ({ context, method, operation, path
|
|
4811
|
+
const initIrOperation$2 = ({ context, method, operation, path, state }) => {
|
|
4813
4812
|
const irOperation = {
|
|
4814
4813
|
id: operationToId({
|
|
4815
4814
|
context,
|
|
4816
4815
|
id: operation.operationId,
|
|
4817
4816
|
method,
|
|
4818
|
-
path
|
|
4817
|
+
path,
|
|
4819
4818
|
state
|
|
4820
4819
|
}),
|
|
4821
4820
|
method,
|
|
4822
|
-
path
|
|
4821
|
+
path
|
|
4823
4822
|
};
|
|
4824
4823
|
if (operation.operationId) irOperation.operationId = operation.operationId;
|
|
4825
4824
|
parseOperationJsDoc$2({
|
|
@@ -4832,12 +4831,12 @@ const initIrOperation$2 = ({ context, method, operation, path: path$1, state })
|
|
|
4832
4831
|
});
|
|
4833
4832
|
return irOperation;
|
|
4834
4833
|
};
|
|
4835
|
-
const operationToIrOperation$2 = ({ context, method, operation, path
|
|
4834
|
+
const operationToIrOperation$2 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
4836
4835
|
const irOperation = initIrOperation$2({
|
|
4837
4836
|
context,
|
|
4838
4837
|
method,
|
|
4839
4838
|
operation,
|
|
4840
|
-
path
|
|
4839
|
+
path,
|
|
4841
4840
|
state
|
|
4842
4841
|
});
|
|
4843
4842
|
if (operation.parameters) irOperation.parameters = operation.parameters;
|
|
@@ -4868,7 +4867,7 @@ const operationToIrOperation$2 = ({ context, method, operation, path: path$1, se
|
|
|
4868
4867
|
mimeTypes,
|
|
4869
4868
|
response: { schema }
|
|
4870
4869
|
});
|
|
4871
|
-
const content = contents.find((content
|
|
4870
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
4872
4871
|
if (content) {
|
|
4873
4872
|
const pagination = paginationField$2({
|
|
4874
4873
|
context,
|
|
@@ -4924,7 +4923,7 @@ const operationToIrOperation$2 = ({ context, method, operation, path: path$1, se
|
|
|
4924
4923
|
mimeTypes: operation.produces ? operation.produces : ["application/json"],
|
|
4925
4924
|
response: responseObject
|
|
4926
4925
|
});
|
|
4927
|
-
const content = contents.find((content
|
|
4926
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
4928
4927
|
if (content) irOperation.responses[name] = {
|
|
4929
4928
|
mediaType: content.mediaType,
|
|
4930
4929
|
schema: schemaToIrSchema$2({
|
|
@@ -4994,14 +4993,14 @@ const operationToIrOperation$2 = ({ context, method, operation, path: path$1, se
|
|
|
4994
4993
|
}
|
|
4995
4994
|
return irOperation;
|
|
4996
4995
|
};
|
|
4997
|
-
const parsePathOperation$2 = ({ context, method, operation, path
|
|
4996
|
+
const parsePathOperation$2 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
4998
4997
|
if (!context.ir.paths) context.ir.paths = {};
|
|
4999
|
-
if (!context.ir.paths[path
|
|
5000
|
-
context.ir.paths[path
|
|
4998
|
+
if (!context.ir.paths[path]) context.ir.paths[path] = {};
|
|
4999
|
+
context.ir.paths[path][method] = operationToIrOperation$2({
|
|
5001
5000
|
context,
|
|
5002
5001
|
method,
|
|
5003
5002
|
operation,
|
|
5004
|
-
path
|
|
5003
|
+
path,
|
|
5005
5004
|
securitySchemesMap,
|
|
5006
5005
|
state
|
|
5007
5006
|
});
|
|
@@ -5015,10 +5014,6 @@ const parsePathOperation$2 = ({ context, method, operation, path: path$1, securi
|
|
|
5015
5014
|
const defaultExplode$2 = (collectionFormat) => {
|
|
5016
5015
|
switch (collectionFormat) {
|
|
5017
5016
|
case "multi": return true;
|
|
5018
|
-
case "csv":
|
|
5019
|
-
case "pipes":
|
|
5020
|
-
case "ssv":
|
|
5021
|
-
case "tsv":
|
|
5022
5017
|
default: return false;
|
|
5023
5018
|
}
|
|
5024
5019
|
};
|
|
@@ -5029,7 +5024,6 @@ const defaultStyle$2 = (_in) => {
|
|
|
5029
5024
|
switch (_in) {
|
|
5030
5025
|
case "header":
|
|
5031
5026
|
case "path": return "simple";
|
|
5032
|
-
case "query":
|
|
5033
5027
|
default: return "form";
|
|
5034
5028
|
}
|
|
5035
5029
|
};
|
|
@@ -5114,12 +5108,12 @@ function parseUrl(value) {
|
|
|
5114
5108
|
if (!match) return errorResponse;
|
|
5115
5109
|
const host = match[5] || "";
|
|
5116
5110
|
if (host === "." || host === "..") return errorResponse;
|
|
5117
|
-
const path
|
|
5111
|
+
const path = match[8] || "";
|
|
5118
5112
|
const protocol = match[2] || "";
|
|
5119
5113
|
if (protocol.length === 1) return errorResponse;
|
|
5120
5114
|
return {
|
|
5121
5115
|
host,
|
|
5122
|
-
path: path
|
|
5116
|
+
path: path === "/" ? "" : path,
|
|
5123
5117
|
port: match[7] || "",
|
|
5124
5118
|
protocol
|
|
5125
5119
|
};
|
|
@@ -5130,7 +5124,7 @@ function parseUrl(value) {
|
|
|
5130
5124
|
const parseServers$2 = ({ context }) => {
|
|
5131
5125
|
let schemes = context.spec.schemes ?? [];
|
|
5132
5126
|
let host = context.spec.host ?? "";
|
|
5133
|
-
const path
|
|
5127
|
+
const path = context.spec.basePath ?? "";
|
|
5134
5128
|
for (const input of context.config.input) if (typeof input.path === "string") {
|
|
5135
5129
|
const url = parseUrl(input.path);
|
|
5136
5130
|
if (!schemes.length) {
|
|
@@ -5139,7 +5133,7 @@ const parseServers$2 = ({ context }) => {
|
|
|
5139
5133
|
if (!host) host = `${url.host}${url.port ? `:${url.port}` : ""}`;
|
|
5140
5134
|
}
|
|
5141
5135
|
if (!schemes.length) schemes = [""];
|
|
5142
|
-
const servers = schemes.map((scheme) => `${scheme ? `${scheme}://` : ""}${host}${path
|
|
5136
|
+
const servers = schemes.map((scheme) => `${scheme ? `${scheme}://` : ""}${host}${path}`).filter(Boolean);
|
|
5143
5137
|
if (servers.length) context.ir.servers = servers.map((url) => ({ url }));
|
|
5144
5138
|
};
|
|
5145
5139
|
|
|
@@ -5150,7 +5144,7 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5150
5144
|
const issues = [];
|
|
5151
5145
|
const operationIds = /* @__PURE__ */ new Map();
|
|
5152
5146
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
5153
|
-
const path
|
|
5147
|
+
const path = entry[0];
|
|
5154
5148
|
const pathItem = entry[1];
|
|
5155
5149
|
for (const method of httpMethods) {
|
|
5156
5150
|
if (method === "trace") continue;
|
|
@@ -5158,7 +5152,7 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5158
5152
|
if (!operation) continue;
|
|
5159
5153
|
const operationKey = createOperationKey({
|
|
5160
5154
|
method,
|
|
5161
|
-
path
|
|
5155
|
+
path
|
|
5162
5156
|
});
|
|
5163
5157
|
if (operation.operationId) if (!operationIds.has(operation.operationId)) operationIds.set(operation.operationId, operationKey);
|
|
5164
5158
|
else issues.push({
|
|
@@ -5170,7 +5164,7 @@ const validateOpenApiSpec$2 = (spec, logger) => {
|
|
|
5170
5164
|
message: "Duplicate `operationId` found. Each `operationId` must be unique.",
|
|
5171
5165
|
path: [
|
|
5172
5166
|
"paths",
|
|
5173
|
-
path
|
|
5167
|
+
path,
|
|
5174
5168
|
method,
|
|
5175
5169
|
"operationId"
|
|
5176
5170
|
],
|
|
@@ -5194,8 +5188,8 @@ const parseV2_0_X = (context) => {
|
|
|
5194
5188
|
});
|
|
5195
5189
|
if (hasFilters(context.config.parser.filters)) {
|
|
5196
5190
|
const filters = createFilters(context.config.parser.filters, context.spec, context.logger);
|
|
5197
|
-
const { graph
|
|
5198
|
-
const { resourceMetadata } = buildResourceMetadata(graph
|
|
5191
|
+
const { graph } = buildGraph(context.spec, context.logger);
|
|
5192
|
+
const { resourceMetadata } = buildResourceMetadata(graph, context.logger);
|
|
5199
5193
|
filterSpec$2({
|
|
5200
5194
|
...createFilteredDependencies({
|
|
5201
5195
|
filters,
|
|
@@ -5224,9 +5218,9 @@ const parseV2_0_X = (context) => {
|
|
|
5224
5218
|
});
|
|
5225
5219
|
}
|
|
5226
5220
|
parseServers$2({ context });
|
|
5227
|
-
for (const path
|
|
5228
|
-
if (path
|
|
5229
|
-
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];
|
|
5230
5224
|
const finalPathItem = pathItem.$ref ? {
|
|
5231
5225
|
...context.resolveRef(pathItem.$ref),
|
|
5232
5226
|
...pathItem
|
|
@@ -5247,7 +5241,7 @@ const parseV2_0_X = (context) => {
|
|
|
5247
5241
|
parameters: finalPathItem.parameters
|
|
5248
5242
|
})
|
|
5249
5243
|
},
|
|
5250
|
-
path
|
|
5244
|
+
path,
|
|
5251
5245
|
securitySchemesMap,
|
|
5252
5246
|
state
|
|
5253
5247
|
};
|
|
@@ -5441,17 +5435,17 @@ const filterSpec$1 = ({ logger, operations, parameters, preserveOrder, requestBo
|
|
|
5441
5435
|
}
|
|
5442
5436
|
}
|
|
5443
5437
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
5444
|
-
const path
|
|
5438
|
+
const path = entry[0];
|
|
5445
5439
|
const pathItem = entry[1];
|
|
5446
5440
|
for (const method of httpMethods) {
|
|
5447
5441
|
if (!pathItem[method]) continue;
|
|
5448
5442
|
const key = addNamespace("operation", createOperationKey({
|
|
5449
5443
|
method,
|
|
5450
|
-
path
|
|
5444
|
+
path
|
|
5451
5445
|
}));
|
|
5452
5446
|
if (!operations.has(key)) delete pathItem[method];
|
|
5453
5447
|
}
|
|
5454
|
-
if (!Object.keys(pathItem).length) delete spec.paths[path
|
|
5448
|
+
if (!Object.keys(pathItem).length) delete spec.paths[path];
|
|
5455
5449
|
}
|
|
5456
5450
|
eventFilterSpec.timeEnd();
|
|
5457
5451
|
};
|
|
@@ -5665,11 +5659,11 @@ const parseAllOf$1 = ({ context, schema, state }) => {
|
|
|
5665
5659
|
else irCompositionSchema.required = schema.required;
|
|
5666
5660
|
schemaItems.push(irCompositionSchema);
|
|
5667
5661
|
if ("$ref" in compositionSchema) {
|
|
5668
|
-
const ref
|
|
5662
|
+
const ref = context.resolveRef(compositionSchema.$ref);
|
|
5669
5663
|
if (state.$ref) {
|
|
5670
5664
|
const discriminators = findDiscriminatorsInSchema$1({
|
|
5671
5665
|
context,
|
|
5672
|
-
schema: ref
|
|
5666
|
+
schema: ref
|
|
5673
5667
|
});
|
|
5674
5668
|
for (const { discriminator, oneOf } of discriminators) {
|
|
5675
5669
|
const values = discriminatorValues(state.$ref, discriminator.mapping, oneOf ? () => oneOf.some((o) => "$ref" in o && o.$ref === state.$ref) : void 0);
|
|
@@ -5678,7 +5672,7 @@ const parseAllOf$1 = ({ context, schema, state }) => {
|
|
|
5678
5672
|
const existingIndex = discriminatorsToAdd.findIndex((d) => d.discriminator.propertyName === discriminator.propertyName);
|
|
5679
5673
|
if (existingIndex !== -1) if (isExplicitMapping && !discriminatorsToAdd[existingIndex].isExplicitMapping) discriminatorsToAdd.splice(existingIndex, 1);
|
|
5680
5674
|
else continue;
|
|
5681
|
-
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref
|
|
5675
|
+
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref.required?.includes(d.discriminator.propertyName) || ref.allOf && ref.allOf.some((item) => {
|
|
5682
5676
|
return ("$ref" in item ? context.resolveRef(item.$ref) : item).required?.includes(d.discriminator.propertyName);
|
|
5683
5677
|
})));
|
|
5684
5678
|
discriminatorsToAdd.push({
|
|
@@ -5942,13 +5936,13 @@ const parseRef$1 = ({ context, schema, state }) => {
|
|
|
5942
5936
|
const refSchema = context.resolveRef(schema.$ref);
|
|
5943
5937
|
const originalRef = state.$ref;
|
|
5944
5938
|
state.$ref = schema.$ref;
|
|
5945
|
-
const irSchema
|
|
5939
|
+
const irSchema = schemaToIrSchema$1({
|
|
5946
5940
|
context,
|
|
5947
5941
|
schema: refSchema,
|
|
5948
5942
|
state
|
|
5949
5943
|
});
|
|
5950
5944
|
state.$ref = originalRef;
|
|
5951
|
-
return irSchema
|
|
5945
|
+
return irSchema;
|
|
5952
5946
|
}
|
|
5953
5947
|
}
|
|
5954
5948
|
const irSchema = {};
|
|
@@ -6125,13 +6119,13 @@ const isPaginationType$1 = (schemaType) => schemaType === "boolean" || schemaTyp
|
|
|
6125
6119
|
const paginationField$1 = ({ context, name, schema }) => {
|
|
6126
6120
|
if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) return true;
|
|
6127
6121
|
if ("$ref" in schema) {
|
|
6128
|
-
const ref
|
|
6129
|
-
if ("content" in ref
|
|
6122
|
+
const ref = context.resolveRef(schema.$ref);
|
|
6123
|
+
if ("content" in ref || "in" in ref) {
|
|
6130
6124
|
let refSchema;
|
|
6131
|
-
if ("in" in ref
|
|
6125
|
+
if ("in" in ref) refSchema = ref.schema;
|
|
6132
6126
|
if (!refSchema) {
|
|
6133
|
-
const contents = mediaTypeObjects$1({ content: ref
|
|
6134
|
-
const content = contents.find((content
|
|
6127
|
+
const contents = mediaTypeObjects$1({ content: ref.content });
|
|
6128
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6135
6129
|
if (content?.schema) refSchema = content.schema;
|
|
6136
6130
|
}
|
|
6137
6131
|
if (!refSchema) return false;
|
|
@@ -6144,13 +6138,13 @@ const paginationField$1 = ({ context, name, schema }) => {
|
|
|
6144
6138
|
return paginationField$1({
|
|
6145
6139
|
context,
|
|
6146
6140
|
name,
|
|
6147
|
-
schema: ref
|
|
6141
|
+
schema: ref
|
|
6148
6142
|
});
|
|
6149
6143
|
}
|
|
6150
|
-
for (const name
|
|
6151
|
-
const property = schema.properties[name
|
|
6144
|
+
for (const name in schema.properties) if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) {
|
|
6145
|
+
const property = schema.properties[name];
|
|
6152
6146
|
if (typeof property !== "boolean" && !("$ref" in property)) {
|
|
6153
|
-
if (isPaginationType$1(getSchemaType({ schema: property }))) return name
|
|
6147
|
+
if (isPaginationType$1(getSchemaType({ schema: property }))) return name;
|
|
6154
6148
|
}
|
|
6155
6149
|
}
|
|
6156
6150
|
for (const allOf of schema.allOf ?? []) {
|
|
@@ -6172,17 +6166,17 @@ const parseOperationJsDoc$1 = ({ irOperation, operation }) => {
|
|
|
6172
6166
|
if (operation.summary) irOperation.summary = operation.summary;
|
|
6173
6167
|
if (operation.tags?.length) irOperation.tags = operation.tags;
|
|
6174
6168
|
};
|
|
6175
|
-
const initIrOperation$1 = ({ context, method, operation, path
|
|
6169
|
+
const initIrOperation$1 = ({ context, method, operation, path, state }) => {
|
|
6176
6170
|
const irOperation = {
|
|
6177
6171
|
id: operationToId({
|
|
6178
6172
|
context,
|
|
6179
6173
|
id: operation.operationId,
|
|
6180
6174
|
method,
|
|
6181
|
-
path
|
|
6175
|
+
path,
|
|
6182
6176
|
state
|
|
6183
6177
|
}),
|
|
6184
6178
|
method,
|
|
6185
|
-
path
|
|
6179
|
+
path
|
|
6186
6180
|
};
|
|
6187
6181
|
if (operation.operationId) irOperation.operationId = operation.operationId;
|
|
6188
6182
|
parseOperationJsDoc$1({
|
|
@@ -6195,19 +6189,19 @@ const initIrOperation$1 = ({ context, method, operation, path: path$1, state })
|
|
|
6195
6189
|
});
|
|
6196
6190
|
return irOperation;
|
|
6197
6191
|
};
|
|
6198
|
-
const operationToIrOperation$1 = ({ context, method, operation, path
|
|
6192
|
+
const operationToIrOperation$1 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
6199
6193
|
const irOperation = initIrOperation$1({
|
|
6200
6194
|
context,
|
|
6201
6195
|
method,
|
|
6202
6196
|
operation,
|
|
6203
|
-
path
|
|
6197
|
+
path,
|
|
6204
6198
|
state
|
|
6205
6199
|
});
|
|
6206
6200
|
if (operation.parameters) irOperation.parameters = operation.parameters;
|
|
6207
6201
|
if (operation.requestBody) {
|
|
6208
6202
|
const requestBody = "$ref" in operation.requestBody ? context.resolveRef(operation.requestBody.$ref) : operation.requestBody;
|
|
6209
6203
|
const contents = mediaTypeObjects$1({ content: requestBody.content });
|
|
6210
|
-
const content = contents.find((content
|
|
6204
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6211
6205
|
if (content) {
|
|
6212
6206
|
const pagination = paginationField$1({
|
|
6213
6207
|
context,
|
|
@@ -6248,7 +6242,7 @@ const operationToIrOperation$1 = ({ context, method, operation, path: path$1, se
|
|
|
6248
6242
|
const response = operation.responses[name];
|
|
6249
6243
|
const responseObject = "$ref" in response ? context.resolveRef(response.$ref) : response;
|
|
6250
6244
|
const contents = mediaTypeObjects$1({ content: responseObject.content });
|
|
6251
|
-
const content = contents.find((content
|
|
6245
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6252
6246
|
if (content) irOperation.responses[name] = {
|
|
6253
6247
|
mediaType: content.mediaType,
|
|
6254
6248
|
schema: schemaToIrSchema$1({
|
|
@@ -6276,15 +6270,15 @@ const operationToIrOperation$1 = ({ context, method, operation, path: path$1, se
|
|
|
6276
6270
|
}
|
|
6277
6271
|
return irOperation;
|
|
6278
6272
|
};
|
|
6279
|
-
const parsePathOperation$1 = ({ context, method, operation, path
|
|
6273
|
+
const parsePathOperation$1 = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
6280
6274
|
if (!context.ir.paths) context.ir.paths = {};
|
|
6281
|
-
if (!context.ir.paths[path
|
|
6275
|
+
if (!context.ir.paths[path]) context.ir.paths[path] = {};
|
|
6282
6276
|
if (operation.servers) context.ir.servers = [...context.ir.servers ?? [], ...operation.servers];
|
|
6283
|
-
context.ir.paths[path
|
|
6277
|
+
context.ir.paths[path][method] = operationToIrOperation$1({
|
|
6284
6278
|
context,
|
|
6285
6279
|
method,
|
|
6286
6280
|
operation,
|
|
6287
|
-
path
|
|
6281
|
+
path,
|
|
6288
6282
|
securitySchemesMap,
|
|
6289
6283
|
state
|
|
6290
6284
|
});
|
|
@@ -6340,7 +6334,7 @@ const parameterToIrParameter$1 = ({ $ref, context, parameter }) => {
|
|
|
6340
6334
|
let schema = parameter.schema;
|
|
6341
6335
|
if (!schema) {
|
|
6342
6336
|
const contents = mediaTypeObjects$1({ content: parameter.content });
|
|
6343
|
-
const content = contents.find((content
|
|
6337
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6344
6338
|
if (content) schema = content.schema;
|
|
6345
6339
|
}
|
|
6346
6340
|
const finalSchema = schema && "$ref" in schema ? {
|
|
@@ -6398,7 +6392,7 @@ const parseParameter$1 = ({ $ref, context, parameter }) => {
|
|
|
6398
6392
|
//#region src/openApi/3.0.x/parser/requestBody.ts
|
|
6399
6393
|
const requestBodyToIrRequestBody$1 = ({ $ref, context, requestBody }) => {
|
|
6400
6394
|
const contents = mediaTypeObjects$1({ content: requestBody.content });
|
|
6401
|
-
const content = contents.find((content
|
|
6395
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
6402
6396
|
const schema = content ? content.schema : void 0;
|
|
6403
6397
|
const irRequestBody = { schema: schemaToIrSchema$1({
|
|
6404
6398
|
context,
|
|
@@ -6446,14 +6440,14 @@ const validateOpenApiSpec$1 = (spec, logger) => {
|
|
|
6446
6440
|
const issues = [];
|
|
6447
6441
|
const operationIds = /* @__PURE__ */ new Map();
|
|
6448
6442
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
6449
|
-
const path
|
|
6443
|
+
const path = entry[0];
|
|
6450
6444
|
const pathItem = entry[1];
|
|
6451
6445
|
for (const method of httpMethods) {
|
|
6452
6446
|
const operation = pathItem[method];
|
|
6453
6447
|
if (!operation) continue;
|
|
6454
6448
|
const operationKey = createOperationKey({
|
|
6455
6449
|
method,
|
|
6456
|
-
path
|
|
6450
|
+
path
|
|
6457
6451
|
});
|
|
6458
6452
|
if (operation.operationId) if (!operationIds.has(operation.operationId)) operationIds.set(operation.operationId, operationKey);
|
|
6459
6453
|
else issues.push({
|
|
@@ -6465,7 +6459,7 @@ const validateOpenApiSpec$1 = (spec, logger) => {
|
|
|
6465
6459
|
message: "Duplicate `operationId` found. Each `operationId` must be unique.",
|
|
6466
6460
|
path: [
|
|
6467
6461
|
"paths",
|
|
6468
|
-
path
|
|
6462
|
+
path,
|
|
6469
6463
|
method,
|
|
6470
6464
|
"operationId"
|
|
6471
6465
|
],
|
|
@@ -6517,8 +6511,8 @@ const parseV3_0_X = (context) => {
|
|
|
6517
6511
|
});
|
|
6518
6512
|
if (hasFilters(context.config.parser.filters)) {
|
|
6519
6513
|
const filters = createFilters(context.config.parser.filters, context.spec, context.logger);
|
|
6520
|
-
const { graph
|
|
6521
|
-
const { resourceMetadata } = buildResourceMetadata(graph
|
|
6514
|
+
const { graph } = buildGraph(context.spec, context.logger);
|
|
6515
|
+
const { resourceMetadata } = buildResourceMetadata(graph, context.logger);
|
|
6522
6516
|
filterSpec$1({
|
|
6523
6517
|
...createFilteredDependencies({
|
|
6524
6518
|
filters,
|
|
@@ -6568,9 +6562,9 @@ const parseV3_0_X = (context) => {
|
|
|
6568
6562
|
}
|
|
6569
6563
|
}
|
|
6570
6564
|
parseServers$1({ context });
|
|
6571
|
-
for (const path
|
|
6572
|
-
if (path
|
|
6573
|
-
const pathItem = context.spec.paths[path
|
|
6565
|
+
for (const path in context.spec.paths) {
|
|
6566
|
+
if (path.startsWith("x-")) continue;
|
|
6567
|
+
const pathItem = context.spec.paths[path];
|
|
6574
6568
|
const finalPathItem = pathItem.$ref ? {
|
|
6575
6569
|
...context.resolveRef(pathItem.$ref),
|
|
6576
6570
|
...pathItem
|
|
@@ -6587,7 +6581,7 @@ const parseV3_0_X = (context) => {
|
|
|
6587
6581
|
servers: finalPathItem.servers,
|
|
6588
6582
|
summary: finalPathItem.summary
|
|
6589
6583
|
},
|
|
6590
|
-
path
|
|
6584
|
+
path,
|
|
6591
6585
|
securitySchemesMap,
|
|
6592
6586
|
state
|
|
6593
6587
|
};
|
|
@@ -6768,17 +6762,17 @@ const filterSpec = ({ logger, operations, parameters, preserveOrder, requestBodi
|
|
|
6768
6762
|
}
|
|
6769
6763
|
}
|
|
6770
6764
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
6771
|
-
const path
|
|
6765
|
+
const path = entry[0];
|
|
6772
6766
|
const pathItem = entry[1];
|
|
6773
6767
|
for (const method of httpMethods) {
|
|
6774
6768
|
if (!pathItem[method]) continue;
|
|
6775
6769
|
const key = addNamespace("operation", createOperationKey({
|
|
6776
6770
|
method,
|
|
6777
|
-
path
|
|
6771
|
+
path
|
|
6778
6772
|
}));
|
|
6779
6773
|
if (!operations.has(key)) delete pathItem[method];
|
|
6780
6774
|
}
|
|
6781
|
-
if (!Object.keys(pathItem).length) delete spec.paths[path
|
|
6775
|
+
if (!Object.keys(pathItem).length) delete spec.paths[path];
|
|
6782
6776
|
}
|
|
6783
6777
|
eventFilterSpec.timeEnd();
|
|
6784
6778
|
};
|
|
@@ -7042,11 +7036,11 @@ const parseAllOf = ({ context, schema, state }) => {
|
|
|
7042
7036
|
else irCompositionSchema.required = schema.required;
|
|
7043
7037
|
schemaItems.push(irCompositionSchema);
|
|
7044
7038
|
if (compositionSchema.$ref) {
|
|
7045
|
-
const ref
|
|
7039
|
+
const ref = context.resolveRef(compositionSchema.$ref);
|
|
7046
7040
|
if (state.$ref) {
|
|
7047
7041
|
const discriminators = findDiscriminatorsInSchema({
|
|
7048
7042
|
context,
|
|
7049
|
-
schema: ref
|
|
7043
|
+
schema: ref
|
|
7050
7044
|
});
|
|
7051
7045
|
for (const { discriminator, oneOf } of discriminators) {
|
|
7052
7046
|
const values = discriminatorValues(state.$ref, discriminator.mapping, oneOf ? () => oneOf.some((o) => "$ref" in o && o.$ref === state.$ref) : void 0);
|
|
@@ -7055,7 +7049,7 @@ const parseAllOf = ({ context, schema, state }) => {
|
|
|
7055
7049
|
const existingIndex = discriminatorsToAdd.findIndex((d) => d.discriminator.propertyName === discriminator.propertyName);
|
|
7056
7050
|
if (existingIndex !== -1) if (isExplicitMapping && !discriminatorsToAdd[existingIndex].isExplicitMapping) discriminatorsToAdd.splice(existingIndex, 1);
|
|
7057
7051
|
else continue;
|
|
7058
|
-
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref
|
|
7052
|
+
const isRequired = discriminators.some((d) => d.discriminator.propertyName === discriminator.propertyName && (ref.required?.includes(d.discriminator.propertyName) || ref.allOf && ref.allOf.some((item) => {
|
|
7059
7053
|
return (item.$ref ? context.resolveRef(item.$ref) : item).required?.includes(d.discriminator.propertyName);
|
|
7060
7054
|
})));
|
|
7061
7055
|
discriminatorsToAdd.push({
|
|
@@ -7324,13 +7318,13 @@ const parseRef = ({ context, schema, state }) => {
|
|
|
7324
7318
|
const refSchema = context.resolveRef(schema.$ref);
|
|
7325
7319
|
const originalRef = state.$ref;
|
|
7326
7320
|
state.$ref = schema.$ref;
|
|
7327
|
-
const irSchema
|
|
7321
|
+
const irSchema = schemaToIrSchema({
|
|
7328
7322
|
context,
|
|
7329
7323
|
schema: refSchema,
|
|
7330
7324
|
state
|
|
7331
7325
|
});
|
|
7332
7326
|
state.$ref = originalRef;
|
|
7333
|
-
return irSchema
|
|
7327
|
+
return irSchema;
|
|
7334
7328
|
}
|
|
7335
7329
|
}
|
|
7336
7330
|
let irSchema = initIrSchema({ schema });
|
|
@@ -7540,13 +7534,13 @@ const isPaginationType = (schemaTypes) => schemaTypes.includes("boolean") || sch
|
|
|
7540
7534
|
const paginationField = ({ context, name, schema }) => {
|
|
7541
7535
|
if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) return true;
|
|
7542
7536
|
if (schema.$ref) {
|
|
7543
|
-
const ref
|
|
7544
|
-
if ("content" in ref
|
|
7537
|
+
const ref = context.resolveRef(schema.$ref);
|
|
7538
|
+
if ("content" in ref || "in" in ref) {
|
|
7545
7539
|
let refSchema;
|
|
7546
|
-
if ("in" in ref
|
|
7540
|
+
if ("in" in ref) refSchema = ref.schema;
|
|
7547
7541
|
if (!refSchema) {
|
|
7548
|
-
const contents = mediaTypeObjects({ content: ref
|
|
7549
|
-
const content = contents.find((content
|
|
7542
|
+
const contents = mediaTypeObjects({ content: ref.content });
|
|
7543
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7550
7544
|
if (content?.schema) refSchema = content.schema;
|
|
7551
7545
|
}
|
|
7552
7546
|
if (!refSchema) return false;
|
|
@@ -7559,20 +7553,20 @@ const paginationField = ({ context, name, schema }) => {
|
|
|
7559
7553
|
return paginationField({
|
|
7560
7554
|
context,
|
|
7561
7555
|
name,
|
|
7562
|
-
schema: ref
|
|
7556
|
+
schema: ref
|
|
7563
7557
|
});
|
|
7564
7558
|
}
|
|
7565
|
-
for (const name
|
|
7566
|
-
const property = schema.properties[name
|
|
7559
|
+
for (const name in schema.properties) if (getPaginationKeywordsRegExp(context.config.parser.pagination).test(name)) {
|
|
7560
|
+
const property = schema.properties[name];
|
|
7567
7561
|
if (typeof property !== "boolean") {
|
|
7568
7562
|
const schemaTypes = getSchemaTypes({ schema: property });
|
|
7569
7563
|
if (!schemaTypes.length) {
|
|
7570
|
-
const nonNullCompositionSchemas = (property.anyOf ?? property.oneOf ?? []).filter((schema
|
|
7564
|
+
const nonNullCompositionSchemas = (property.anyOf ?? property.oneOf ?? []).filter((schema) => schema.type !== "null");
|
|
7571
7565
|
if (nonNullCompositionSchemas.length === 1) {
|
|
7572
|
-
if (isPaginationType(getSchemaTypes({ schema: nonNullCompositionSchemas[0] }))) return name
|
|
7566
|
+
if (isPaginationType(getSchemaTypes({ schema: nonNullCompositionSchemas[0] }))) return name;
|
|
7573
7567
|
}
|
|
7574
7568
|
}
|
|
7575
|
-
if (isPaginationType(schemaTypes)) return name
|
|
7569
|
+
if (isPaginationType(schemaTypes)) return name;
|
|
7576
7570
|
}
|
|
7577
7571
|
}
|
|
7578
7572
|
for (const allOf of schema.allOf ?? []) {
|
|
@@ -7594,17 +7588,17 @@ const parseOperationJsDoc = ({ irOperation, operation }) => {
|
|
|
7594
7588
|
if (operation.summary) irOperation.summary = operation.summary;
|
|
7595
7589
|
if (operation.tags?.length) irOperation.tags = operation.tags;
|
|
7596
7590
|
};
|
|
7597
|
-
const initIrOperation = ({ context, method, operation, path
|
|
7591
|
+
const initIrOperation = ({ context, method, operation, path, state }) => {
|
|
7598
7592
|
const irOperation = {
|
|
7599
7593
|
id: operationToId({
|
|
7600
7594
|
context,
|
|
7601
7595
|
id: operation.operationId,
|
|
7602
7596
|
method,
|
|
7603
|
-
path
|
|
7597
|
+
path,
|
|
7604
7598
|
state
|
|
7605
7599
|
}),
|
|
7606
7600
|
method,
|
|
7607
|
-
path
|
|
7601
|
+
path
|
|
7608
7602
|
};
|
|
7609
7603
|
if (operation.operationId) irOperation.operationId = operation.operationId;
|
|
7610
7604
|
parseOperationJsDoc({
|
|
@@ -7617,19 +7611,19 @@ const initIrOperation = ({ context, method, operation, path: path$1, state }) =>
|
|
|
7617
7611
|
});
|
|
7618
7612
|
return irOperation;
|
|
7619
7613
|
};
|
|
7620
|
-
const operationToIrOperation = ({ context, method, operation, path
|
|
7614
|
+
const operationToIrOperation = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
7621
7615
|
const irOperation = initIrOperation({
|
|
7622
7616
|
context,
|
|
7623
7617
|
method,
|
|
7624
7618
|
operation,
|
|
7625
|
-
path
|
|
7619
|
+
path,
|
|
7626
7620
|
state
|
|
7627
7621
|
});
|
|
7628
7622
|
if (operation.parameters) irOperation.parameters = operation.parameters;
|
|
7629
7623
|
if (operation.requestBody) {
|
|
7630
7624
|
const requestBody = "$ref" in operation.requestBody ? context.resolveRef(operation.requestBody.$ref) : operation.requestBody;
|
|
7631
7625
|
const contents = mediaTypeObjects({ content: requestBody.content });
|
|
7632
|
-
const content = contents.find((content
|
|
7626
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7633
7627
|
if (content) {
|
|
7634
7628
|
const pagination = paginationField({
|
|
7635
7629
|
context,
|
|
@@ -7661,7 +7655,7 @@ const operationToIrOperation = ({ context, method, operation, path: path$1, secu
|
|
|
7661
7655
|
const response = operation.responses[name];
|
|
7662
7656
|
const responseObject = "$ref" in response ? context.resolveRef(response.$ref) : response;
|
|
7663
7657
|
const contents = mediaTypeObjects({ content: responseObject.content });
|
|
7664
|
-
const content = contents.find((content
|
|
7658
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7665
7659
|
if (content) irOperation.responses[name] = {
|
|
7666
7660
|
mediaType: content.mediaType,
|
|
7667
7661
|
schema: schemaToIrSchema({
|
|
@@ -7689,27 +7683,27 @@ const operationToIrOperation = ({ context, method, operation, path: path$1, secu
|
|
|
7689
7683
|
}
|
|
7690
7684
|
return irOperation;
|
|
7691
7685
|
};
|
|
7692
|
-
const parseOperationObject = ({ context, method, operation, path
|
|
7686
|
+
const parseOperationObject = ({ context, method, operation, path, securitySchemesMap, state }) => {
|
|
7693
7687
|
if (operation.servers) context.ir.servers = [...context.ir.servers ?? [], ...operation.servers];
|
|
7694
7688
|
return { parsed: operationToIrOperation({
|
|
7695
7689
|
context,
|
|
7696
7690
|
method,
|
|
7697
7691
|
operation,
|
|
7698
|
-
path
|
|
7692
|
+
path,
|
|
7699
7693
|
securitySchemesMap,
|
|
7700
7694
|
state
|
|
7701
7695
|
}) };
|
|
7702
7696
|
};
|
|
7703
|
-
const parsePathOperation = ({ context, method, path
|
|
7697
|
+
const parsePathOperation = ({ context, method, path, ...options }) => {
|
|
7704
7698
|
if (!context.ir.paths) context.ir.paths = {};
|
|
7705
|
-
if (!context.ir.paths[path
|
|
7699
|
+
if (!context.ir.paths[path]) context.ir.paths[path] = {};
|
|
7706
7700
|
const { parsed } = parseOperationObject({
|
|
7707
7701
|
context,
|
|
7708
7702
|
method,
|
|
7709
|
-
path
|
|
7703
|
+
path,
|
|
7710
7704
|
...options
|
|
7711
7705
|
});
|
|
7712
|
-
context.ir.paths[path
|
|
7706
|
+
context.ir.paths[path][method] = parsed;
|
|
7713
7707
|
};
|
|
7714
7708
|
const parseWebhookOperation = ({ context, key, method, ...options }) => {
|
|
7715
7709
|
if (!context.ir.webhooks) context.ir.webhooks = {};
|
|
@@ -7773,7 +7767,7 @@ const parameterToIrParameter = ({ $ref, context, parameter }) => {
|
|
|
7773
7767
|
let schema = parameter.schema;
|
|
7774
7768
|
if (!schema) {
|
|
7775
7769
|
const contents = mediaTypeObjects({ content: parameter.content });
|
|
7776
|
-
const content = contents.find((content
|
|
7770
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7777
7771
|
if (content) schema = content.schema;
|
|
7778
7772
|
}
|
|
7779
7773
|
const finalSchema = {
|
|
@@ -7827,7 +7821,7 @@ const parseParameter = ({ $ref, context, parameter }) => {
|
|
|
7827
7821
|
//#region src/openApi/3.1.x/parser/requestBody.ts
|
|
7828
7822
|
const requestBodyToIrRequestBody = ({ $ref, context, requestBody }) => {
|
|
7829
7823
|
const contents = mediaTypeObjects({ content: requestBody.content });
|
|
7830
|
-
const content = contents.find((content
|
|
7824
|
+
const content = contents.find((content) => content.type === "json") || contents[0];
|
|
7831
7825
|
const schema = content ? content.schema : void 0;
|
|
7832
7826
|
const irRequestBody = { schema: schemaToIrSchema({
|
|
7833
7827
|
context,
|
|
@@ -7875,14 +7869,14 @@ const validateOpenApiSpec = (spec, logger) => {
|
|
|
7875
7869
|
const issues = [];
|
|
7876
7870
|
const operationIds = /* @__PURE__ */ new Map();
|
|
7877
7871
|
if (spec.paths) for (const entry of Object.entries(spec.paths)) {
|
|
7878
|
-
const path
|
|
7872
|
+
const path = entry[0];
|
|
7879
7873
|
const pathItem = entry[1];
|
|
7880
7874
|
for (const method of httpMethods) {
|
|
7881
7875
|
const operation = pathItem[method];
|
|
7882
7876
|
if (!operation) continue;
|
|
7883
7877
|
const operationKey = createOperationKey({
|
|
7884
7878
|
method,
|
|
7885
|
-
path
|
|
7879
|
+
path
|
|
7886
7880
|
});
|
|
7887
7881
|
if (operation.operationId) if (!operationIds.has(operation.operationId)) operationIds.set(operation.operationId, operationKey);
|
|
7888
7882
|
else issues.push({
|
|
@@ -7894,7 +7888,7 @@ const validateOpenApiSpec = (spec, logger) => {
|
|
|
7894
7888
|
message: "Duplicate `operationId` found. Each `operationId` must be unique.",
|
|
7895
7889
|
path: [
|
|
7896
7890
|
"paths",
|
|
7897
|
-
path
|
|
7891
|
+
path,
|
|
7898
7892
|
method,
|
|
7899
7893
|
"operationId"
|
|
7900
7894
|
],
|
|
@@ -8095,8 +8089,8 @@ const parseV3_1_X = (context) => {
|
|
|
8095
8089
|
});
|
|
8096
8090
|
if (hasFilters(context.config.parser.filters)) {
|
|
8097
8091
|
const filters = createFilters(context.config.parser.filters, context.spec, context.logger);
|
|
8098
|
-
const { graph
|
|
8099
|
-
const { resourceMetadata } = buildResourceMetadata(graph
|
|
8092
|
+
const { graph } = buildGraph(context.spec, context.logger);
|
|
8093
|
+
const { resourceMetadata } = buildResourceMetadata(graph, context.logger);
|
|
8100
8094
|
filterSpec({
|
|
8101
8095
|
...createFilteredDependencies({
|
|
8102
8096
|
filters,
|
|
@@ -8146,9 +8140,9 @@ const parseV3_1_X = (context) => {
|
|
|
8146
8140
|
}
|
|
8147
8141
|
}
|
|
8148
8142
|
parseServers({ context });
|
|
8149
|
-
for (const path
|
|
8150
|
-
if (path
|
|
8151
|
-
const pathItem = context.spec.paths[path
|
|
8143
|
+
for (const path in context.spec.paths) {
|
|
8144
|
+
if (path.startsWith("x-")) continue;
|
|
8145
|
+
const pathItem = context.spec.paths[path];
|
|
8152
8146
|
const finalPathItem = pathItem.$ref ? {
|
|
8153
8147
|
...context.resolveRef(pathItem.$ref),
|
|
8154
8148
|
...pathItem
|
|
@@ -8165,7 +8159,7 @@ const parseV3_1_X = (context) => {
|
|
|
8165
8159
|
servers: finalPathItem.servers,
|
|
8166
8160
|
summary: finalPathItem.summary
|
|
8167
8161
|
},
|
|
8168
|
-
path
|
|
8162
|
+
path,
|
|
8169
8163
|
securitySchemesMap,
|
|
8170
8164
|
state
|
|
8171
8165
|
};
|
|
@@ -8388,7 +8382,7 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8388
8382
|
const patchFn = patchOptions.schemas[key];
|
|
8389
8383
|
await patchFn(schema);
|
|
8390
8384
|
}
|
|
8391
|
-
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path
|
|
8385
|
+
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
8392
8386
|
if (!pathItem || typeof pathItem !== "object") continue;
|
|
8393
8387
|
for (const method of [
|
|
8394
8388
|
"get",
|
|
@@ -8402,13 +8396,13 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8402
8396
|
]) {
|
|
8403
8397
|
const operation = pathItem[method];
|
|
8404
8398
|
if (!operation || typeof operation !== "object") continue;
|
|
8405
|
-
await patchOptions.operations(method, path
|
|
8399
|
+
await patchOptions.operations(method, path, operation);
|
|
8406
8400
|
}
|
|
8407
8401
|
}
|
|
8408
8402
|
else for (const key in patchOptions.operations) {
|
|
8409
|
-
const [method, path
|
|
8410
|
-
if (!method || !path
|
|
8411
|
-
const pathItem = spec.paths[path
|
|
8403
|
+
const [method, path] = key.split(" ");
|
|
8404
|
+
if (!method || !path) continue;
|
|
8405
|
+
const pathItem = spec.paths[path];
|
|
8412
8406
|
if (!pathItem) continue;
|
|
8413
8407
|
const operation = pathItem[method.toLocaleLowerCase()] || pathItem[method.toLocaleUpperCase()];
|
|
8414
8408
|
if (!operation || typeof operation !== "object") continue;
|
|
@@ -8447,7 +8441,7 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8447
8441
|
patchFn(schema);
|
|
8448
8442
|
}
|
|
8449
8443
|
}
|
|
8450
|
-
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path
|
|
8444
|
+
if (patchOptions.operations && spec.paths) if (typeof patchOptions.operations === "function") for (const [path, pathItem] of Object.entries(spec.paths)) {
|
|
8451
8445
|
if (!pathItem || typeof pathItem !== "object") continue;
|
|
8452
8446
|
for (const method of [
|
|
8453
8447
|
"get",
|
|
@@ -8461,13 +8455,13 @@ async function patchOpenApiSpec({ patchOptions, spec: _spec }) {
|
|
|
8461
8455
|
]) {
|
|
8462
8456
|
const operation = pathItem[method];
|
|
8463
8457
|
if (!operation || typeof operation !== "object") continue;
|
|
8464
|
-
await patchOptions.operations(method, path
|
|
8458
|
+
await patchOptions.operations(method, path, operation);
|
|
8465
8459
|
}
|
|
8466
8460
|
}
|
|
8467
8461
|
else for (const key in patchOptions.operations) {
|
|
8468
|
-
const [method, path
|
|
8469
|
-
if (!method || !path
|
|
8470
|
-
const pathItem = spec.paths[path
|
|
8462
|
+
const [method, path] = key.split(" ");
|
|
8463
|
+
if (!method || !path) continue;
|
|
8464
|
+
const pathItem = spec.paths[path];
|
|
8471
8465
|
if (!pathItem) continue;
|
|
8472
8466
|
const operation = pathItem[method.toLocaleLowerCase()] || pathItem[method.toLocaleUpperCase()];
|
|
8473
8467
|
if (!operation || typeof operation !== "object") continue;
|
|
@@ -8494,6 +8488,33 @@ const mappers = {
|
|
|
8494
8488
|
string: (name) => ({ name })
|
|
8495
8489
|
};
|
|
8496
8490
|
|
|
8491
|
+
//#endregion
|
|
8492
|
+
//#region src/plugins/symbol.ts
|
|
8493
|
+
/**
|
|
8494
|
+
* Helper function to build the input for symbol registration, applying naming hooks if provided.
|
|
8495
|
+
*/
|
|
8496
|
+
function buildSymbolIn({ plugin, ...ctx }) {
|
|
8497
|
+
const hooks = [plugin.config["~hooks"]?.symbols?.getName, plugin.context.config.parser.hooks.symbols?.getName];
|
|
8498
|
+
for (const hook of hooks) {
|
|
8499
|
+
if (!hook) continue;
|
|
8500
|
+
const result = hook(ctx);
|
|
8501
|
+
if (typeof result === "function") {
|
|
8502
|
+
const name = result(ctx);
|
|
8503
|
+
if (name) return {
|
|
8504
|
+
meta: ctx.meta,
|
|
8505
|
+
name
|
|
8506
|
+
};
|
|
8507
|
+
} else if (typeof result === "string") return {
|
|
8508
|
+
meta: ctx.meta,
|
|
8509
|
+
name: ctx.naming ? applyNaming(result, ctx.naming) : result
|
|
8510
|
+
};
|
|
8511
|
+
}
|
|
8512
|
+
return {
|
|
8513
|
+
meta: ctx.meta,
|
|
8514
|
+
name: ctx.naming ? applyNaming(ctx.name, ctx.naming) : ctx.name
|
|
8515
|
+
};
|
|
8516
|
+
}
|
|
8517
|
+
|
|
8497
8518
|
//#endregion
|
|
8498
8519
|
//#region src/utils/escape.ts
|
|
8499
8520
|
function escapeComment(value) {
|
|
@@ -8517,9 +8538,14 @@ const utils = {
|
|
|
8517
8538
|
/**
|
|
8518
8539
|
* Converts an {@link OutputHeader} value to a string prefix for file content.
|
|
8519
8540
|
*/
|
|
8520
|
-
function outputHeaderToPrefix(
|
|
8521
|
-
|
|
8522
|
-
|
|
8541
|
+
function outputHeaderToPrefix(ctx) {
|
|
8542
|
+
const { defaultValue, header, project } = ctx;
|
|
8543
|
+
let lines = typeof header === "function" ? header({
|
|
8544
|
+
defaultValue,
|
|
8545
|
+
project
|
|
8546
|
+
}) : header;
|
|
8547
|
+
if (lines === void 0) lines = defaultValue;
|
|
8548
|
+
if (lines === null) return "";
|
|
8523
8549
|
lines = typeof lines === "string" ? lines.split(/\r?\n/) : lines.flatMap((line) => line.split(/\r?\n/));
|
|
8524
8550
|
const content = lines.join("\n");
|
|
8525
8551
|
return content ? `${content}\n\n` : "";
|
|
@@ -8593,35 +8619,35 @@ function sanitizeSegment(segment) {
|
|
|
8593
8619
|
* paths//event/get/properties/query, { anchor: 'event.subscribe' }
|
|
8594
8620
|
* → 'event.subscribe-Query'
|
|
8595
8621
|
*/
|
|
8596
|
-
function pathToName(path
|
|
8622
|
+
function pathToName(path, options) {
|
|
8597
8623
|
const names = [];
|
|
8598
8624
|
let index = 0;
|
|
8599
|
-
const rootContext = ROOT_CONTEXT[path
|
|
8625
|
+
const rootContext = ROOT_CONTEXT[path[0]];
|
|
8600
8626
|
if (rootContext) {
|
|
8601
8627
|
index = rootContext.skip;
|
|
8602
8628
|
if (options?.anchor) {
|
|
8603
8629
|
names.push(options.anchor);
|
|
8604
8630
|
index += rootContext.names;
|
|
8605
|
-
} else for (let n = 0; n < rootContext.names && index < path
|
|
8606
|
-
names.push(sanitizeSegment(path
|
|
8631
|
+
} else for (let n = 0; n < rootContext.names && index < path.length; n++) {
|
|
8632
|
+
names.push(sanitizeSegment(path[index]));
|
|
8607
8633
|
index++;
|
|
8608
8634
|
}
|
|
8609
8635
|
} else if (options?.anchor) {
|
|
8610
8636
|
names.push(options.anchor);
|
|
8611
8637
|
index++;
|
|
8612
|
-
} else if (index < path
|
|
8613
|
-
names.push(sanitizeSegment(path
|
|
8638
|
+
} else if (index < path.length) {
|
|
8639
|
+
names.push(sanitizeSegment(path[index]));
|
|
8614
8640
|
index++;
|
|
8615
8641
|
}
|
|
8616
|
-
while (index < path
|
|
8617
|
-
const segment = String(path
|
|
8642
|
+
while (index < path.length) {
|
|
8643
|
+
const segment = String(path[index]);
|
|
8618
8644
|
const role = STRUCTURAL_ROLE[segment];
|
|
8619
8645
|
if (role === "name") {
|
|
8620
8646
|
index++;
|
|
8621
|
-
if (index < path
|
|
8647
|
+
if (index < path.length) names.push(sanitizeSegment(path[index]));
|
|
8622
8648
|
} else if (role === "index") {
|
|
8623
8649
|
index++;
|
|
8624
|
-
if (index < path
|
|
8650
|
+
if (index < path.length && typeof path[index] === "number") index++;
|
|
8625
8651
|
continue;
|
|
8626
8652
|
} else if (STRUCTURAL_SUFFIX[segment]) names.push(STRUCTURAL_SUFFIX[segment]);
|
|
8627
8653
|
index++;
|
|
@@ -8630,5 +8656,5 @@ function pathToName(path$1, options) {
|
|
|
8630
8656
|
}
|
|
8631
8657
|
|
|
8632
8658
|
//#endregion
|
|
8633
|
-
export { ConfigError, ConfigValidationError, Context, HeyApiError, IntentContext, JobError, MinHeap, OperationPath, OperationStrategy, PluginInstance, addItemsToSchema, applyNaming, buildGraph, 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, isTopLevelComponent, jsonPointerToPath, loadPackageJson,
|
|
8659
|
+
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 };
|
|
8634
8660
|
//# sourceMappingURL=index.mjs.map
|