oas 37.2.0 → 38.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (40) hide show
  1. package/README.md +13 -3
  2. package/dist/analyzer/index.cjs +400 -203
  3. package/dist/analyzer/index.cjs.map +1 -1
  4. package/dist/analyzer/index.d.cts +23 -129
  5. package/dist/analyzer/index.d.ts +23 -129
  6. package/dist/analyzer/index.js +395 -198
  7. package/dist/analyzer/index.js.map +1 -1
  8. package/dist/analyzer/types.cjs +26 -1
  9. package/dist/analyzer/types.cjs.map +1 -1
  10. package/dist/analyzer/types.d.cts +20 -24
  11. package/dist/analyzer/types.d.ts +20 -24
  12. package/dist/analyzer/types.js +25 -0
  13. package/dist/analyzer/types.js.map +1 -1
  14. package/dist/{chunk-W6GBV2JT.cjs → chunk-COHEPMUP.cjs} +1 -1
  15. package/dist/chunk-COHEPMUP.cjs.map +1 -0
  16. package/dist/{chunk-CKC36IL7.js → chunk-QTPMJRIE.js} +1 -1
  17. package/dist/chunk-QTPMJRIE.js.map +1 -0
  18. package/dist/{chunk-6QP66C5V.js → chunk-VSILRJVM.js} +6 -1
  19. package/dist/chunk-VSILRJVM.js.map +1 -0
  20. package/dist/{chunk-LOR5XCEP.js → chunk-XTE5ZNGQ.js} +2 -2
  21. package/dist/{chunk-YCSVUVAC.cjs → chunk-YFZN44KB.cjs} +70 -70
  22. package/dist/{chunk-YCSVUVAC.cjs.map → chunk-YFZN44KB.cjs.map} +1 -1
  23. package/dist/{chunk-GPOPN7TQ.cjs → chunk-ZD7R5BNE.cjs} +7 -2
  24. package/dist/chunk-ZD7R5BNE.cjs.map +1 -0
  25. package/dist/index.cjs +36 -27
  26. package/dist/index.cjs.map +1 -1
  27. package/dist/index.js +11 -2
  28. package/dist/index.js.map +1 -1
  29. package/dist/operation/index.cjs +3 -3
  30. package/dist/operation/index.js +2 -2
  31. package/dist/reducer/index.cjs +9 -9
  32. package/dist/reducer/index.js +2 -2
  33. package/dist/utils.cjs +2 -2
  34. package/dist/utils.js +1 -1
  35. package/package.json +1 -1
  36. package/dist/chunk-6QP66C5V.js.map +0 -1
  37. package/dist/chunk-CKC36IL7.js.map +0 -1
  38. package/dist/chunk-GPOPN7TQ.cjs.map +0 -1
  39. package/dist/chunk-W6GBV2JT.cjs.map +0 -1
  40. /package/dist/{chunk-LOR5XCEP.js.map → chunk-XTE5ZNGQ.js.map} +0 -0
