zudoku 0.40.0 → 0.41.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/app/main.js +7 -4
- package/dist/app/main.js.map +1 -1
- package/dist/cli/cli.js +12 -1
- package/dist/cli/cli.js.map +1 -1
- package/dist/cli/common/machine-id/lib.js +1 -0
- package/dist/cli/common/machine-id/lib.js.map +1 -1
- package/dist/config/ZuploBuildConfig.d.ts +155 -0
- package/dist/config/ZuploBuildConfig.js +29 -0
- package/dist/config/ZuploBuildConfig.js.map +1 -0
- package/dist/config/loader.js +0 -3
- package/dist/config/loader.js.map +1 -1
- package/dist/config/validators/BuildSchema.d.ts +1 -0
- package/dist/config/validators/BuildSchema.js.map +1 -1
- package/dist/config/validators/common.d.ts +17 -11
- package/dist/config/validators/common.js +1 -1
- package/dist/config/validators/common.js.map +1 -1
- package/dist/config/validators/validate.d.ts +7 -5
- package/dist/lib/authentication/providers/openid.d.ts +3 -1
- package/dist/lib/authentication/providers/openid.js +17 -11
- package/dist/lib/authentication/providers/openid.js.map +1 -1
- package/dist/lib/components/BuildCheck.d.ts +4 -0
- package/dist/lib/components/BuildCheck.js +22 -0
- package/dist/lib/components/BuildCheck.js.map +1 -0
- package/dist/lib/components/Zudoku.js +1 -3
- package/dist/lib/components/Zudoku.js.map +1 -1
- package/dist/lib/components/context/ViewportAnchorContext.js +8 -9
- package/dist/lib/components/context/ViewportAnchorContext.js.map +1 -1
- package/dist/lib/components/index.d.ts +4 -0
- package/dist/lib/components/index.js +2 -0
- package/dist/lib/components/index.js.map +1 -1
- package/dist/lib/components/navigation/PoweredByZudoku.js +2 -1
- package/dist/lib/components/navigation/PoweredByZudoku.js.map +1 -1
- package/dist/lib/components/navigation/ZuploLogo.d.ts +3 -0
- package/dist/lib/components/navigation/ZuploLogo.js +4 -0
- package/dist/lib/components/navigation/ZuploLogo.js.map +1 -0
- package/dist/lib/oas/parser/index.d.ts +1 -1
- package/dist/lib/oas/parser/index.js +3 -2
- package/dist/lib/oas/parser/index.js.map +1 -1
- package/dist/lib/plugins/openapi/OperationList.d.ts +1 -1
- package/dist/lib/plugins/openapi/OperationList.js +6 -4
- package/dist/lib/plugins/openapi/OperationList.js.map +1 -1
- package/dist/lib/plugins/openapi/processors/removeExtensions.d.ts +3 -2
- package/dist/lib/plugins/openapi/processors/removeExtensions.js +1 -1
- package/dist/lib/plugins/openapi/processors/removeExtensions.js.map +1 -1
- package/dist/lib/plugins/openapi/processors/removeExtensions.test.js +26 -6
- package/dist/lib/plugins/openapi/processors/removeExtensions.test.js.map +1 -1
- package/dist/lib/plugins/openapi/processors/removeParameters.d.ts +3 -1
- package/dist/lib/plugins/openapi/processors/removeParameters.js +1 -1
- package/dist/lib/plugins/openapi/processors/removeParameters.js.map +1 -1
- package/dist/lib/plugins/openapi/processors/removeParameters.test.js +53 -25
- package/dist/lib/plugins/openapi/processors/removeParameters.test.js.map +1 -1
- package/dist/lib/plugins/openapi/processors/removePaths.d.ts +3 -1
- package/dist/lib/plugins/openapi/processors/removePaths.js +1 -1
- package/dist/lib/plugins/openapi/processors/removePaths.js.map +1 -1
- package/dist/lib/plugins/openapi/processors/removePaths.test.js +75 -35
- package/dist/lib/plugins/openapi/processors/removePaths.test.js.map +1 -1
- package/dist/lib/plugins/openapi/util/getRoutes.js +20 -13
- package/dist/lib/plugins/openapi/util/getRoutes.js.map +1 -1
- package/dist/lib/util/ensureArray.d.ts +1 -0
- package/dist/lib/util/ensureArray.js +2 -0
- package/dist/lib/util/ensureArray.js.map +1 -0
- package/dist/vite/api/SchemaManager.d.ts +36 -0
- package/dist/vite/api/SchemaManager.js +120 -0
- package/dist/vite/api/SchemaManager.js.map +1 -0
- package/dist/vite/api/SchemaManager.test.d.ts +1 -0
- package/dist/vite/api/SchemaManager.test.js +106 -0
- package/dist/vite/api/SchemaManager.test.js.map +1 -0
- package/dist/vite/config.js +5 -1
- package/dist/vite/config.js.map +1 -1
- package/dist/vite/plugin-api.js +39 -117
- package/dist/vite/plugin-api.js.map +1 -1
- package/dist/vite/plugin-sidebar.d.ts +3 -1
- package/dist/vite/plugin-sidebar.js +8 -2
- package/dist/vite/plugin-sidebar.js.map +1 -1
- package/dist/zuplo/enrich-with-zuplo.d.ts +3 -3
- package/dist/zuplo/enrich-with-zuplo.js +18 -17
- package/dist/zuplo/enrich-with-zuplo.js.map +1 -1
- package/dist/zuplo/env.d.ts +26 -0
- package/dist/zuplo/env.js +17 -0
- package/dist/zuplo/env.js.map +1 -1
- package/dist/zuplo/with-zuplo-processors.d.ts +2 -2
- package/dist/zuplo/with-zuplo-processors.js +3 -3
- package/dist/zuplo/with-zuplo-processors.js.map +1 -1
- package/dist/zuplo/with-zuplo.d.ts +3 -0
- package/dist/zuplo/with-zuplo.js +6 -9
- package/dist/zuplo/with-zuplo.js.map +1 -1
- package/lib/{Markdown-C5h6bxbE.js → Markdown-DqDbGCj2.js} +314 -315
- package/lib/{Markdown-C5h6bxbE.js.map → Markdown-DqDbGCj2.js.map} +1 -1
- package/lib/{MdxPage-B66ht0D_.js → MdxPage-DGVqOhzg.js} +5 -5
- package/lib/{MdxPage-B66ht0D_.js.map → MdxPage-DGVqOhzg.js.map} +1 -1
- package/lib/{OasProvider-BKPF0Pbt.js → OasProvider-qeJNCq-h.js} +2 -2
- package/lib/{OasProvider-BKPF0Pbt.js.map → OasProvider-qeJNCq-h.js.map} +1 -1
- package/lib/{OperationList-0bhBU7ME.js → OperationList-CBpQALZd.js} +798 -794
- package/lib/{OperationList-0bhBU7ME.js.map → OperationList-CBpQALZd.js.map} +1 -1
- package/lib/{Pagination-Bt1czAiJ.js → Pagination-PfYTF0cF.js} +2 -2
- package/lib/{Pagination-Bt1czAiJ.js.map → Pagination-PfYTF0cF.js.map} +1 -1
- package/lib/{SchemaList-CsTIT1pi.js → SchemaList-BIzyXPnY.js} +5 -5
- package/lib/{SchemaList-CsTIT1pi.js.map → SchemaList-BIzyXPnY.js.map} +1 -1
- package/lib/{SchemaView-DCSWtnYr.js → SchemaView-DwlVvFfp.js} +2 -2
- package/lib/{SchemaView-DCSWtnYr.js.map → SchemaView-DwlVvFfp.js.map} +1 -1
- package/lib/{SlotletProvider-VUmTNmLZ.js → SlotletProvider-p4XaFFOh.js} +2 -2
- package/lib/{SlotletProvider-VUmTNmLZ.js.map → SlotletProvider-p4XaFFOh.js.map} +1 -1
- package/lib/{Toc-BK39DQvI.js → Toc-BVdRaIC0.js} +2 -2
- package/lib/{Toc-BK39DQvI.js.map → Toc-BVdRaIC0.js.map} +1 -1
- package/lib/{createServer-DLN7APz_.js → createServer-D_5UkLtY.js} +1459 -1485
- package/lib/createServer-D_5UkLtY.js.map +1 -0
- package/lib/{index-tpbiZmWp.js → index-B7lRu87v.js} +686 -648
- package/lib/index-B7lRu87v.js.map +1 -0
- package/lib/index-BpThvE5R.js +66 -0
- package/lib/index-BpThvE5R.js.map +1 -0
- package/lib/{index-Ba_X7EnR.js → index-CxdJ8TBB.js} +255 -249
- package/lib/{index-Ba_X7EnR.js.map → index-CxdJ8TBB.js.map} +1 -1
- package/lib/index-ueM1dihS.js +247 -0
- package/lib/index-ueM1dihS.js.map +1 -0
- package/lib/processors/removeExtensions.js +1 -1
- package/lib/processors/removeExtensions.js.map +1 -1
- package/lib/processors/removeParameters.js +1 -1
- package/lib/processors/removeParameters.js.map +1 -1
- package/lib/processors/removePaths.js +1 -1
- package/lib/processors/removePaths.js.map +1 -1
- package/lib/{index-DcHeSvkE.js → public-api-CrAQFYc4.js} +651 -684
- package/lib/public-api-CrAQFYc4.js.map +1 -0
- package/lib/zudoku.auth-openid.js +144 -138
- package/lib/zudoku.auth-openid.js.map +1 -1
- package/lib/zudoku.components.js +23 -22
- package/lib/zudoku.plugin-api-catalog.js +2 -2
- package/lib/zudoku.plugin-api-keys.js +1 -1
- package/lib/zudoku.plugin-custom-pages.js +1 -1
- package/lib/zudoku.plugin-markdown.js +1 -1
- package/lib/zudoku.plugin-openapi.js +1 -1
- package/package.json +3 -3
- package/src/app/main.tsx +12 -1
- package/src/lib/authentication/providers/openid.tsx +23 -12
- package/src/lib/components/BuildCheck.tsx +60 -0
- package/src/lib/components/Zudoku.tsx +1 -3
- package/src/lib/components/context/ViewportAnchorContext.tsx +8 -15
- package/src/lib/components/index.ts +2 -0
- package/src/lib/components/navigation/PoweredByZudoku.tsx +8 -3
- package/src/lib/components/navigation/ZuploLogo.tsx +14 -0
- package/src/lib/oas/parser/index.ts +4 -2
- package/src/lib/plugins/openapi/OperationList.tsx +15 -3
- package/src/lib/plugins/openapi/processors/removeExtensions.test.ts +29 -9
- package/src/lib/plugins/openapi/processors/removeExtensions.ts +5 -3
- package/src/lib/plugins/openapi/processors/removeParameters.test.ts +67 -33
- package/src/lib/plugins/openapi/processors/removeParameters.ts +5 -3
- package/src/lib/plugins/openapi/processors/removePaths.test.ts +85 -44
- package/src/lib/plugins/openapi/processors/removePaths.ts +5 -3
- package/src/lib/plugins/openapi/util/getRoutes.tsx +21 -13
- package/src/lib/util/ensureArray.ts +3 -0
- package/client.d.ts +0 -8
- package/dist/lib/oas/parser/upgrade/index.d.ts +0 -9
- package/dist/lib/oas/parser/upgrade/index.js +0 -90
- package/dist/lib/oas/parser/upgrade/index.js.map +0 -1
- package/lib/createServer-DLN7APz_.js.map +0 -1
- package/lib/index-DcHeSvkE.js.map +0 -1
- package/lib/index-tpbiZmWp.js.map +0 -1
- package/src/lib/oas/parser/upgrade/index.ts +0 -103
|
@@ -0,0 +1,247 @@
|
|
|
1
|
+
import { q as h } from "./public-api-CrAQFYc4.js";
|
|
2
|
+
function j(n) {
|
|
3
|
+
return n == null ? void 0 : n.find((e) => e.isEntrypoint);
|
|
4
|
+
}
|
|
5
|
+
function p(n, e, t = []) {
|
|
6
|
+
const i = {};
|
|
7
|
+
for (const [f, s] of Object.entries(n)) {
|
|
8
|
+
const o = [...t, f];
|
|
9
|
+
Array.isArray(s) ? i[f] = s.map((c, r) => typeof c == "object" && !Array.isArray(c) && c !== null ? p(c, e, [...o, r.toString()]) : c) : typeof s == "object" && !Array.isArray(s) && s !== null ? i[f] = p(s, e, o) : i[f] = s;
|
|
10
|
+
}
|
|
11
|
+
return e(i, t);
|
|
12
|
+
}
|
|
13
|
+
function x(n) {
|
|
14
|
+
const e = [];
|
|
15
|
+
return !n || typeof n != "object" ? e : (p(n, (t) => (t.$ref && typeof t.$ref == "string" && !t.$ref.startsWith("#") && e.push(t.$ref.split("#")[0]), t)), [...new Set(e)]);
|
|
16
|
+
}
|
|
17
|
+
function b(n) {
|
|
18
|
+
return typeof n < "u" && Array.isArray(n) && n.length > 0 && n.some((e) => e.isEntrypoint === !0);
|
|
19
|
+
}
|
|
20
|
+
function O(n) {
|
|
21
|
+
if (n === null)
|
|
22
|
+
return {};
|
|
23
|
+
if (typeof n == "string") {
|
|
24
|
+
if (n.trim() === "")
|
|
25
|
+
return {};
|
|
26
|
+
try {
|
|
27
|
+
return JSON.parse(n);
|
|
28
|
+
} catch {
|
|
29
|
+
return h(n, {
|
|
30
|
+
maxAliasCount: 1e4
|
|
31
|
+
});
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
return b(n), n;
|
|
35
|
+
}
|
|
36
|
+
function q(n, e = {}) {
|
|
37
|
+
if (b(n))
|
|
38
|
+
return n;
|
|
39
|
+
const t = O(n);
|
|
40
|
+
return [
|
|
41
|
+
{
|
|
42
|
+
isEntrypoint: !0,
|
|
43
|
+
specification: t,
|
|
44
|
+
filename: null,
|
|
45
|
+
dir: "./",
|
|
46
|
+
references: x(t),
|
|
47
|
+
...e
|
|
48
|
+
}
|
|
49
|
+
];
|
|
50
|
+
}
|
|
51
|
+
function w(n) {
|
|
52
|
+
let e = n;
|
|
53
|
+
if (e !== null && typeof e.openapi == "string" && e.openapi.startsWith("3.0"))
|
|
54
|
+
e.openapi = "3.1.1";
|
|
55
|
+
else
|
|
56
|
+
return e;
|
|
57
|
+
return e = p(e, (t) => (t.type !== "undefined" && t.nullable === !0 && (t.type = [t.type, "null"], delete t.nullable), t)), e = p(e, (t) => (t.exclusiveMinimum === !0 ? (t.exclusiveMinimum = t.minimum, delete t.minimum) : t.exclusiveMinimum === !1 && delete t.exclusiveMinimum, t.exclusiveMaximum === !0 ? (t.exclusiveMaximum = t.maximum, delete t.maximum) : t.exclusiveMaximum === !1 && delete t.exclusiveMaximum, t)), e = p(e, (t, i) => (t.example !== void 0 && (P(i) ? t.examples = [t.example] : t.examples = {
|
|
58
|
+
default: {
|
|
59
|
+
value: t.example
|
|
60
|
+
}
|
|
61
|
+
}, delete t.example), t)), e = p(e, (t, i) => {
|
|
62
|
+
if (t.type === "object" && t.properties !== void 0 && i.slice(0, -1).some((o, c) => o === "content" && i[c + 1] === "multipart/form-data")) {
|
|
63
|
+
const o = Object.entries(t.properties);
|
|
64
|
+
for (const [c, r] of o)
|
|
65
|
+
typeof r == "object" && r.type === "string" && r.format === "binary" && (r.contentMediaType = "application/octet-stream", delete r.format);
|
|
66
|
+
}
|
|
67
|
+
return t;
|
|
68
|
+
}), e = p(e, (t, i) => i.includes("content") && i.includes("application/octet-stream") ? {} : t.type === "string" && t.format === "binary" ? {
|
|
69
|
+
type: "string",
|
|
70
|
+
contentMediaType: "application/octet-stream"
|
|
71
|
+
} : t), e = p(e, (t) => t.type === "string" && t.format === "base64" ? {
|
|
72
|
+
type: "string",
|
|
73
|
+
contentEncoding: "base64"
|
|
74
|
+
} : t), e = p(e, (t, i) => t.type === "string" && t.format === "byte" ? {
|
|
75
|
+
type: "string",
|
|
76
|
+
contentEncoding: "base64",
|
|
77
|
+
contentMediaType: i.slice(0, -1).find((o, c) => i[c - 1] === "content")
|
|
78
|
+
} : t), e;
|
|
79
|
+
}
|
|
80
|
+
function P(n) {
|
|
81
|
+
return [
|
|
82
|
+
["components", "schemas"],
|
|
83
|
+
"properties",
|
|
84
|
+
"items",
|
|
85
|
+
"allOf",
|
|
86
|
+
"anyOf",
|
|
87
|
+
"oneOf",
|
|
88
|
+
"not",
|
|
89
|
+
"additionalProperties"
|
|
90
|
+
].some((t) => Array.isArray(t) ? t.every((i, f) => n[f] === i) : n.includes(t)) || n.includes("schema") || n.some((t) => t.endsWith("Schema"));
|
|
91
|
+
}
|
|
92
|
+
function M(n) {
|
|
93
|
+
var t, i, f;
|
|
94
|
+
let e = n;
|
|
95
|
+
if (e !== null && typeof e.swagger == "string" && ((t = e.swagger) != null && t.startsWith("2.0")))
|
|
96
|
+
e.openapi = "3.0.4", delete e.swagger;
|
|
97
|
+
else
|
|
98
|
+
return e;
|
|
99
|
+
if (e.host) {
|
|
100
|
+
const s = Array.isArray(e.schemes) && ((i = e.schemes) != null && i.length) ? e.schemes : ["http"];
|
|
101
|
+
e.servers = s.map((o) => ({
|
|
102
|
+
url: `${o}://${e.host}${e.basePath ?? ""}`
|
|
103
|
+
})), delete e.basePath, delete e.schemes, delete e.host;
|
|
104
|
+
} else e.basePath && (e.servers = [{ url: e.basePath }], delete e.basePath);
|
|
105
|
+
if (e.definitions && (e.components = Object.assign({}, e.components, {
|
|
106
|
+
schemas: e.definitions
|
|
107
|
+
}), delete e.definitions, e = p(e, (s) => {
|
|
108
|
+
var o;
|
|
109
|
+
return (o = s.$ref) != null && o.startsWith("#/definitions/") && (s.$ref = s.$ref.replace(/^#\/definitions\//, "#/components/schemas/")), s;
|
|
110
|
+
})), e = p(e, (s) => (s.type === "file" && (s.type = "string", s.format = "binary"), s)), typeof e.paths == "object") {
|
|
111
|
+
for (const s in e.paths)
|
|
112
|
+
if (Object.hasOwn(e.paths, s)) {
|
|
113
|
+
const o = e.paths[s];
|
|
114
|
+
for (const c in o)
|
|
115
|
+
if (Object.hasOwn(o, c)) {
|
|
116
|
+
const r = o[c];
|
|
117
|
+
if (r.parameters) {
|
|
118
|
+
const l = structuredClone(r.parameters.find((u) => u.in === "body") ?? {});
|
|
119
|
+
if (l && Object.keys(l).length) {
|
|
120
|
+
delete l.name, delete l.in;
|
|
121
|
+
const u = e.consumes ?? r.consumes ?? ["application/json"];
|
|
122
|
+
typeof r.requestBody != "object" && (r.requestBody = {}), typeof r.requestBody.content != "object" && (r.requestBody.content = {});
|
|
123
|
+
const { schema: m, ...d } = l;
|
|
124
|
+
r.requestBody = {
|
|
125
|
+
...r.requestBody,
|
|
126
|
+
...d
|
|
127
|
+
};
|
|
128
|
+
for (const g of u)
|
|
129
|
+
r.requestBody.content[g] = {
|
|
130
|
+
schema: m
|
|
131
|
+
};
|
|
132
|
+
}
|
|
133
|
+
r.parameters = r.parameters.filter((u) => u.in !== "body"), delete r.consumes;
|
|
134
|
+
const a = r.parameters.filter((u) => u.in === "formData");
|
|
135
|
+
if (a.length > 0) {
|
|
136
|
+
typeof r.requestBody != "object" && (r.requestBody = {}), typeof r.requestBody.content != "object" && (r.requestBody.content = {}), r.requestBody.content["application/x-www-form-urlencoded"] = {
|
|
137
|
+
schema: {
|
|
138
|
+
type: "object",
|
|
139
|
+
properties: {},
|
|
140
|
+
required: []
|
|
141
|
+
// Initialize required array
|
|
142
|
+
}
|
|
143
|
+
};
|
|
144
|
+
for (const u of a)
|
|
145
|
+
r.requestBody.content["application/x-www-form-urlencoded"].schema.properties[u.name] = {
|
|
146
|
+
type: u.type,
|
|
147
|
+
description: u.description
|
|
148
|
+
}, u.required && r.requestBody.content["application/x-www-form-urlencoded"].schema.required.push(u.name);
|
|
149
|
+
r.parameters = r.parameters.filter((u) => u.in !== "formData");
|
|
150
|
+
}
|
|
151
|
+
r.parameters = r.parameters.map((u) => y(u));
|
|
152
|
+
}
|
|
153
|
+
if (r.responses) {
|
|
154
|
+
for (const l in r.responses)
|
|
155
|
+
if (Object.hasOwn(r.responses, l)) {
|
|
156
|
+
const a = r.responses[l];
|
|
157
|
+
if (a.headers && (a.headers = Object.entries(a.headers).reduce((u, [m, d]) => ({
|
|
158
|
+
[m]: y(d),
|
|
159
|
+
...u
|
|
160
|
+
}), {})), a.schema) {
|
|
161
|
+
const u = e.produces ?? r.produces ?? ["application/json"];
|
|
162
|
+
typeof a.content != "object" && (a.content = {});
|
|
163
|
+
for (const m of u)
|
|
164
|
+
a.content[m] = {
|
|
165
|
+
schema: a.schema
|
|
166
|
+
};
|
|
167
|
+
delete a.schema;
|
|
168
|
+
}
|
|
169
|
+
}
|
|
170
|
+
}
|
|
171
|
+
delete r.produces, ((f = r.parameters) == null ? void 0 : f.length) === 0 && delete r.parameters;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
if (e.securityDefinitions) {
|
|
176
|
+
typeof e.components != "object" && (e.components = {}), e.components = e.components, Object.assign(e.components, { securitySchemes: {} });
|
|
177
|
+
for (const [s, o] of Object.entries(e.securityDefinitions))
|
|
178
|
+
if (typeof o == "object")
|
|
179
|
+
if ("type" in o && o.type === "oauth2") {
|
|
180
|
+
const { flow: c, authorizationUrl: r, tokenUrl: l, scopes: a } = o;
|
|
181
|
+
Object.assign(e.components.securitySchemes, {
|
|
182
|
+
[s]: {
|
|
183
|
+
type: "oauth2",
|
|
184
|
+
flows: {
|
|
185
|
+
[c]: Object.assign({}, r && { authorizationUrl: r }, l && { tokenUrl: l }, a && { scopes: a })
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
});
|
|
189
|
+
} else "type" in o && o.type === "basic" ? Object.assign(e.components.securitySchemes, {
|
|
190
|
+
[s]: {
|
|
191
|
+
type: "http",
|
|
192
|
+
scheme: "basic"
|
|
193
|
+
}
|
|
194
|
+
}) : Object.assign(e.components.securitySchemes, {
|
|
195
|
+
[s]: o
|
|
196
|
+
});
|
|
197
|
+
delete e.securityDefinitions;
|
|
198
|
+
}
|
|
199
|
+
return e;
|
|
200
|
+
}
|
|
201
|
+
function B(n) {
|
|
202
|
+
return [
|
|
203
|
+
"type",
|
|
204
|
+
"format",
|
|
205
|
+
"items",
|
|
206
|
+
"maximum",
|
|
207
|
+
"exclusiveMaximum",
|
|
208
|
+
"minimum",
|
|
209
|
+
"exclusiveMinimum",
|
|
210
|
+
"maxLength",
|
|
211
|
+
"minLength",
|
|
212
|
+
"pattern",
|
|
213
|
+
"maxItems",
|
|
214
|
+
"minItems",
|
|
215
|
+
"uniqueItems",
|
|
216
|
+
"enum",
|
|
217
|
+
"multipleOf"
|
|
218
|
+
].reduce((t, i) => (Object.hasOwn(n, i) && (t[i] = n[i], delete n[i]), t), {});
|
|
219
|
+
}
|
|
220
|
+
function y(n) {
|
|
221
|
+
return delete n.collectionFormat, delete n.default, {
|
|
222
|
+
schema: B(n),
|
|
223
|
+
...n
|
|
224
|
+
};
|
|
225
|
+
}
|
|
226
|
+
function S(n) {
|
|
227
|
+
return n ? {
|
|
228
|
+
specification: [M, w].reduce((i, f) => f(i), j(q(n)).specification),
|
|
229
|
+
// TODO: Make dynamic
|
|
230
|
+
version: "3.1"
|
|
231
|
+
} : {
|
|
232
|
+
specification: null,
|
|
233
|
+
version: "3.1"
|
|
234
|
+
};
|
|
235
|
+
}
|
|
236
|
+
export {
|
|
237
|
+
j as getEntrypoint,
|
|
238
|
+
x as getListOfReferences,
|
|
239
|
+
b as isFilesystem,
|
|
240
|
+
P as isSchemaPath,
|
|
241
|
+
O as normalize,
|
|
242
|
+
p as traverse,
|
|
243
|
+
S as upgrade,
|
|
244
|
+
w as upgradeFromThreeToThreeOne,
|
|
245
|
+
M as upgradeFromTwoToThree
|
|
246
|
+
};
|
|
247
|
+
//# sourceMappingURL=index-ueM1dihS.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index-ueM1dihS.js","sources":["../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/getEntrypoint.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/traverse.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/getListOfReferences.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/isFilesystem.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/normalize.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/makeFilesystem.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/upgradeFromThreeToThreeOne.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/upgradeFromTwoToThree.js","../../../node_modules/.pnpm/@scalar+openapi-parser@0.10.14/node_modules/@scalar/openapi-parser/dist/utils/upgrade.js"],"sourcesContent":["/**\n * Return just the entrypoint of the filesystem.\n */\nfunction getEntrypoint(filesystem) {\n return filesystem?.find((file) => file.isEntrypoint);\n}\n\nexport { getEntrypoint };\n","/**\n * Recursively traverses the specification and applies the transform function to each node.\n */\nfunction traverse(specification, transform, path = []) {\n const result = {};\n for (const [key, value] of Object.entries(specification)) {\n const currentPath = [...path, key];\n if (Array.isArray(value)) {\n result[key] = value.map((item, index) => {\n if (typeof item === 'object' && !Array.isArray(item) && item !== null) {\n return traverse(item, transform, [...currentPath, index.toString()]);\n }\n return item;\n });\n }\n else if (typeof value === 'object' && !Array.isArray(value) && value !== null) {\n result[key] = traverse(value, transform, currentPath);\n }\n else {\n result[key] = value;\n }\n }\n return transform(result, path);\n}\n\nexport { traverse };\n","import { traverse } from './traverse.js';\n\n/**\n * Walks through the specification and returns all references as an array.\n *\n * Warning: Doesn’t return internal references.\n */\nfunction getListOfReferences(specification) {\n const references = [];\n // Make sure we’re dealing with an object\n if (!specification || typeof specification !== 'object') {\n return references;\n }\n // Traverse the specification and collect all references\n traverse(specification, (value) => {\n if (value.$ref && typeof value.$ref === 'string' && !value.$ref.startsWith('#')) {\n references.push(value.$ref.split('#')[0]);\n }\n return value;\n });\n // Remove duplicates\n return [...new Set(references)];\n}\n\nexport { getListOfReferences };\n","/**\n * Check if the value is a filesystem\n */\nfunction isFilesystem(value) {\n return (typeof value !== 'undefined' &&\n Array.isArray(value) &&\n value.length > 0 &&\n value.some((file) => file.isEntrypoint === true));\n}\n\nexport { isFilesystem };\n","import { parse } from 'yaml';\nimport { isFilesystem } from './isFilesystem.js';\n\n/**\n * Normalize the OpenAPI document (YAML, JSON, object) to a JavaScript object.\n *\n * Doesn’t modify the object if it’s a `Filesystem` (multiple files) already.\n */\nfunction normalize(specification) {\n if (specification === null) {\n return {};\n }\n if (typeof specification === 'string') {\n if (specification.trim() === '') {\n return {};\n }\n try {\n return JSON.parse(specification);\n }\n catch (_error) {\n return parse(specification, {\n maxAliasCount: 10000,\n });\n }\n }\n if (isFilesystem(specification)) {\n return specification;\n }\n return specification;\n}\n\nexport { normalize };\n","import { getListOfReferences } from './getListOfReferences.js';\nimport { isFilesystem } from './isFilesystem.js';\nimport { normalize } from './normalize.js';\n\nfunction makeFilesystem(value, overwrites = {}) {\n // Keep as is\n if (isFilesystem(value)) {\n return value;\n }\n // Make an object\n const specification = normalize(value);\n // Create fake filesystem\n return [\n {\n isEntrypoint: true,\n specification,\n filename: null,\n dir: './',\n references: getListOfReferences(specification),\n ...overwrites,\n },\n ];\n}\n\nexport { makeFilesystem };\n","import { traverse } from './traverse.js';\n\n/**\n * Upgrade from OpenAPI 3.0.x to 3.1.1\n *\n * https://www.openapis.org/blog/2021/02/16/migrating-from-openapi-3-0-to-3-1-0\n */\nfunction upgradeFromThreeToThreeOne(originalSpecification) {\n let specification = originalSpecification;\n // Version\n if (specification !== null && typeof specification.openapi === 'string' && specification.openapi.startsWith('3.0')) {\n specification.openapi = '3.1.1';\n }\n else {\n // Skip if it’s something else than 3.0.x\n return specification;\n }\n // Nullable types\n specification = traverse(specification, (schema) => {\n if (schema.type !== 'undefined' && schema.nullable === true) {\n schema.type = [schema.type, 'null'];\n delete schema.nullable;\n }\n return schema;\n });\n // exclusiveMinimum and exclusiveMaximum\n specification = traverse(specification, (schema) => {\n if (schema.exclusiveMinimum === true) {\n schema.exclusiveMinimum = schema.minimum;\n delete schema.minimum;\n }\n else if (schema.exclusiveMinimum === false) {\n delete schema.exclusiveMinimum;\n }\n if (schema.exclusiveMaximum === true) {\n schema.exclusiveMaximum = schema.maximum;\n delete schema.maximum;\n }\n else if (schema.exclusiveMaximum === false) {\n delete schema.exclusiveMaximum;\n }\n return schema;\n });\n // Use examples not example\n specification = traverse(specification, (schema, path) => {\n if (schema.example !== undefined) {\n // Arrays in schemas\n if (isSchemaPath(path)) {\n schema.examples = [schema.example];\n }\n // Objects everywhere else\n else {\n schema.examples = {\n default: {\n value: schema.example,\n },\n };\n }\n delete schema.example;\n }\n return schema;\n });\n // Multipart file uploads with a binary file\n specification = traverse(specification, (schema, path) => {\n if (schema.type === 'object' && schema.properties !== undefined) {\n // Check if this is a multipart request body schema\n const parentPath = path.slice(0, -1);\n const isMultipart = parentPath.some((segment, index) => {\n return segment === 'content' && path[index + 1] === 'multipart/form-data';\n });\n if (isMultipart) {\n // Types\n const entries = Object.entries(schema.properties);\n for (const [_, value] of entries) {\n if (typeof value === 'object' && value.type === 'string' && value.format === 'binary') {\n value.contentMediaType = 'application/octet-stream';\n delete value.format;\n }\n }\n }\n }\n return schema;\n });\n // Uploading a binary file in a POST request\n specification = traverse(specification, (schema, path) => {\n if (path.includes('content') && path.includes('application/octet-stream')) {\n return {};\n }\n if (schema.type === 'string' && schema.format === 'binary') {\n return {\n type: 'string',\n contentMediaType: 'application/octet-stream',\n };\n }\n return schema;\n });\n // Uploading an image with base64 encoding\n specification = traverse(specification, (schema) => {\n if (schema.type === 'string' && schema.format === 'base64') {\n return {\n type: 'string',\n contentEncoding: 'base64',\n };\n }\n return schema;\n });\n specification = traverse(specification, (schema, path) => {\n if (schema.type === 'string' && schema.format === 'byte') {\n const parentPath = path.slice(0, -1);\n const contentMediaType = parentPath.find((_, index) => path[index - 1] === 'content');\n return {\n type: 'string',\n contentEncoding: 'base64',\n contentMediaType,\n };\n }\n return schema;\n });\n // Declaring $schema Dialects to protect against change\n // if (typeof specification.$schema === 'undefined') {\n // specification.$schema = 'http://json-schema.org/draft-07/schema#'\n // }\n return specification;\n}\n/** Determine if the current path is within a schema */\nfunction isSchemaPath(path) {\n const schemaLocations = [\n ['components', 'schemas'],\n 'properties',\n 'items',\n 'allOf',\n 'anyOf',\n 'oneOf',\n 'not',\n 'additionalProperties',\n ];\n return (schemaLocations.some((location) => {\n if (Array.isArray(location)) {\n return location.every((segment, index) => path[index] === segment);\n }\n return path.includes(location);\n }) ||\n path.includes('schema') ||\n path.some((segment) => segment.endsWith('Schema')));\n}\n\nexport { isSchemaPath, upgradeFromThreeToThreeOne };\n","import { traverse } from './traverse.js';\n\n/**\n * Upgrade Swagger 2.0 to OpenAPI 3.0\n *\n * https://swagger.io/blog/news/whats-new-in-openapi-3-0/\n */\nfunction upgradeFromTwoToThree(originalSpecification) {\n let specification = originalSpecification;\n // Version\n if (specification !== null && typeof specification.swagger === 'string' && specification.swagger?.startsWith('2.0')) {\n specification.openapi = '3.0.4';\n delete specification.swagger;\n }\n else {\n // Skip if it’s something else than 3.0.x\n return specification;\n }\n // Servers\n if (specification.host) {\n const schemes = Array.isArray(specification.schemes) && specification.schemes?.length ? specification.schemes : ['http'];\n specification.servers = schemes.map((scheme) => ({\n url: `${scheme}://${specification.host}${specification.basePath ?? ''}`,\n }));\n delete specification.basePath;\n delete specification.schemes;\n delete specification.host;\n }\n else if (specification.basePath) {\n specification.servers = [{ url: specification.basePath }];\n delete specification.basePath;\n }\n // Schemas\n if (specification.definitions) {\n specification.components = Object.assign({}, specification.components, {\n schemas: specification.definitions,\n });\n delete specification.definitions;\n // Rewrite $refs to definitions\n specification = traverse(specification, (schema) => {\n if (schema.$ref?.startsWith('#/definitions/')) {\n schema.$ref = schema.$ref.replace(/^#\\/definitions\\//, '#/components/schemas/');\n }\n return schema;\n });\n }\n specification = traverse(specification, (schema) => {\n if (schema.type === 'file') {\n schema.type = 'string';\n schema.format = 'binary';\n }\n return schema;\n });\n // Paths\n if (typeof specification.paths === 'object') {\n for (const path in specification.paths) {\n if (Object.hasOwn(specification.paths, path)) {\n const pathItem = specification.paths[path];\n for (const method in pathItem) {\n if (Object.hasOwn(pathItem, method)) {\n const operationItem = pathItem[method];\n // Request bodies\n if (operationItem.parameters) {\n const bodyParameter = structuredClone(operationItem.parameters.find((parameter) => parameter.in === 'body') ?? {});\n if (bodyParameter && Object.keys(bodyParameter).length) {\n delete bodyParameter.name;\n delete bodyParameter.in;\n const consumes = specification.consumes ?? operationItem.consumes ?? ['application/json'];\n if (typeof operationItem.requestBody !== 'object') {\n operationItem.requestBody = {};\n }\n if (typeof operationItem.requestBody.content !== 'object') {\n operationItem.requestBody.content = {};\n }\n const { schema, ...requestBody } = bodyParameter;\n operationItem.requestBody = {\n ...operationItem.requestBody,\n ...requestBody,\n };\n for (const type of consumes) {\n operationItem.requestBody.content[type] = {\n schema: schema,\n };\n }\n }\n // Delete body parameter\n operationItem.parameters = operationItem.parameters.filter((parameter) => parameter.in !== 'body');\n delete operationItem.consumes;\n // formData parameters\n const formDataParameters = operationItem.parameters.filter((parameter) => parameter.in === 'formData');\n if (formDataParameters.length > 0) {\n if (typeof operationItem.requestBody !== 'object') {\n operationItem.requestBody = {};\n }\n if (typeof operationItem.requestBody.content !== 'object') {\n operationItem.requestBody.content = {};\n }\n operationItem.requestBody.content['application/x-www-form-urlencoded'] = {\n schema: {\n type: 'object',\n properties: {},\n required: [], // Initialize required array\n },\n };\n for (const param of formDataParameters) {\n operationItem.requestBody.content['application/x-www-form-urlencoded'].schema.properties[param.name] =\n {\n type: param.type,\n description: param.description,\n };\n // Add to required array if param is required\n if (param.required) {\n operationItem.requestBody.content['application/x-www-form-urlencoded'].schema.required.push(param.name);\n }\n }\n // Remove formData parameters from the parameters array\n operationItem.parameters = operationItem.parameters.filter((parameter) => parameter.in !== 'formData');\n }\n operationItem.parameters = operationItem.parameters.map((parameter) => transformParameterObject(parameter));\n }\n // Responses\n if (operationItem.responses) {\n for (const response in operationItem.responses) {\n if (Object.hasOwn(operationItem.responses, response)) {\n const responseItem = operationItem.responses[response];\n if (responseItem.headers) {\n responseItem.headers = Object.entries(responseItem.headers).reduce((acc, [name, header]) => {\n return {\n [name]: transformParameterObject(header),\n ...acc,\n };\n }, {});\n }\n if (responseItem.schema) {\n const produces = specification.produces ?? operationItem.produces ?? ['application/json'];\n if (typeof responseItem.content !== 'object') {\n responseItem.content = {};\n }\n for (const type of produces) {\n responseItem.content[type] = {\n schema: responseItem.schema,\n };\n }\n delete responseItem.schema;\n }\n }\n }\n }\n delete operationItem.produces;\n // Delete empty parameters\n if (operationItem.parameters?.length === 0) {\n delete operationItem.parameters;\n }\n }\n }\n }\n }\n }\n // Upgrade securityDefinitions\n if (specification.securityDefinitions) {\n if (typeof specification.components !== 'object') {\n specification.components = {};\n }\n // Assert that components is of type OpenAPIV3.ComponentsObject\n specification.components = specification.components;\n Object.assign(specification.components, { securitySchemes: {} });\n for (const [key, securityScheme] of Object.entries(specification.securityDefinitions)) {\n if (typeof securityScheme === 'object') {\n if ('type' in securityScheme && securityScheme.type === 'oauth2') {\n const { flow, authorizationUrl, tokenUrl, scopes } = securityScheme;\n // Assert that securitySchemes is of type OpenAPIV3.SecuritySchemeObject\n Object.assign(specification.components.securitySchemes, {\n [key]: {\n type: 'oauth2',\n flows: {\n [flow]: Object.assign({}, authorizationUrl && { authorizationUrl }, tokenUrl && { tokenUrl }, scopes && { scopes }),\n },\n },\n });\n }\n else if ('type' in securityScheme && securityScheme.type === 'basic') {\n Object.assign(specification.components.securitySchemes, {\n [key]: {\n type: 'http',\n scheme: 'basic',\n },\n });\n }\n else {\n Object.assign(specification.components.securitySchemes, {\n [key]: securityScheme,\n });\n }\n }\n }\n delete specification.securityDefinitions;\n }\n return specification;\n}\nfunction transformItemsObject(obj) {\n const schemaProperties = [\n 'type',\n 'format',\n 'items',\n 'maximum',\n 'exclusiveMaximum',\n 'minimum',\n 'exclusiveMinimum',\n 'maxLength',\n 'minLength',\n 'pattern',\n 'maxItems',\n 'minItems',\n 'uniqueItems',\n 'enum',\n 'multipleOf',\n ];\n return schemaProperties.reduce((acc, property) => {\n if (Object.hasOwn(obj, property)) {\n acc[property] = obj[property];\n delete obj[property];\n }\n return acc;\n }, {});\n}\nfunction transformParameterObject(parameter) {\n delete parameter.collectionFormat;\n delete parameter.default;\n return {\n schema: transformItemsObject(parameter),\n ...parameter,\n };\n}\n\nexport { upgradeFromTwoToThree };\n","import { getEntrypoint } from './getEntrypoint.js';\nimport { makeFilesystem } from './makeFilesystem.js';\nimport { upgradeFromThreeToThreeOne } from './upgradeFromThreeToThreeOne.js';\nimport { upgradeFromTwoToThree } from './upgradeFromTwoToThree.js';\n\n/**\n * Upgrade specification to OpenAPI 3.1.0\n */\nfunction upgrade(value) {\n if (!value) {\n return {\n specification: null,\n version: '3.1',\n };\n }\n const upgraders = [upgradeFromTwoToThree, upgradeFromThreeToThreeOne];\n // TODO: Run upgrade over the whole filesystem\n const result = upgraders.reduce((currentSpecification, upgrader) => upgrader(currentSpecification), getEntrypoint(makeFilesystem(value)).specification);\n return {\n specification: result,\n // TODO: Make dynamic\n version: '3.1',\n };\n}\n\nexport { upgrade };\n"],"names":["getEntrypoint","filesystem","file","traverse","specification","transform","path","result","key","value","currentPath","item","index","getListOfReferences","references","isFilesystem","normalize","parse","makeFilesystem","overwrites","upgradeFromThreeToThreeOne","originalSpecification","schema","isSchemaPath","segment","entries","_","location","upgradeFromTwoToThree","_a","schemes","_b","scheme","pathItem","method","operationItem","bodyParameter","parameter","consumes","requestBody","type","formDataParameters","param","transformParameterObject","response","responseItem","acc","name","header","produces","_c","securityScheme","flow","authorizationUrl","tokenUrl","scopes","transformItemsObject","obj","property","upgrade","currentSpecification","upgrader"],"mappings":";AAGA,SAASA,EAAcC,GAAY;AAC/B,SAAOA,KAAA,gBAAAA,EAAY,KAAK,CAACC,MAASA,EAAK;AAC3C;ACFA,SAASC,EAASC,GAAeC,GAAWC,IAAO,CAAA,GAAI;AACnD,QAAMC,IAAS,CAAE;AACjB,aAAW,CAACC,GAAKC,CAAK,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AAO/C,EAAc;AAAA,EAC7B;AACI,SAAOA;AACX;AACA,SAASoD,EAAqBC,GAAK;AAkB/B,SAjByB;AAAA,IACrB;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,IACA;AAAA,EACH,EACuB,OAAO,CAACX,GAAKY,OAC7B,OAAO,OAAOD,GAAKC,CAAQ,MAC3BZ,EAAIY,CAAQ,IAAID,EAAIC,CAAQ,GAC5B,OAAOD,EAAIC,CAAQ,IAEhBZ,IACR,EAAE;AACT;AACA,SAASH,EAAyBN,GAAW;AACzC,gBAAOA,EAAU,kBACjB,OAAOA,EAAU,SACV;AAAA,IACH,QAAQmB,EAAqBnB,CAAS;AAAA,IACtC,GAAGA;AAAA,EACN;AACL;AChOA,SAASsB,EAAQlD,GAAO;AACpB,SAAKA,IASE;AAAA,IACH,eAJc,CAACmB,GAAuBR,CAA0B,EAE3C,OAAO,CAACwC,GAAsBC,MAAaA,EAASD,CAAoB,GAAG5D,EAAckB,EAAeT,CAAK,CAAC,EAAE,aAAa;AAAA;AAAA,IAIlJ,SAAS;AAAA,EACZ,IAZU;AAAA,IACH,eAAe;AAAA,IACf,SAAS;AAAA,EACZ;AAUT;","x_google_ignoreList":[0,1,2,3,4,5,6,7,8]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { traverse as c } from "./traverse.js";
|
|
2
|
-
const x = ({ keys: t, shouldRemove: o } = {}) => (n) => c(n, (i) => {
|
|
2
|
+
const x = ({ keys: t, shouldRemove: o } = {}) => ({ schema: n }) => c(n, (i) => {
|
|
3
3
|
const s = {};
|
|
4
4
|
for (const [e, r] of Object.entries(i))
|
|
5
5
|
e.startsWith("x-") && (t === void 0 || t.includes(e)) && (!o || o(e)) || (s[e] = r);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeExtensions.js","sources":["../../src/lib/plugins/openapi/processors/removeExtensions.ts"],"sourcesContent":["import { type RecordAny, traverse } from \"./traverse.js\";\n\ninterface RemoveExtensionsOptions {\n keys?: string[];\n shouldRemove?: (key: string) => boolean;\n}\n\n// Remove all `x-` prefixed key/value pairs, or filter by names if provided\nexport const removeExtensions =\n ({ keys, shouldRemove }: RemoveExtensionsOptions = {}) =>\n (
|
|
1
|
+
{"version":3,"file":"removeExtensions.js","sources":["../../src/lib/plugins/openapi/processors/removeExtensions.ts"],"sourcesContent":["import type { ProcessorArg } from \"../../../../config/validators/BuildSchema.js\";\nimport type { OpenAPIDocument } from \"../../../oas/parser/index.js\";\nimport { type RecordAny, traverse } from \"./traverse.js\";\n\ninterface RemoveExtensionsOptions {\n keys?: string[];\n shouldRemove?: (key: string) => boolean;\n}\n\n// Remove all `x-` prefixed key/value pairs, or filter by names if provided\nexport const removeExtensions =\n ({ keys, shouldRemove }: RemoveExtensionsOptions = {}) =>\n ({ schema }: ProcessorArg) =>\n traverse(schema, (spec) => {\n const result: RecordAny = {};\n\n for (const [key, value] of Object.entries(spec)) {\n const isExtension = key.startsWith(\"x-\");\n const shouldBeRemoved =\n isExtension &&\n (keys === undefined || keys.includes(key)) &&\n (!shouldRemove || shouldRemove(key));\n\n if (shouldBeRemoved) continue;\n\n result[key] = value;\n }\n return result;\n }) as OpenAPIDocument;\n"],"names":["removeExtensions","keys","shouldRemove","schema","traverse","spec","result","key","value"],"mappings":";AAUO,MAAMA,IACX,CAAC,EAAE,MAAAC,GAAM,cAAAC,EAA0C,IAAA,CACnD,MAAA,CAAC,EAAE,QAAAC,QACDC,EAASD,GAAQ,CAACE,MAAS;AACzB,QAAMC,IAAoB,CAAC;AAE3B,aAAW,CAACC,GAAKC,CAAK,KAAK,OAAO,QAAQH,CAAI;AAO5C,IANoBE,EAAI,WAAW,IAAI,MAGpCN,MAAS,UAAaA,EAAK,SAASM,CAAG,OACvC,CAACL,KAAgBA,EAAaK,CAAG,OAIpCD,EAAOC,CAAG,IAAIC;AAET,SAAAF;AACT,CAAC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { traverse as j } from "./traverse.js";
|
|
2
|
-
const O = ({ names: f, in: n, shouldRemove: i } = {}) => (c) => j(c, (r) => {
|
|
2
|
+
const O = ({ names: f, in: n, shouldRemove: i } = {}) => ({ schema: c }) => j(c, (r) => {
|
|
3
3
|
var b;
|
|
4
4
|
const y = (p) => p.filter((e) => !(f != null && f.includes(e.name) || n != null && n.includes(e.in) || i != null && i({ parameter: e })));
|
|
5
5
|
if ((b = r.components) != null && b.parameters && (r = {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removeParameters.js","sources":["../../src/lib/plugins/openapi/processors/removeParameters.ts"],"sourcesContent":["import { type RecordAny, traverse } from \"./traverse.js\";\n\ninterface RemoveParametersOptions {\n // Names of parameters to remove\n names?: string[];\n // Specific locations to remove parameters from ('query', 'header', 'path', 'cookie')\n in?: string[];\n // Custom filter function\n shouldRemove?: ({ parameter }: { parameter: RecordAny }) => boolean;\n}\n\nexport const removeParameters =\n ({ names, in: locations, shouldRemove }: RemoveParametersOptions = {}) =>\n (
|
|
1
|
+
{"version":3,"file":"removeParameters.js","sources":["../../src/lib/plugins/openapi/processors/removeParameters.ts"],"sourcesContent":["import type { ProcessorArg } from \"../../../../config/validators/BuildSchema.js\";\nimport type { OpenAPIDocument } from \"../../../oas/parser/index.js\";\nimport { type RecordAny, traverse } from \"./traverse.js\";\n\ninterface RemoveParametersOptions {\n // Names of parameters to remove\n names?: string[];\n // Specific locations to remove parameters from ('query', 'header', 'path', 'cookie')\n in?: string[];\n // Custom filter function\n shouldRemove?: ({ parameter }: { parameter: RecordAny }) => boolean;\n}\n\nexport const removeParameters =\n ({ names, in: locations, shouldRemove }: RemoveParametersOptions = {}) =>\n ({ schema }: ProcessorArg) =>\n traverse(schema, (spec) => {\n // Helper function to filter parameters\n const filterParameters = (parameters: RecordAny[]) =>\n parameters.filter((p) => {\n if (names?.includes(p.name)) return false;\n if (locations?.includes(p.in)) return false;\n if (shouldRemove?.({ parameter: p })) return false;\n return true;\n });\n\n // Handle components.parameters\n if (spec.components?.parameters) {\n spec = {\n ...spec,\n components: {\n ...spec.components,\n parameters: Object.fromEntries(\n Object.entries(spec.components.parameters).filter(\n ([_, param]) => {\n const p = param as RecordAny;\n if (p.$ref) return true; // Skip references\n return (\n !names?.includes(p.name) &&\n !locations?.includes(p.in) &&\n !shouldRemove?.({ parameter: p })\n );\n },\n ),\n ),\n },\n };\n }\n\n // Handle paths\n if (spec.paths) {\n const updatedPaths: RecordAny = {};\n\n for (const [path, pathItem] of Object.entries(spec.paths)) {\n if (typeof pathItem !== \"object\" || pathItem === null) {\n updatedPaths[path] = pathItem;\n continue;\n }\n\n let updatedPathItem = { ...pathItem };\n\n // Handle path-level parameters\n if (\n \"parameters\" in updatedPathItem &&\n Array.isArray(updatedPathItem.parameters)\n ) {\n updatedPathItem.parameters = filterParameters(\n updatedPathItem.parameters,\n );\n }\n\n // Handle operation-level parameters\n for (const method of Object.keys(updatedPathItem)) {\n const pathItemWithMethods = updatedPathItem as Record<\n string,\n RecordAny\n >;\n\n if (\n method === \"parameters\" ||\n typeof pathItemWithMethods[method] !== \"object\"\n ) {\n continue;\n }\n\n const operation = pathItemWithMethods[method];\n if (Array.isArray(operation.parameters)) {\n pathItemWithMethods[method] = {\n ...operation,\n parameters: filterParameters(operation.parameters),\n };\n updatedPathItem = pathItemWithMethods;\n }\n }\n\n updatedPaths[path] = updatedPathItem;\n }\n\n spec = { ...spec, paths: updatedPaths };\n }\n\n return spec;\n }) as OpenAPIDocument;\n"],"names":["removeParameters","names","locations","shouldRemove","schema","traverse","spec","filterParameters","parameters","p","_a","_","param","updatedPaths","path","pathItem","updatedPathItem","method","pathItemWithMethods","operation"],"mappings":";AAaO,MAAMA,IACX,CAAC,EAAE,OAAAC,GAAO,IAAIC,GAAW,cAAAC,EAAa,IAA6B,OACnE,CAAC,EAAE,Q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I,MAAM,QAAQE,EAAU,UAAU,MACpCD,EAAoBD,CAAM,IAAI;AAAA,UAC5B,GAAGE;AAAA,UACH,YAAYZ,EAAiBY,EAAU,UAAU;AAAA,QACnD,GACkBH,IAAAE;AAAA,MACpB;AAGF,MAAAL,EAAaC,CAAI,IAAIE;AAAA,IAAA;AAGvB,IAAAV,IAAO,EAAE,GAAGA,GAAM,OAAOO,EAAa;AAAA,EAAA;AAGjC,SAAAP;AACT,CAAC;"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { traverse as y } from "./traverse.js";
|
|
2
|
-
const P = ({ paths: e = {}, shouldRemove: r }) => (f) => y(f, (n) => {
|
|
2
|
+
const P = ({ paths: e = {}, shouldRemove: r }) => ({ schema: f }) => y(f, (n) => {
|
|
3
3
|
if (!n.paths) return n;
|
|
4
4
|
const a = {};
|
|
5
5
|
for (const [t, i] of Object.entries(n.paths)) {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"removePaths.js","sources":["../../src/lib/plugins/openapi/processors/removePaths.ts"],"sourcesContent":["import { type RecordAny, traverse } from \"./traverse.js\";\n\ninterface RemovePathsOptions {\n // Path definitions, e.g., { '/path': true, '/path-2': ['get'] }\n paths?: Record<string, true | string[]>;\n shouldRemove?: (options: {\n path: string;\n method: true | string;\n operation: RecordAny;\n }) => boolean;\n}\n\nexport const removePaths =\n ({ paths = {}, shouldRemove }: RemovePathsOptions) =>\n (
|
|
1
|
+
{"version":3,"file":"removePaths.js","sources":["../../src/lib/plugins/openapi/processors/removePaths.ts"],"sourcesContent":["import type { ProcessorArg } from \"../../../../config/validators/BuildSchema.js\";\nimport type { OpenAPIDocument } from \"../../../oas/parser/index.js\";\nimport { type RecordAny, traverse } from \"./traverse.js\";\n\ninterface RemovePathsOptions {\n // Path definitions, e.g., { '/path': true, '/path-2': ['get'] }\n paths?: Record<string, true | string[]>;\n shouldRemove?: (options: {\n path: string;\n method: true | string;\n operation: RecordAny;\n }) => boolean;\n}\n\nexport const removePaths =\n ({ paths = {}, shouldRemove }: RemovePathsOptions) =>\n ({ schema }: ProcessorArg) =>\n traverse(schema, (spec) => {\n if (!spec.paths) return spec;\n\n const updatedPaths: RecordAny = {};\n\n for (const [path, methods] of Object.entries(spec.paths)) {\n const operations = spec.paths[path];\n\n // If the path is explicitly marked for removal in `paths`\n if (paths[path] === true) continue;\n\n // If the path should be removed via `shouldRemove`\n if (shouldRemove?.({ path, method: true, operation: operations }))\n continue;\n\n if (typeof methods === \"object\" && methods !== null) {\n const filteredPath = Object.fromEntries(\n Object.entries(methods).filter(([method]) => {\n const operations = spec.paths[path][method];\n const isMethodToRemove =\n Array.isArray(paths[path]) && paths[path].includes(method);\n\n const isMethodFiltered = shouldRemove?.({\n path,\n method,\n operation: operations,\n });\n\n return !isMethodToRemove && !isMethodFiltered;\n }),\n );\n\n updatedPaths[path] = filteredPath;\n } else {\n updatedPaths[path] = methods;\n }\n }\n\n return { ...spec, paths: updatedPaths };\n }) as OpenAPIDocument;\n"],"names":["removePaths","paths","shouldRemove","schema","traverse","spec","updatedPaths","path","methods","operations","filteredPath","method","isMethodToRemove","isMethodFiltered"],"mappings":";AAcO,MAAMA,IACX,CAAC,EAAE,OAAAC,IAAQ,CAAA,GAAI,cAAAC,EACf,MAAA,CAAC,EAAE,QAAAC,QACDC,EAASD,GAAQ,CAACE,MAAS;AACrB,MAAA,CAACA,EAAK,MAAc,QAAAA;AAExB,QAAMC,IAA0B,CAAC;AAEtB,aAAA,CAACC,GAAMC,CAAO,KAAK,OAAO,QAAQH,EAAK,KAAK,GAAG;AAClD,UAAAI,IAAaJ,EAAK,MAAME,CAAI;AAG9B,QAAAN,EAAMM,CAAI,MAAM,MAGhB,EAAAL,KAAA,QAAAA,EAAe,EAAE,MAAAK,GAAM,QAAQ,IAAM,WAAWE;AAGpD,UAAI,OAAOD,KAAY,YAAYA,MAAY,MAAM;AACnD,cAAME,IAAe,OAAO;AAAA,UAC1B,OAAO,QAAQF,CAAO,EAAE,OAAO,CAAC,CAACG,CAAM,MAAM;AAC3C,kBAAMF,IAAaJ,EAAK,MAAME,CAAI,EAAEI,CAAM,GACpCC,IACJ,MAAM,QAAQX,EAAMM,CAAI,CAAC,KAAKN,EAAMM,CAAI,EAAE,SAASI,CAAM,GAErDE,IAAmBX,KAAA,gBAAAA,EAAe;AAAA,cACtC,MAAAK;AAAA,cACA,QAAAI;AAAA,cACA,WAAWF;AAAAA,YAAA;AAGN,mBAAA,CAACG,KAAoB,CAACC;AAAA,UAC9B,CAAA;AAAA,QACH;AAEA,QAAAP,EAAaC,CAAI,IAAIG;AAAA,MAAA;AAErB,QAAAJ,EAAaC,CAAI,IAAIC;AAAA,EACvB;AAGF,SAAO,EAAE,GAAGH,GAAM,OAAOC,EAAa;AACxC,CAAC;"}
|