oas 37.1.0 → 38.0.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/README.md +13 -3
- package/dist/analyzer/index.cjs +400 -203
- package/dist/analyzer/index.cjs.map +1 -1
- package/dist/analyzer/index.d.cts +23 -129
- package/dist/analyzer/index.d.ts +23 -129
- package/dist/analyzer/index.js +395 -198
- package/dist/analyzer/index.js.map +1 -1
- package/dist/analyzer/types.cjs +26 -1
- package/dist/analyzer/types.cjs.map +1 -1
- package/dist/analyzer/types.d.cts +20 -24
- package/dist/analyzer/types.d.ts +20 -24
- package/dist/analyzer/types.js +25 -0
- package/dist/analyzer/types.js.map +1 -1
- package/dist/{chunk-W6GBV2JT.cjs → chunk-COHEPMUP.cjs} +1 -1
- package/dist/chunk-COHEPMUP.cjs.map +1 -0
- package/dist/{chunk-CKC36IL7.js → chunk-QTPMJRIE.js} +1 -1
- package/dist/chunk-QTPMJRIE.js.map +1 -0
- package/dist/{chunk-6APWNY54.js → chunk-VSILRJVM.js} +58 -57
- package/dist/chunk-VSILRJVM.js.map +1 -0
- package/dist/{chunk-I7R3WTTN.js → chunk-XTE5ZNGQ.js} +2 -2
- package/dist/{chunk-QPYARJRD.cjs → chunk-YFZN44KB.cjs} +70 -70
- package/dist/{chunk-QPYARJRD.cjs.map → chunk-YFZN44KB.cjs.map} +1 -1
- package/dist/{chunk-OWMXX4EB.cjs → chunk-ZD7R5BNE.cjs} +59 -58
- package/dist/chunk-ZD7R5BNE.cjs.map +1 -0
- package/dist/index.cjs +27 -27
- package/dist/index.js +2 -2
- package/dist/operation/index.cjs +3 -3
- package/dist/operation/index.js +2 -2
- package/dist/reducer/index.cjs +9 -9
- package/dist/reducer/index.js +2 -2
- package/dist/utils.cjs +2 -2
- package/dist/utils.js +1 -1
- package/package.json +2 -2
- package/dist/chunk-6APWNY54.js.map +0 -1
- package/dist/chunk-CKC36IL7.js.map +0 -1
- package/dist/chunk-OWMXX4EB.cjs.map +0 -1
- package/dist/chunk-W6GBV2JT.cjs.map +0 -1
- /package/dist/{chunk-I7R3WTTN.js.map → chunk-XTE5ZNGQ.js.map} +0 -0
package/dist/analyzer/index.cjs
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
|
-
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _optionalChain(ops) { let lastAccessLHS = undefined; let value = ops[0]; let i = 1; while (i < ops.length) { const op = ops[i]; const fn = ops[i + 1]; i += 2; if ((op === 'optionalAccess' || op === 'optionalCall') && value == null) { return undefined; } if (op === 'access' || op === 'optionalAccess') { lastAccessLHS = value; value = fn(value); } else if (op === 'call' || op === 'optionalCall') { value = fn((...args) => value.call(lastAccessLHS, ...args)); lastAccessLHS = undefined; } } return value; }
|
|
2
2
|
|
|
3
3
|
|
|
4
|
-
var
|
|
4
|
+
var _chunkCOHEPMUPcjs = require('../chunk-COHEPMUP.cjs');
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
var _chunkZD7R5BNEcjs = require('../chunk-ZD7R5BNE.cjs');
|
|
11
|
+
require('../chunk-6HXOZ5GY.cjs');
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
var _chunk7PWF3F2Wcjs = require('../chunk-7PWF3F2W.cjs');
|
|
5
15
|
|
|
6
16
|
// src/analyzer/dereference.ts
|
|
7
17
|
var _openapiparser = require('@readme/openapi-parser');
|
|
8
|
-
function getDereferencingOptions(
|
|
18
|
+
function getDereferencingOptions(circularRefs) {
|
|
9
19
|
return {
|
|
10
20
|
resolve: {
|
|
11
21
|
// We shouldn't be resolving external pointers at this point so just ignore them.
|
|
@@ -17,7 +27,7 @@ function getDereferencingOptions(circularRefs2) {
|
|
|
17
27
|
// accumulate a list of circular references.
|
|
18
28
|
circular: "ignore",
|
|
19
29
|
onCircular: (path) => {
|
|
20
|
-
|
|
30
|
+
circularRefs.add(`#${path.split("#")[1]}`);
|
|
21
31
|
}
|
|
22
32
|
}
|
|
23
33
|
};
|
|
@@ -47,13 +57,13 @@ async function dereferenceOas(definition, opts) {
|
|
|
47
57
|
});
|
|
48
58
|
}
|
|
49
59
|
state.processing = true;
|
|
50
|
-
const
|
|
51
|
-
const dereferencingOptions = getDereferencingOptions(
|
|
60
|
+
const circularRefs = /* @__PURE__ */ new Set();
|
|
61
|
+
const dereferencingOptions = getDereferencingOptions(circularRefs);
|
|
52
62
|
const { promises } = state;
|
|
53
63
|
return _openapiparser.dereference.call(void 0, definition, dereferencingOptions).then((dereferenced) => {
|
|
54
64
|
const result = {
|
|
55
65
|
api: dereferenced,
|
|
56
|
-
circularRefs: [...
|
|
66
|
+
circularRefs: [...circularRefs]
|
|
57
67
|
};
|
|
58
68
|
state.result = result;
|
|
59
69
|
state.circularRefs = result.circularRefs;
|
|
@@ -74,51 +84,189 @@ async function dereferenceOas(definition, opts) {
|
|
|
74
84
|
throw err;
|
|
75
85
|
});
|
|
76
86
|
}
|
|
87
|
+
function dereferenceOasShared(definition) {
|
|
88
|
+
let clone = sharedClones.get(definition);
|
|
89
|
+
if (!clone) {
|
|
90
|
+
clone = structuredClone(definition);
|
|
91
|
+
sharedClones.set(definition, clone);
|
|
92
|
+
}
|
|
93
|
+
return dereferenceOas(clone);
|
|
94
|
+
}
|
|
95
|
+
var sharedClones = /* @__PURE__ */ new WeakMap();
|
|
77
96
|
|
|
78
|
-
// src/analyzer/
|
|
79
|
-
|
|
80
|
-
|
|
97
|
+
// src/analyzer/query-cache.ts
|
|
98
|
+
var cache = /* @__PURE__ */ new WeakMap();
|
|
99
|
+
function queryCached(queries, definition) {
|
|
100
|
+
let byQuery = cache.get(definition);
|
|
101
|
+
if (!byQuery) {
|
|
102
|
+
byQuery = /* @__PURE__ */ new Map();
|
|
103
|
+
cache.set(definition, byQuery);
|
|
104
|
+
}
|
|
105
|
+
const cacheKey = queries.join(" ");
|
|
106
|
+
let results = byQuery.get(cacheKey);
|
|
107
|
+
if (!results) {
|
|
108
|
+
results = _chunkCOHEPMUPcjs.query.call(void 0, queries, definition);
|
|
109
|
+
byQuery.set(cacheKey, results);
|
|
110
|
+
}
|
|
111
|
+
return results;
|
|
81
112
|
}
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
113
|
+
|
|
114
|
+
// src/analyzer/scope.ts
|
|
115
|
+
var _jsonpointer = require('jsonpointer'); var _jsonpointer2 = _interopRequireDefault(_jsonpointer);
|
|
116
|
+
function resolveKey(keys, target) {
|
|
117
|
+
return keys.find((key) => key === target) || keys.find((key) => key.toLowerCase() === target.toLowerCase());
|
|
86
118
|
}
|
|
87
|
-
|
|
88
|
-
const
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
119
|
+
function accumulateReachableRefs(definition, seeds) {
|
|
120
|
+
const reachable = /* @__PURE__ */ new Set();
|
|
121
|
+
const queue = [...seeds];
|
|
122
|
+
while (queue.length) {
|
|
123
|
+
const ref = queue.shift();
|
|
124
|
+
if (reachable.has(ref)) {
|
|
125
|
+
continue;
|
|
126
|
+
}
|
|
127
|
+
reachable.add(ref);
|
|
128
|
+
let resolved;
|
|
129
|
+
try {
|
|
130
|
+
resolved = _jsonpointer2.default.get(definition, _chunkZD7R5BNEcjs.toPointer.call(void 0, ref));
|
|
131
|
+
} catch (e) {
|
|
132
|
+
continue;
|
|
133
|
+
}
|
|
134
|
+
if (resolved === void 0) {
|
|
135
|
+
continue;
|
|
136
|
+
}
|
|
137
|
+
_chunkZD7R5BNEcjs.collectRefsInSchema.call(void 0, resolved).forEach((nestedRef) => {
|
|
138
|
+
if (!reachable.has(nestedRef)) {
|
|
139
|
+
queue.push(nestedRef);
|
|
140
|
+
}
|
|
141
|
+
});
|
|
142
|
+
}
|
|
143
|
+
return reachable;
|
|
144
|
+
}
|
|
145
|
+
function buildAnchors(rootPointer, extraPointers, reachableRefs) {
|
|
146
|
+
const anchors = [rootPointer, ...extraPointers];
|
|
147
|
+
reachableRefs.forEach((ref) => anchors.push(_chunkZD7R5BNEcjs.toPointer.call(void 0, ref)));
|
|
148
|
+
return { anchors, anchorPrefixes: anchors.map((anchor) => `${anchor}/`) };
|
|
149
|
+
}
|
|
150
|
+
function collectSecuritySchemeRefs(security) {
|
|
151
|
+
if (!Array.isArray(security)) {
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
const refs = [];
|
|
155
|
+
security.forEach((requirement) => {
|
|
156
|
+
if (requirement && typeof requirement === "object") {
|
|
157
|
+
Object.keys(requirement).forEach((scheme) => {
|
|
158
|
+
refs.push(`#/components/securitySchemes/${scheme}`);
|
|
159
|
+
});
|
|
160
|
+
}
|
|
161
|
+
});
|
|
162
|
+
return refs;
|
|
163
|
+
}
|
|
164
|
+
function computeOperationScope(definition, path, method) {
|
|
165
|
+
const pathKey = resolveKey(Object.keys(definition.paths || {}), path);
|
|
166
|
+
if (!pathKey) {
|
|
167
|
+
throw new Error(`Path \`${path}\` not found.`);
|
|
168
|
+
}
|
|
169
|
+
const pathItem = definition.paths[pathKey] || {};
|
|
170
|
+
const methodKey = resolveKey(Object.keys(pathItem), method);
|
|
171
|
+
if (!methodKey || !_chunkZD7R5BNEcjs.supportedMethods.includes(methodKey.toLowerCase())) {
|
|
172
|
+
throw new Error(`Operation \`${method} ${path}\` not found.`);
|
|
173
|
+
}
|
|
174
|
+
const operation = pathItem[methodKey];
|
|
175
|
+
const rootPointer = `/paths/${_chunkZD7R5BNEcjs.encodePointer.call(void 0, pathKey)}/${methodKey}`;
|
|
176
|
+
const extraPointers = [];
|
|
177
|
+
const seeds = new Set(_chunkZD7R5BNEcjs.collectRefsInSchema.call(void 0, operation));
|
|
178
|
+
if (pathItem.parameters) {
|
|
179
|
+
extraPointers.push(`/paths/${_chunkZD7R5BNEcjs.encodePointer.call(void 0, pathKey)}/parameters`);
|
|
180
|
+
_chunkZD7R5BNEcjs.collectRefsInSchema.call(void 0, pathItem.parameters).forEach((ref) => seeds.add(ref));
|
|
181
|
+
}
|
|
182
|
+
const security = "security" in operation ? operation.security : definition.security;
|
|
183
|
+
collectSecuritySchemeRefs(security).forEach((ref) => seeds.add(ref));
|
|
184
|
+
const reachableRefs = accumulateReachableRefs(definition, seeds);
|
|
185
|
+
return { rootPointer, extraPointers, reachableRefs, ...buildAnchors(rootPointer, extraPointers, reachableRefs) };
|
|
186
|
+
}
|
|
187
|
+
function computeWebhookScope(definition, webhookName, method) {
|
|
188
|
+
const webhooks2 = "webhooks" in definition ? definition.webhooks : {};
|
|
189
|
+
const webhookKey = resolveKey(Object.keys(webhooks2 || {}), webhookName);
|
|
190
|
+
if (!webhookKey) {
|
|
191
|
+
throw new Error(`Webhook \`${webhookName}\` not found.`);
|
|
192
|
+
}
|
|
193
|
+
const webhook = webhooks2[webhookKey] || {};
|
|
194
|
+
const methodKey = resolveKey(Object.keys(webhook), method);
|
|
195
|
+
if (!methodKey || !_chunkZD7R5BNEcjs.supportedMethods.includes(methodKey.toLowerCase())) {
|
|
196
|
+
throw new Error(`Webhook operation \`${method} ${webhookName}\` not found.`);
|
|
197
|
+
}
|
|
198
|
+
const operation = webhook[methodKey];
|
|
199
|
+
const rootPointer = `/webhooks/${_chunkZD7R5BNEcjs.encodePointer.call(void 0, webhookKey)}/${methodKey}`;
|
|
200
|
+
const extraPointers = [];
|
|
201
|
+
const seeds = new Set(_chunkZD7R5BNEcjs.collectRefsInSchema.call(void 0, operation));
|
|
202
|
+
if (webhook.parameters) {
|
|
203
|
+
extraPointers.push(`/webhooks/${_chunkZD7R5BNEcjs.encodePointer.call(void 0, webhookKey)}/parameters`);
|
|
204
|
+
_chunkZD7R5BNEcjs.collectRefsInSchema.call(void 0, webhook.parameters).forEach((ref) => seeds.add(ref));
|
|
205
|
+
}
|
|
206
|
+
const security = "security" in operation ? operation.security : definition.security;
|
|
207
|
+
collectSecuritySchemeRefs(security).forEach((ref) => seeds.add(ref));
|
|
208
|
+
const reachableRefs = accumulateReachableRefs(definition, seeds);
|
|
209
|
+
return { rootPointer, extraPointers, reachableRefs, ...buildAnchors(rootPointer, extraPointers, reachableRefs) };
|
|
92
210
|
}
|
|
93
|
-
function
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
}
|
|
99
|
-
function fileSize(definition, definitionDereferenced) {
|
|
100
|
-
const originalSizeInBytes = Buffer.from(JSON.stringify(definition)).length;
|
|
101
|
-
const raw = Number((originalSizeInBytes / (1024 * 1024)).toFixed(2));
|
|
102
|
-
let dereferenced;
|
|
103
|
-
try {
|
|
104
|
-
const dereferencedSizeInBytes = Buffer.from(JSON.stringify(definitionDereferenced)).length;
|
|
105
|
-
dereferenced = Number((dereferencedSizeInBytes / (1024 * 1024)).toFixed(2));
|
|
106
|
-
} catch (err) {
|
|
107
|
-
if (err instanceof RangeError) {
|
|
108
|
-
dereferenced = NaN;
|
|
109
|
-
} else {
|
|
110
|
-
throw err;
|
|
211
|
+
function isPointerInScope(pointer, scope) {
|
|
212
|
+
const { anchors, anchorPrefixes } = scope;
|
|
213
|
+
for (let i = 0; i < anchors.length; i += 1) {
|
|
214
|
+
if (pointer === anchors[i] || pointer.startsWith(anchorPrefixes[i])) {
|
|
215
|
+
return true;
|
|
111
216
|
}
|
|
112
217
|
}
|
|
113
|
-
return
|
|
218
|
+
return false;
|
|
219
|
+
}
|
|
220
|
+
function isAncestorOfScope(pointer, scope) {
|
|
221
|
+
return scope.rootPointer === pointer || scope.rootPointer.startsWith(`${pointer}/`);
|
|
222
|
+
}
|
|
223
|
+
|
|
224
|
+
// src/analyzer/queries/openapi.ts
|
|
225
|
+
function filterByScope(results, scope) {
|
|
226
|
+
if (!scope) {
|
|
227
|
+
return results;
|
|
228
|
+
}
|
|
229
|
+
return results.filter((res) => isPointerInScope(res.pointer, scope));
|
|
230
|
+
}
|
|
231
|
+
function additionalProperties(definition, scope) {
|
|
232
|
+
return filterByScope(queryCached(["$..additionalProperties"], definition), scope).map(
|
|
233
|
+
(res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer)
|
|
234
|
+
);
|
|
235
|
+
}
|
|
236
|
+
function callbacks(definition, scope) {
|
|
237
|
+
return filterByScope(
|
|
238
|
+
queryCached(["$.components.callbacks", "$.paths.*[?(@.callbacks)].callbacks"], definition),
|
|
239
|
+
scope
|
|
240
|
+
).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
241
|
+
}
|
|
242
|
+
function commonParameters(definition, scope) {
|
|
243
|
+
return filterByScope(queryCached(["$..paths[*].parameters"], definition), scope).map(
|
|
244
|
+
(res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer)
|
|
245
|
+
);
|
|
246
|
+
}
|
|
247
|
+
function discriminators(definition, scope) {
|
|
248
|
+
return filterByScope(queryCached(["$..discriminator"], definition), scope).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
114
249
|
}
|
|
115
|
-
function links(definition) {
|
|
116
|
-
return
|
|
250
|
+
function links(definition, scope) {
|
|
251
|
+
return filterByScope(queryCached(["$.components.links", "$.paths..responses.*.links"], definition), scope).map(
|
|
252
|
+
(res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer)
|
|
253
|
+
);
|
|
117
254
|
}
|
|
118
|
-
function mediaTypes(definition) {
|
|
255
|
+
function mediaTypes(definition, scope) {
|
|
119
256
|
const results = Array.from(
|
|
120
257
|
new Set(
|
|
121
|
-
|
|
258
|
+
filterByScope(
|
|
259
|
+
queryCached(
|
|
260
|
+
[
|
|
261
|
+
"$..paths..content",
|
|
262
|
+
"$.components.requestBodies..content",
|
|
263
|
+
"$.components.responses..content",
|
|
264
|
+
"$.webhooks..content"
|
|
265
|
+
],
|
|
266
|
+
definition
|
|
267
|
+
),
|
|
268
|
+
scope
|
|
269
|
+
).flatMap((res) => {
|
|
122
270
|
return Object.keys(res.value);
|
|
123
271
|
})
|
|
124
272
|
)
|
|
@@ -126,185 +274,234 @@ function mediaTypes(definition) {
|
|
|
126
274
|
results.sort();
|
|
127
275
|
return results;
|
|
128
276
|
}
|
|
129
|
-
function parameterSerialization(definition) {
|
|
130
|
-
return
|
|
277
|
+
function parameterSerialization(definition, scope) {
|
|
278
|
+
return filterByScope(queryCached(["$..parameters[*].style^"], definition), scope).map(
|
|
279
|
+
(res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer)
|
|
280
|
+
);
|
|
131
281
|
}
|
|
132
|
-
function polymorphism(definition) {
|
|
282
|
+
function polymorphism(definition, scope) {
|
|
133
283
|
const results = Array.from(
|
|
134
|
-
new Set(
|
|
284
|
+
new Set(
|
|
285
|
+
filterByScope(queryCached(["$..allOf^", "$..anyOf^", "$..oneOf^"], definition), scope).map(
|
|
286
|
+
(res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer)
|
|
287
|
+
)
|
|
288
|
+
)
|
|
135
289
|
);
|
|
136
290
|
results.sort();
|
|
137
291
|
return results;
|
|
138
292
|
}
|
|
139
|
-
function references(definition) {
|
|
140
|
-
return
|
|
293
|
+
function references(definition, scope) {
|
|
294
|
+
return filterByScope(queryCached(["$..$ref^"], definition), scope).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
141
295
|
}
|
|
142
|
-
function securityTypes(definition) {
|
|
143
|
-
return Array.from(
|
|
296
|
+
function securityTypes(definition, scope) {
|
|
297
|
+
return Array.from(
|
|
298
|
+
new Set(
|
|
299
|
+
filterByScope(queryCached(["$.components.securitySchemes..type"], definition), scope).map(
|
|
300
|
+
(res) => res.value
|
|
301
|
+
)
|
|
302
|
+
)
|
|
303
|
+
);
|
|
144
304
|
}
|
|
145
305
|
function serverVariables(definition) {
|
|
146
|
-
return
|
|
306
|
+
return queryCached(["$.servers..variables^"], definition).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
147
307
|
}
|
|
148
308
|
function totalOperations(definition) {
|
|
149
|
-
return
|
|
150
|
-
}
|
|
151
|
-
function webhooks(definition) {
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
309
|
+
return queryCached(["$..paths[*]"], definition).flatMap((res) => Object.keys(res.value)).length;
|
|
310
|
+
}
|
|
311
|
+
function webhooks(definition, scope) {
|
|
312
|
+
const results = queryCached(["$.webhooks[*]"], definition);
|
|
313
|
+
if (!scope) {
|
|
314
|
+
return results.map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
315
|
+
}
|
|
316
|
+
return results.filter((res) => isPointerInScope(res.pointer, scope) || isAncestorOfScope(res.pointer, scope)).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
317
|
+
}
|
|
318
|
+
function xmlRequests(definition, scope) {
|
|
319
|
+
return filterByScope(
|
|
320
|
+
queryCached(
|
|
321
|
+
[
|
|
322
|
+
"$..requestBody..['application/xml']",
|
|
323
|
+
"$..requestBody..['application/xml-external-parsed-entity']",
|
|
324
|
+
"$..requestBody..['application/xml-dtd']",
|
|
325
|
+
"$..requestBody..['text/xml']",
|
|
326
|
+
"$..requestBody..['text/xml-external-parsed-entity']",
|
|
327
|
+
"$..requestBody.content[?(@property.match(/\\+xml$/i))]"
|
|
328
|
+
],
|
|
329
|
+
definition
|
|
330
|
+
),
|
|
331
|
+
scope
|
|
332
|
+
).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
333
|
+
}
|
|
334
|
+
function xmlResponses(definition, scope) {
|
|
335
|
+
return filterByScope(
|
|
336
|
+
queryCached(
|
|
337
|
+
[
|
|
338
|
+
"$..responses..['application/xml']",
|
|
339
|
+
"$..responses..['application/xml-external-parsed-entity']",
|
|
340
|
+
"$..responses..['application/xml-dtd']",
|
|
341
|
+
"$..responses..['text/xml']",
|
|
342
|
+
"$..responses..['text/xml-external-parsed-entity']",
|
|
343
|
+
"$..responses[*].content[?(@property.match(/\\+xml$/i))]"
|
|
344
|
+
],
|
|
345
|
+
definition
|
|
346
|
+
),
|
|
347
|
+
scope
|
|
348
|
+
).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
349
|
+
}
|
|
350
|
+
function xmlSchemas(definition, scope) {
|
|
351
|
+
return filterByScope(
|
|
352
|
+
queryCached(["$.components.schemas..xml^", "$..parameters..xml^", "$..requestBody..xml^"], definition),
|
|
353
|
+
scope
|
|
354
|
+
).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
|
|
184
355
|
}
|
|
185
356
|
|
|
186
357
|
// src/analyzer/index.ts
|
|
187
|
-
async function
|
|
188
|
-
const
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
|
|
286
|
-
|
|
358
|
+
async function buildAnalysis(definition, query2, scope) {
|
|
359
|
+
const analysis = {};
|
|
360
|
+
if (!query2 || query2.includes("mediaTypes")) {
|
|
361
|
+
analysis.mediaTypes = {
|
|
362
|
+
name: "Media Type",
|
|
363
|
+
found: mediaTypes(definition, scope)
|
|
364
|
+
};
|
|
365
|
+
}
|
|
366
|
+
if (!query2 || query2.includes("operationTotal")) {
|
|
367
|
+
analysis.operationTotal = {
|
|
368
|
+
name: "Operation",
|
|
369
|
+
// A scoped analysis is, by definition, looking at exactly one operation.
|
|
370
|
+
found: scope ? 1 : totalOperations(definition)
|
|
371
|
+
};
|
|
372
|
+
}
|
|
373
|
+
if (!query2 || query2.includes("securityTypes")) {
|
|
374
|
+
analysis.securityTypes = {
|
|
375
|
+
name: "Security Type",
|
|
376
|
+
found: securityTypes(definition, scope)
|
|
377
|
+
};
|
|
378
|
+
}
|
|
379
|
+
if (!query2 || query2.includes("additionalProperties")) {
|
|
380
|
+
const additionalProperties2 = additionalProperties(definition, scope);
|
|
381
|
+
analysis.additionalProperties = {
|
|
382
|
+
present: !!additionalProperties2.length,
|
|
383
|
+
locations: additionalProperties2
|
|
384
|
+
};
|
|
385
|
+
}
|
|
386
|
+
if (!query2 || query2.includes("callbacks")) {
|
|
387
|
+
const callbacks2 = callbacks(definition, scope);
|
|
388
|
+
analysis.callbacks = {
|
|
389
|
+
present: !!callbacks2.length,
|
|
390
|
+
locations: callbacks2
|
|
391
|
+
};
|
|
392
|
+
}
|
|
393
|
+
if (!query2 || query2.includes("circularRefs")) {
|
|
394
|
+
const { circularRefs: dereferencedCircularRefs } = await dereferenceOasShared(definition);
|
|
395
|
+
const circularRefs = (scope ? dereferencedCircularRefs.filter((ref) => isPointerInScope(_chunkZD7R5BNEcjs.toPointer.call(void 0, ref), scope)) : [...dereferencedCircularRefs]).toSorted();
|
|
396
|
+
analysis.circularRefs = {
|
|
397
|
+
present: !!circularRefs.length,
|
|
398
|
+
locations: circularRefs
|
|
399
|
+
};
|
|
400
|
+
}
|
|
401
|
+
if (!query2 || query2.includes("commonParameters")) {
|
|
402
|
+
const commonParameters2 = commonParameters(definition, scope);
|
|
403
|
+
analysis.commonParameters = {
|
|
404
|
+
present: !!commonParameters2.length,
|
|
405
|
+
locations: commonParameters2
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
if (!query2 || query2.includes("discriminators")) {
|
|
409
|
+
const discriminators2 = discriminators(definition, scope);
|
|
410
|
+
analysis.discriminators = {
|
|
411
|
+
present: !!discriminators2.length,
|
|
412
|
+
locations: discriminators2
|
|
413
|
+
};
|
|
414
|
+
}
|
|
415
|
+
if (!query2 || query2.includes("links")) {
|
|
416
|
+
const links2 = links(definition, scope);
|
|
417
|
+
analysis.links = {
|
|
418
|
+
present: !!links2.length,
|
|
419
|
+
locations: links2
|
|
420
|
+
};
|
|
421
|
+
}
|
|
422
|
+
if (!query2 || query2.includes("style")) {
|
|
423
|
+
const parameterSerialization2 = parameterSerialization(definition, scope);
|
|
424
|
+
analysis.style = {
|
|
425
|
+
present: !!parameterSerialization2.length,
|
|
426
|
+
locations: parameterSerialization2
|
|
427
|
+
};
|
|
428
|
+
}
|
|
429
|
+
if (!query2 || query2.includes("polymorphism")) {
|
|
430
|
+
const polymorphism2 = polymorphism(definition, scope);
|
|
431
|
+
analysis.polymorphism = {
|
|
432
|
+
present: !!polymorphism2.length,
|
|
433
|
+
locations: polymorphism2
|
|
434
|
+
};
|
|
435
|
+
}
|
|
436
|
+
if (!query2 || query2.includes("references")) {
|
|
437
|
+
const references2 = references(definition, scope);
|
|
438
|
+
analysis.references = {
|
|
439
|
+
present: !!references2.length,
|
|
440
|
+
locations: references2
|
|
441
|
+
};
|
|
442
|
+
}
|
|
443
|
+
if (!query2 || query2.includes("serverVariables")) {
|
|
444
|
+
const serverVariables2 = serverVariables(definition);
|
|
445
|
+
analysis.serverVariables = {
|
|
446
|
+
present: !!serverVariables2.length,
|
|
447
|
+
locations: serverVariables2
|
|
448
|
+
};
|
|
449
|
+
}
|
|
450
|
+
if (!query2 || query2.includes("xmlRequests")) {
|
|
451
|
+
const xmlRequests2 = xmlRequests(definition, scope);
|
|
452
|
+
analysis.xmlRequests = {
|
|
453
|
+
present: !!xmlRequests2.length,
|
|
454
|
+
locations: xmlRequests2
|
|
455
|
+
};
|
|
456
|
+
}
|
|
457
|
+
if (!query2 || query2.includes("xmlResponses")) {
|
|
458
|
+
const xmlResponses2 = xmlResponses(definition, scope);
|
|
459
|
+
analysis.xmlResponses = {
|
|
460
|
+
present: !!xmlResponses2.length,
|
|
461
|
+
locations: xmlResponses2
|
|
462
|
+
};
|
|
463
|
+
}
|
|
464
|
+
if (!query2 || query2.includes("xmlSchemas")) {
|
|
465
|
+
const xmlSchemas2 = xmlSchemas(definition, scope);
|
|
466
|
+
analysis.xmlSchemas = {
|
|
467
|
+
present: !!xmlSchemas2.length,
|
|
468
|
+
locations: xmlSchemas2
|
|
469
|
+
};
|
|
470
|
+
}
|
|
471
|
+
if (!query2 || query2.includes("xmlSchemas")) {
|
|
472
|
+
const webhooks2 = webhooks(definition, scope);
|
|
473
|
+
analysis.webhooks = {
|
|
474
|
+
present: !!webhooks2.length,
|
|
475
|
+
locations: webhooks2
|
|
476
|
+
};
|
|
477
|
+
}
|
|
287
478
|
return analysis;
|
|
288
479
|
}
|
|
480
|
+
async function analyzer(definition, query2) {
|
|
481
|
+
return buildAnalysis(definition, query2);
|
|
482
|
+
}
|
|
483
|
+
async function analyzeOperation(definition, {
|
|
484
|
+
path,
|
|
485
|
+
method,
|
|
486
|
+
query: query2
|
|
487
|
+
}) {
|
|
488
|
+
const scope = computeOperationScope(definition, path, method);
|
|
489
|
+
return buildAnalysis(definition, query2, scope);
|
|
490
|
+
}
|
|
491
|
+
async function analyzeWebhookOperation(definition, {
|
|
492
|
+
webhookName,
|
|
493
|
+
method,
|
|
494
|
+
query: query2
|
|
495
|
+
}) {
|
|
496
|
+
if (!_chunk7PWF3F2Wcjs.isOpenAPI31.call(void 0, definition)) {
|
|
497
|
+
throw new TypeError("The supplied definition is not a OpenAPI 3.1 definition.");
|
|
498
|
+
}
|
|
499
|
+
const scope = computeWebhookScope(definition, webhookName, method);
|
|
500
|
+
return buildAnalysis(definition, query2, scope);
|
|
501
|
+
}
|
|
289
502
|
|
|
290
503
|
|
|
291
504
|
|
|
292
505
|
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
exports.analyzeAdditionalProperties = additionalProperties; exports.analyzeCallbacks = callbacks; exports.analyzeCircularRefs = circularRefs; exports.analyzeCommonParameters = commonParameters; exports.analyzeDiscriminators = discriminators; exports.analyzeFileSize = fileSize; exports.analyzeLinks = links; exports.analyzeMediaTypes = mediaTypes; exports.analyzeParameterSerialization = parameterSerialization; exports.analyzePolymorphism = polymorphism; exports.analyzeReferences = references; exports.analyzeSecurityTypes = securityTypes; exports.analyzeServerVariables = serverVariables; exports.analyzeTotalOperations = totalOperations; exports.analyzeWebhooks = webhooks; exports.analyzeXMLRequests = xmlRequests; exports.analyzeXMLResponses = xmlResponses; exports.analyzeXMLSchemas = xmlSchemas; exports.analyzer = analyzer;
|
|
506
|
+
exports.analyzeOperation = analyzeOperation; exports.analyzeWebhookOperation = analyzeWebhookOperation; exports.analyzer = analyzer;
|
|
310
507
|
//# sourceMappingURL=index.cjs.map
|