@@ -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 _chunkW6GBV2JTcjs = require('../chunk-W6GBV2JT.cjs');
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(circularRefs2) {
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
- circularRefs2.add(`#${path.split("#")[1]}`);
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 circularRefs2 = /* @__PURE__ */ new Set();
51
- const dereferencingOptions = getDereferencingOptions(circularRefs2);
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: [...circularRefs2]
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/queries/openapi.ts
79
- function additionalProperties(definition) {
80
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$..additionalProperties"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
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
- function callbacks(definition) {
83
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$.components.callbacks", "$.paths.*[?(@.callbacks)].callbacks"], definition).map(
84
- (res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer)
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
- async function circularRefs(definition) {
88
- const { circularRefs: refs } = await dereferenceOas(structuredClone(definition));
89
- const results = [...refs];
90
- results.sort();
91
- return results;
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 commonParameters(definition) {
94
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$..paths[*].parameters"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
95
- }
96
- function discriminators(definition) {
97
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$..discriminator"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
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 { raw, dereferenced };
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 _chunkW6GBV2JTcjs.query.call(void 0, ["$.components.links", "$.paths..responses.*.links"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
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
- _chunkW6GBV2JTcjs.query.call(void 0, ["$..paths..content"], definition).flatMap((res) => {
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 _chunkW6GBV2JTcjs.query.call(void 0, ["$..parameters[*].style^"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
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(_chunkW6GBV2JTcjs.query.call(void 0, ["$..allOf^", "$..anyOf^", "$..oneOf^"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer)))
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 _chunkW6GBV2JTcjs.query.call(void 0, ["$..$ref^"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
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(new Set(_chunkW6GBV2JTcjs.query.call(void 0, ["$.components.securitySchemes..type"], definition).map((res) => res.value)));
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 _chunkW6GBV2JTcjs.query.call(void 0, ["$.servers..variables^"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
306
+ return queryCached(["$.servers..variables^"], definition).map((res) => _chunkCOHEPMUPcjs.refizePointer.call(void 0, res.pointer));
147
307
  }
148
308
  function totalOperations(definition) {
149
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$..paths[*]"], definition).flatMap((res) => Object.keys(res.value)).length;
150
- }
151
- function webhooks(definition) {
152
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$.webhooks[*]"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
153
- }
154
- function xmlRequests(definition) {
155
- return _chunkW6GBV2JTcjs.query.call(void 0,
156
- [
157
- "$..requestBody..['application/xml']",
158
- "$..requestBody..['application/xml-external-parsed-entity']",
159
- "$..requestBody..['application/xml-dtd']",
160
- "$..requestBody..['text/xml']",
161
- "$..requestBody..['text/xml-external-parsed-entity']",
162
- "$..requestBody.content[?(@property.match(/\\+xml$/i))]"
163
- ],
164
- definition
165
- ).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
166
- }
167
- function xmlResponses(definition) {
168
- return _chunkW6GBV2JTcjs.query.call(void 0,
169
- [
170
- "$..responses..['application/xml']",
171
- "$..responses..['application/xml-external-parsed-entity']",
172
- "$..responses..['application/xml-dtd']",
173
- "$..responses..['text/xml']",
174
- "$..responses..['text/xml-external-parsed-entity']",
175
- "$..responses[*].content[?(@property.match(/\\+xml$/i))]"
176
- ],
177
- definition
178
- ).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
179
- }
180
- function xmlSchemas(definition) {
181
- return _chunkW6GBV2JTcjs.query.call(void 0, ["$.components.schemas..xml^", "$..parameters..xml^", "$..requestBody..xml^"], definition).map(
182
- (res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer)
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 analyzer(definition) {
188
- const clonedDefinition = structuredClone(definition);
189
- const { api: dereferencedApi, circularRefs: dereferencedCircularRefs } = await dereferenceOas(clonedDefinition);
190
- const additionalProperties2 = additionalProperties(definition);
191
- const callbacks2 = callbacks(definition);
192
- const circularRefs2 = [...dereferencedCircularRefs].toSorted();
193
- const commonParameters2 = commonParameters(definition);
194
- const discriminators2 = discriminators(definition);
195
- const { raw: rawFileSize, dereferenced: dereferencedFileSize } = fileSize(definition, dereferencedApi);
196
- const links2 = links(definition);
197
- const parameterSerialization2 = parameterSerialization(definition);
198
- const polymorphism2 = polymorphism(definition);
199
- const references2 = references(definition);
200
- const serverVariables2 = serverVariables(definition);
201
- const xmlSchemas2 = xmlSchemas(definition);
202
- const xmlRequests2 = xmlRequests(definition);
203
- const xmlResponses2 = xmlResponses(definition);
204
- const webhooks2 = webhooks(definition);
205
- const analysis = {
206
- general: {
207
- dereferencedFileSize: {
208
- name: "Dereferenced File Size",
209
- found: dereferencedFileSize
210
- },
211
- mediaTypes: {
212
- name: "Media Type",
213
- found: mediaTypes(definition)
214
- },
215
- operationTotal: {
216
- name: "Operation",
217
- found: totalOperations(definition)
218
- },
219
- rawFileSize: {
220
- name: "Raw File Size",
221
- found: rawFileSize
222
- },
223
- securityTypes: {
224
- name: "Security Type",
225
- found: securityTypes(definition)
226
- }
227
- },
228
- openapi: {
229
- additionalProperties: {
230
- present: !!additionalProperties2.length,
231
- locations: additionalProperties2
232
- },
233
- callbacks: {
234
- present: !!callbacks2.length,
235
- locations: callbacks2
236
- },
237
- circularRefs: {
238
- present: !!circularRefs2.length,
239
- locations: circularRefs2
240
- },
241
- commonParameters: {
242
- present: !!commonParameters2.length,
243
- locations: commonParameters2
244
- },
245
- discriminators: {
246
- present: !!discriminators2.length,
247
- locations: discriminators2
248
- },
249
- links: {
250
- present: !!links2.length,
251
- locations: links2
252
- },
253
- style: {
254
- present: !!parameterSerialization2.length,
255
- locations: parameterSerialization2
256
- },
257
- polymorphism: {
258
- present: !!polymorphism2.length,
259
- locations: polymorphism2
260
- },
261
- references: {
262
- present: !!references2.length,
263
- locations: references2
264
- },
265
- serverVariables: {
266
- present: !!serverVariables2.length,
267
- locations: serverVariables2
268
- },
269
- xmlRequests: {
270
- present: !!xmlRequests2.length,
271
- locations: xmlRequests2
272
- },
273
- xmlResponses: {
274
- present: !!xmlResponses2.length,
275
- locations: xmlResponses2
276
- },
277
- xmlSchemas: {
278
- present: !!xmlSchemas2.length,
279
- locations: xmlSchemas2
280
- },
281
- webhooks: {
282
- present: !!webhooks2.length,
283
- locations: webhooks2
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