oas 31.1.2 → 32.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.
Files changed (70) hide show
  1. package/README.md +5 -0
  2. package/dist/analyzer/index.cjs +6 -7
  3. package/dist/analyzer/index.cjs.map +1 -1
  4. package/dist/analyzer/index.js +5 -6
  5. package/dist/analyzer/index.js.map +1 -1
  6. package/dist/{chunk-LSH3X5NA.js → chunk-4JRU2N6C.js} +85 -48
  7. package/dist/chunk-4JRU2N6C.js.map +1 -0
  8. package/dist/{chunk-SYZDNSG6.cjs → chunk-7H5IXVWY.cjs} +104 -67
  9. package/dist/chunk-7H5IXVWY.cjs.map +1 -0
  10. package/dist/{chunk-B5WP4BJM.cjs → chunk-7RDMAMMI.cjs} +511 -240
  11. package/dist/chunk-7RDMAMMI.cjs.map +1 -0
  12. package/dist/{chunk-BRYRBTD7.cjs → chunk-AQUZF2EA.cjs} +483 -368
  13. package/dist/chunk-AQUZF2EA.cjs.map +1 -0
  14. package/dist/{chunk-5EP6HY2E.js → chunk-HYH37HS2.js} +494 -223
  15. package/dist/chunk-HYH37HS2.js.map +1 -0
  16. package/dist/{chunk-7MARUOFZ.js → chunk-MNOEMVCF.js} +2 -2
  17. package/dist/chunk-MNOEMVCF.js.map +1 -0
  18. package/dist/{chunk-HGVFNEKW.js → chunk-ORCSXEZP.js} +422 -307
  19. package/dist/chunk-ORCSXEZP.js.map +1 -0
  20. package/dist/chunk-YPR7YTHM.cjs +24 -0
  21. package/dist/chunk-YPR7YTHM.cjs.map +1 -0
  22. package/dist/extensions.d.cts +3 -1
  23. package/dist/extensions.d.ts +3 -1
  24. package/dist/get-parameters-as-json-schema-BH81ZOnw.d.ts +36 -0
  25. package/dist/get-parameters-as-json-schema-DM1vWIEM.d.cts +36 -0
  26. package/dist/index.cjs +5 -6
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +947 -7
  29. package/dist/index.d.ts +946 -8
  30. package/dist/index.js +4 -5
  31. package/dist/operation/index.cjs +4 -5
  32. package/dist/operation/index.cjs.map +1 -1
  33. package/dist/operation/index.d.cts +3 -1
  34. package/dist/operation/index.d.ts +3 -1
  35. package/dist/operation/index.js +3 -4
  36. package/dist/reducer/index.cjs +16 -18
  37. package/dist/reducer/index.cjs.map +1 -1
  38. package/dist/reducer/index.js +4 -6
  39. package/dist/reducer/index.js.map +1 -1
  40. package/dist/types.cjs +2 -2
  41. package/dist/types.d.cts +9 -1
  42. package/dist/types.d.ts +9 -1
  43. package/dist/types.js +1 -1
  44. package/dist/utils.cjs +4 -4
  45. package/dist/utils.cjs.map +1 -1
  46. package/dist/utils.d.cts +17 -3
  47. package/dist/utils.d.ts +17 -3
  48. package/dist/utils.js +5 -5
  49. package/package.json +3 -6
  50. package/dist/chunk-5EP6HY2E.js.map +0 -1
  51. package/dist/chunk-7MARUOFZ.js.map +0 -1
  52. package/dist/chunk-B5WP4BJM.cjs.map +0 -1
  53. package/dist/chunk-BRYRBTD7.cjs.map +0 -1
  54. package/dist/chunk-HGVFNEKW.js.map +0 -1
  55. package/dist/chunk-LSH3X5NA.js.map +0 -1
  56. package/dist/chunk-O3GIPZLC.cjs +0 -9
  57. package/dist/chunk-O3GIPZLC.cjs.map +0 -1
  58. package/dist/chunk-SYZDNSG6.cjs.map +0 -1
  59. package/dist/chunk-VA3NKXX7.js +0 -9
  60. package/dist/chunk-VA3NKXX7.js.map +0 -1
  61. package/dist/chunk-VQBEI5WI.cjs +0 -24
  62. package/dist/chunk-VQBEI5WI.cjs.map +0 -1
  63. package/dist/extensions-9XckV6aO.d.cts +0 -899
  64. package/dist/extensions-gq53-7Ux.d.ts +0 -899
  65. package/dist/operation/lib/get-parameters-as-json-schema.cjs +0 -11
  66. package/dist/operation/lib/get-parameters-as-json-schema.cjs.map +0 -1
  67. package/dist/operation/lib/get-parameters-as-json-schema.d.cts +0 -4
  68. package/dist/operation/lib/get-parameters-as-json-schema.d.ts +0 -4
  69. package/dist/operation/lib/get-parameters-as-json-schema.js +0 -11
  70. package/dist/operation/lib/get-parameters-as-json-schema.js.map +0 -1
@@ -1,6 +1,5 @@
1
- "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; } function _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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 _nullishCoalesce(lhs, rhsFn) { if (lhs != null) { return lhs; } else { return rhsFn(); } } 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; } var _class;
2
2
 
3
- var _chunkO3GIPZLCcjs = require('./chunk-O3GIPZLC.cjs');
4
3
 
5
4
 
6
5
 
@@ -11,125 +10,27 @@ var _chunkO3GIPZLCcjs = require('./chunk-O3GIPZLC.cjs');
11
10
 
12
11
 
13
12
 
14
- var _chunkB5WP4BJMcjs = require('./chunk-B5WP4BJM.cjs');
13
+
14
+
15
+
16
+ var _chunk7RDMAMMIcjs = require('./chunk-7RDMAMMI.cjs');
15
17
 
16
18
 
17
19
  var _chunkAYA3UT4Lcjs = require('./chunk-AYA3UT4L.cjs');
18
20
 
19
21
 
20
- var _chunkVQBEI5WIcjs = require('./chunk-VQBEI5WI.cjs');
22
+ var _chunkYPR7YTHMcjs = require('./chunk-YPR7YTHM.cjs');
21
23
 
22
24
  // src/operation/index.ts
23
25
  var _jsonschemarefparser = require('@apidevtools/json-schema-ref-parser');
24
26
 
25
- // src/lib/build-discriminator-one-of.ts
26
- function hasDiscriminatorWithoutPolymorphism(schema) {
27
- if (!schema || typeof schema !== "object") return false;
28
- if (!("discriminator" in schema)) return false;
29
- if ("oneOf" in schema || "anyOf" in schema) return false;
30
- return true;
31
- }
32
- function allOfReferencesSchema(schema, targetSchemaName) {
33
- if (!schema || typeof schema !== "object") return false;
34
- if (!("allOf" in schema) || !Array.isArray(schema.allOf)) return false;
35
- return schema.allOf.some((item) => {
36
- if (_chunkVQBEI5WIcjs.isRef.call(void 0, item)) {
37
- const refParts = item.$ref.split("/");
38
- const refSchemaName = refParts[refParts.length - 1];
39
- return refSchemaName === targetSchemaName;
40
- }
41
- return false;
42
- });
43
- }
44
- function findDiscriminatorChildren(api) {
45
- const childrenMap = /* @__PURE__ */ new Map();
46
- const invertedChildrenMap = /* @__PURE__ */ new Map();
47
- if (!_optionalChain([api, 'optionalAccess', _2 => _2.components, 'optionalAccess', _3 => _3.schemas]) || typeof api.components.schemas !== "object") {
48
- return { children: childrenMap, inverted: invertedChildrenMap };
49
- }
50
- const schemas = api.components.schemas;
51
- const schemaNames = Object.keys(schemas);
52
- const discriminatorSchemas = schemaNames.filter((name) => {
53
- return hasDiscriminatorWithoutPolymorphism(schemas[name]);
54
- });
55
- for (const baseName of discriminatorSchemas) {
56
- const baseSchema = schemas[baseName];
57
- const discriminator = baseSchema.discriminator;
58
- let childSchemaNames;
59
- if (discriminator.mapping && typeof discriminator.mapping === "object") {
60
- const mappingRefs = Object.values(discriminator.mapping);
61
- if (mappingRefs.length > 0) {
62
- childSchemaNames = mappingRefs.map((ref) => {
63
- const parts = ref.split("/");
64
- return parts[parts.length - 1];
65
- });
66
- }
67
- }
68
- if (!childSchemaNames || childSchemaNames.length === 0) {
69
- childSchemaNames = schemaNames.filter((name) => {
70
- if (name === baseName) return false;
71
- return allOfReferencesSchema(schemas[name], baseName);
72
- });
73
- }
74
- if (childSchemaNames.length > 0) {
75
- childrenMap.set(baseName, childSchemaNames);
76
- }
77
- }
78
- for (const [key, values] of childrenMap) {
79
- for (const value of values) {
80
- if (invertedChildrenMap.has(value)) {
81
- _optionalChain([invertedChildrenMap, 'access', _4 => _4.get, 'call', _5 => _5(value), 'optionalAccess', _6 => _6.push, 'call', _7 => _7(key)]);
82
- } else {
83
- invertedChildrenMap.set(value, [key]);
84
- }
85
- }
86
- }
87
- return { children: childrenMap, inverted: invertedChildrenMap };
88
- }
89
- function buildDiscriminatorOneOf(api, childrenMap) {
90
- if (!_optionalChain([api, 'optionalAccess', _8 => _8.components, 'optionalAccess', _9 => _9.schemas]) || typeof api.components.schemas !== "object") {
91
- return;
92
- } else if (childrenMap.size === 0) {
93
- return;
94
- }
95
- for (const [schemaName, childNames] of childrenMap) {
96
- const schema = api.components.schemas[schemaName];
97
- if (!schema) continue;
98
- const oneOf = [];
99
- for (const childName of childNames) {
100
- if (api.components.schemas[childName]) {
101
- oneOf.push(_chunkB5WP4BJMcjs.cloneObject.call(void 0, api.components.schemas[childName]));
102
- }
103
- }
104
- if (oneOf.length > 0) {
105
- schema.oneOf = oneOf;
106
- }
107
- }
108
- for (const [parentSchemaName, childNames] of childrenMap) {
109
- for (const childName of childNames) {
110
- const childSchema = api.components.schemas[childName];
111
- if (!childSchema || !("allOf" in childSchema) || !Array.isArray(childSchema.allOf)) {
112
- continue;
113
- }
114
- for (let i = 0; i < childSchema.allOf.length; i++) {
115
- const item = childSchema.allOf[i];
116
- if (item && typeof item === "object" && "x-readme-ref-name" in item && item["x-readme-ref-name"] === parentSchemaName && "oneOf" in item) {
117
- const clonedItem = _chunkB5WP4BJMcjs.cloneObject.call(void 0, item);
118
- delete clonedItem.oneOf;
119
- childSchema.allOf[i] = clonedItem;
120
- }
121
- }
122
- }
123
- }
124
- }
125
-
126
27
  // src/operation/lib/dedupe-common-parameters.ts
127
28
  function dedupeCommonParameters(parameters, commonParameters) {
128
29
  return commonParameters.filter((param) => {
129
30
  return !parameters.find((param2) => {
130
31
  if (param.name && param2.name) {
131
32
  return param.name === param2.name && param.in === param2.in;
132
- } else if (_chunkVQBEI5WIcjs.isRef.call(void 0, param) && _chunkVQBEI5WIcjs.isRef.call(void 0, param2)) {
33
+ } else if (_chunkYPR7YTHMcjs.isRef.call(void 0, param) && _chunkYPR7YTHMcjs.isRef.call(void 0, param2)) {
133
34
  return param.$ref === param2.$ref;
134
35
  }
135
36
  return false;
@@ -153,7 +54,7 @@ function usesPolymorphism(schema) {
153
54
  return false;
154
55
  }
155
56
  function objectify(thing) {
156
- if (!_chunkB5WP4BJMcjs.isObject.call(void 0, thing)) {
57
+ if (!_chunk7RDMAMMIcjs.isObject.call(void 0, thing)) {
157
58
  return {};
158
59
  }
159
60
  return thing;
@@ -273,16 +174,16 @@ function sampleFromSchema(schema, opts = {}) {
273
174
  const props = objectify(properties);
274
175
  const obj = {};
275
176
  for (const name in props) {
276
- if (_optionalChain([props, 'optionalAccess', _10 => _10[name], 'access', _11 => _11.deprecated])) {
177
+ if (_optionalChain([props, 'optionalAccess', _2 => _2[name], 'access', _3 => _3.deprecated])) {
277
178
  continue;
278
179
  }
279
- if (_optionalChain([props, 'optionalAccess', _12 => _12[name], 'access', _13 => _13.readOnly]) && !includeReadOnly) {
180
+ if (_optionalChain([props, 'optionalAccess', _4 => _4[name], 'access', _5 => _5.readOnly]) && !includeReadOnly) {
280
181
  continue;
281
182
  }
282
- if (_optionalChain([props, 'optionalAccess', _14 => _14[name], 'access', _15 => _15.writeOnly]) && !includeWriteOnly) {
183
+ if (_optionalChain([props, 'optionalAccess', _6 => _6[name], 'access', _7 => _7.writeOnly]) && !includeWriteOnly) {
283
184
  continue;
284
185
  }
285
- if (_optionalChain([props, 'access', _16 => _16[name], 'access', _17 => _17.examples, 'optionalAccess', _18 => _18.length])) {
186
+ if (_optionalChain([props, 'access', _8 => _8[name], 'access', _9 => _9.examples, 'optionalAccess', _10 => _10.length])) {
286
187
  obj[name] = props[name].examples[0];
287
188
  continue;
288
189
  }
@@ -362,7 +263,7 @@ function getMediaTypeExamples(mediaType, mediaTypeObject, opts = {}) {
362
263
  }
363
264
  }
364
265
  if (mediaTypeObject.schema) {
365
- if (!_chunkB5WP4BJMcjs.matches_mimetype_default.xml(mediaType)) {
266
+ if (!_chunk7RDMAMMIcjs.matches_mimetype_default.xml(mediaType)) {
366
267
  return [
367
268
  {
368
269
  value: samples_default(JSON.parse(JSON.stringify(mediaTypeObject.schema)), opts)
@@ -374,17 +275,19 @@ function getMediaTypeExamples(mediaType, mediaTypeObject, opts = {}) {
374
275
  }
375
276
 
376
277
  // src/operation/lib/get-response-examples.ts
377
- function getResponseExamples(operation) {
278
+ function getResponseExamples(operation, definition) {
378
279
  return Object.keys(operation.responses || {}).map((status) => {
379
- const response = _optionalChain([operation, 'access', _19 => _19.responses, 'optionalAccess', _20 => _20[status]]);
280
+ let response = _optionalChain([operation, 'access', _11 => _11.responses, 'optionalAccess', _12 => _12[status]]);
380
281
  let onlyHeaders = false;
381
- if (!response || _chunkVQBEI5WIcjs.isRef.call(void 0, response)) {
382
- return false;
282
+ if (!response) return false;
283
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
284
+ response = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, response, definition);
285
+ if (!response || _chunkYPR7YTHMcjs.isRef.call(void 0, response)) return false;
383
286
  }
384
287
  const mediaTypes = {};
385
- (_optionalChain([response, 'optionalAccess', _21 => _21.content]) ? Object.keys(response.content) : []).forEach((mediaType) => {
288
+ (_optionalChain([response, 'optionalAccess', _13 => _13.content]) ? Object.keys(response.content) : []).forEach((mediaType) => {
386
289
  if (!mediaType) return;
387
- const mediaTypeObject = _optionalChain([response, 'access', _22 => _22.content, 'optionalAccess', _23 => _23[mediaType]]);
290
+ const mediaTypeObject = _optionalChain([response, 'access', _14 => _14.content, 'optionalAccess', _15 => _15[mediaType]]);
388
291
  if (!mediaTypeObject) return;
389
292
  const examples = getMediaTypeExamples(mediaType, mediaTypeObject, {
390
293
  includeReadOnly: true,
@@ -410,20 +313,31 @@ function getResponseExamples(operation) {
410
313
  }
411
314
 
412
315
  // src/operation/lib/get-callback-examples.ts
413
- function getCallbackExamples(operation) {
316
+ function getCallbackExamples(operation, definition) {
414
317
  if (!operation.callbacks) {
415
318
  return [];
416
319
  }
417
320
  const examples = Object.keys(operation.callbacks).map((identifier) => {
418
- const callback = _optionalChain([operation, 'access', _24 => _24.callbacks, 'optionalAccess', _25 => _25[identifier]]);
419
- if (!callback || _chunkVQBEI5WIcjs.isRef.call(void 0, callback)) {
420
- return [];
321
+ let callback = _optionalChain([operation, 'access', _16 => _16.callbacks, 'optionalAccess', _17 => _17[identifier]]);
322
+ if (!callback) return [];
323
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, callback)) {
324
+ callback = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, callback, definition);
325
+ if (!callback || _chunkYPR7YTHMcjs.isRef.call(void 0, callback)) return [];
421
326
  }
422
327
  const items = Object.keys(callback).map((expression) => {
423
- return Object.keys(callback[expression]).map((method) => {
424
- const pathItem = callback[expression];
425
- const example = getResponseExamples(pathItem[method]);
426
- if (example.length === 0) return false;
328
+ let callbackPath = callback[expression];
329
+ if (!callbackPath) return [];
330
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, callbackPath)) {
331
+ callbackPath = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, callbackPath, definition);
332
+ if (!callbackPath || _chunkYPR7YTHMcjs.isRef.call(void 0, callbackPath)) return [];
333
+ }
334
+ return Object.keys(callbackPath).map((method) => {
335
+ if (["servers", "parameters", "summary", "description"].includes(method)) {
336
+ return false;
337
+ }
338
+ const pathItem = callbackPath;
339
+ const example = getResponseExamples(pathItem[method], definition);
340
+ if (!example.length) return false;
427
341
  return {
428
342
  identifier,
429
343
  expression,
@@ -464,7 +378,7 @@ function getExampleGroups(operation) {
464
378
  const namelessCodeSampleCounts = {};
465
379
  const groups = {};
466
380
  const codeSamples = _chunkAYA3UT4Lcjs.getExtension.call(void 0, "code-samples", operation.api, operation);
467
- _optionalChain([codeSamples, 'optionalAccess', _26 => _26.forEach, 'call', _27 => _27((sample, i) => {
381
+ _optionalChain([codeSamples, 'optionalAccess', _18 => _18.forEach, 'call', _19 => _19((sample, i) => {
468
382
  if (namelessCodeSampleCounts[sample.language]) {
469
383
  namelessCodeSampleCounts[sample.language] += 1;
470
384
  } else {
@@ -472,7 +386,7 @@ function getExampleGroups(operation) {
472
386
  }
473
387
  const name = getDefaultName(sample, namelessCodeSampleCounts);
474
388
  if (sample.correspondingExample) {
475
- if (_optionalChain([groups, 'access', _28 => _28[sample.correspondingExample], 'optionalAccess', _29 => _29.customCodeSamples, 'optionalAccess', _30 => _30.length])) {
389
+ if (_optionalChain([groups, 'access', _20 => _20[sample.correspondingExample], 'optionalAccess', _21 => _21.customCodeSamples, 'optionalAccess', _22 => _22.length])) {
476
390
  groups[sample.correspondingExample].customCodeSamples.push({ ...sample, name, originalIndex: i });
477
391
  } else if (sample.correspondingExample) {
478
392
  groups[sample.correspondingExample] = {
@@ -480,7 +394,7 @@ function getExampleGroups(operation) {
480
394
  customCodeSamples: [{ ...sample, name, originalIndex: i }]
481
395
  };
482
396
  }
483
- } else if (_optionalChain([groups, 'access', _31 => _31[noCorrespondingResponseKey], 'optionalAccess', _32 => _32.customCodeSamples, 'optionalAccess', _33 => _33.length])) {
397
+ } else if (_optionalChain([groups, 'access', _23 => _23[noCorrespondingResponseKey], 'optionalAccess', _24 => _24.customCodeSamples, 'optionalAccess', _25 => _25.length])) {
484
398
  groups[noCorrespondingResponseKey].customCodeSamples.push({ ...sample, name, originalIndex: i });
485
399
  } else {
486
400
  groups[noCorrespondingResponseKey] = {
@@ -495,17 +409,19 @@ function getExampleGroups(operation) {
495
409
  }
496
410
  operation.getParameters().forEach((param) => {
497
411
  Object.entries(param.examples || {}).forEach(([exampleKey, paramExample]) => {
498
- if (_chunkVQBEI5WIcjs.isRef.call(void 0, paramExample)) {
499
- return;
412
+ let example = paramExample;
413
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, example)) {
414
+ example = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, example, operation.api);
415
+ if (!example || _chunkYPR7YTHMcjs.isRef.call(void 0, example)) return;
500
416
  }
501
417
  groups[exampleKey] = {
502
418
  ...groups[exampleKey],
503
- name: _optionalChain([groups, 'access', _34 => _34[exampleKey], 'optionalAccess', _35 => _35.name]) || paramExample.summary || exampleKey,
419
+ name: _optionalChain([groups, 'access', _26 => _26[exampleKey], 'optionalAccess', _27 => _27.name]) || example.summary || exampleKey,
504
420
  request: {
505
- ..._optionalChain([groups, 'access', _36 => _36[exampleKey], 'optionalAccess', _37 => _37.request]),
421
+ ..._optionalChain([groups, 'access', _28 => _28[exampleKey], 'optionalAccess', _29 => _29.request]),
506
422
  [param.in]: {
507
- ..._optionalChain([groups, 'access', _38 => _38[exampleKey], 'optionalAccess', _39 => _39.request, 'optionalAccess', _40 => _40[param.in]]),
508
- [param.name]: paramExample.value
423
+ ..._optionalChain([groups, 'access', _30 => _30[exampleKey], 'optionalAccess', _31 => _31.request, 'optionalAccess', _32 => _32[param.in]]),
424
+ [param.name]: example.value
509
425
  }
510
426
  }
511
427
  };
@@ -517,9 +433,9 @@ function getExampleGroups(operation) {
517
433
  const mediaType = requestExample.mediaType === "application/x-www-form-urlencoded" ? "formData" : "body";
518
434
  groups[mediaTypeExample.title] = {
519
435
  ...groups[mediaTypeExample.title],
520
- name: _optionalChain([groups, 'access', _41 => _41[mediaTypeExample.title], 'optionalAccess', _42 => _42.name]) || mediaTypeExample.summary || mediaTypeExample.title,
436
+ name: _optionalChain([groups, 'access', _33 => _33[mediaTypeExample.title], 'optionalAccess', _34 => _34.name]) || mediaTypeExample.summary || mediaTypeExample.title,
521
437
  request: {
522
- ..._optionalChain([groups, 'access', _43 => _43[mediaTypeExample.title], 'optionalAccess', _44 => _44.request]),
438
+ ..._optionalChain([groups, 'access', _35 => _35[mediaTypeExample.title], 'optionalAccess', _36 => _36.request]),
523
439
  [mediaType]: mediaTypeExample.value
524
440
  }
525
441
  };
@@ -538,9 +454,14 @@ function getExampleGroups(operation) {
538
454
  }
539
455
 
540
456
  // src/operation/lib/get-requestbody-examples.ts
541
- function getRequestBodyExamples(operation) {
542
- const requestBody = operation.requestBody;
543
- if (!requestBody || _chunkVQBEI5WIcjs.isRef.call(void 0, requestBody) || !requestBody.content) {
457
+ function getRequestBodyExamples(operation, definition) {
458
+ let requestBody = operation.requestBody;
459
+ if (!requestBody) {
460
+ return [];
461
+ } else if (_chunkYPR7YTHMcjs.isRef.call(void 0, requestBody)) {
462
+ requestBody = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, requestBody, definition);
463
+ }
464
+ if (!requestBody || _chunkYPR7YTHMcjs.isRef.call(void 0, requestBody) || !requestBody.content) {
544
465
  return [];
545
466
  }
546
467
  return Object.keys(requestBody.content || {}).map((mediaType) => {
@@ -559,26 +480,69 @@ function getRequestBodyExamples(operation) {
559
480
  }).filter((item) => item !== false);
560
481
  }
561
482
 
562
- // src/operation/lib/get-response-as-json-schema.ts
563
- var isJSON = _chunkB5WP4BJMcjs.matches_mimetype_default.json;
564
- function buildHeadersSchema(response, opts) {
483
+ // src/operation/lib/operationId.ts
484
+ function hasOperationId(operation) {
485
+ return Boolean("operationId" in operation && _optionalChain([operation, 'access', _37 => _37.operationId, 'optionalAccess', _38 => _38.length]));
486
+ }
487
+ function getOperationId(path, method, operation, opts = {}) {
488
+ function sanitize(id) {
489
+ return id.replace(_optionalChain([opts, 'optionalAccess', _39 => _39.camelCase]) || _optionalChain([opts, 'optionalAccess', _40 => _40.friendlyCase]) ? /[^a-zA-Z0-9_]/g : /[^a-zA-Z0-9]/g, "-").replace(/--+/g, "-").replace(/^-|-$/g, "");
490
+ }
491
+ const operationIdExists = hasOperationId(operation);
492
+ let operationId;
493
+ if (operationIdExists) {
494
+ operationId = operation.operationId;
495
+ } else {
496
+ operationId = sanitize(path).toLowerCase();
497
+ }
498
+ const currMethod = method.toLowerCase();
499
+ if (_optionalChain([opts, 'optionalAccess', _41 => _41.camelCase]) || _optionalChain([opts, 'optionalAccess', _42 => _42.friendlyCase])) {
500
+ if (_optionalChain([opts, 'optionalAccess', _43 => _43.friendlyCase])) {
501
+ operationId = operationId.replaceAll("_", " ");
502
+ if (!operationIdExists) {
503
+ operationId = operationId.replace(/[^a-zA-Z0-9_]+(.)/g, (_, chr) => ` ${chr}`).split(" ").filter((word, i, arr) => word !== arr[i - 1]).join(" ");
504
+ }
505
+ }
506
+ operationId = operationId.replace(/[^a-zA-Z0-9_]+(.)/g, (_, chr) => chr.toUpperCase());
507
+ if (operationIdExists) {
508
+ operationId = sanitize(operationId);
509
+ }
510
+ operationId = operationId.replace(/^[0-9]/g, (match) => `_${match}`);
511
+ operationId = operationId.charAt(0).toLowerCase() + operationId.slice(1);
512
+ if (operationId.startsWith(currMethod)) {
513
+ return operationId;
514
+ }
515
+ if (operationIdExists) {
516
+ return operationId;
517
+ }
518
+ operationId = operationId.charAt(0).toUpperCase() + operationId.slice(1);
519
+ return `${currMethod}${operationId}`;
520
+ } else if (operationIdExists) {
521
+ return operationId;
522
+ }
523
+ return `${currMethod}_${operationId}`;
524
+ }
525
+
526
+ // src/operation/transformers/get-response-as-json-schema.ts
527
+ var isJSON = _chunk7RDMAMMIcjs.matches_mimetype_default.json;
528
+ function buildHeadersSchema(response, schemaOptions) {
565
529
  const headersSchema = {
566
530
  type: "object",
567
531
  properties: {}
568
532
  };
569
533
  if (response.headers) {
570
534
  Object.keys(response.headers).forEach((key) => {
571
- if (!_optionalChain([response, 'access', _45 => _45.headers, 'optionalAccess', _46 => _46[key]]) || _chunkVQBEI5WIcjs.isRef.call(void 0, _optionalChain([response, 'access', _47 => _47.headers, 'optionalAccess', _48 => _48[key]]))) {
535
+ if (!_optionalChain([response, 'access', _44 => _44.headers, 'optionalAccess', _45 => _45[key]]) || _chunkYPR7YTHMcjs.isRef.call(void 0, _optionalChain([response, 'access', _46 => _46.headers, 'optionalAccess', _47 => _47[key]]))) {
572
536
  return;
573
537
  }
574
538
  if (response.headers[key].schema) {
575
539
  const header = response.headers[key];
576
- if (!header.schema || _chunkVQBEI5WIcjs.isRef.call(void 0, header.schema)) {
540
+ if (!header.schema || _chunkYPR7YTHMcjs.isRef.call(void 0, header.schema)) {
577
541
  return;
578
542
  }
579
- headersSchema.properties[key] = _chunkB5WP4BJMcjs.toJSONSchema.call(void 0, header.schema, {
543
+ headersSchema.properties[key] = _chunk7RDMAMMIcjs.toJSONSchema.call(void 0, header.schema, {
580
544
  addEnumsToDescriptions: true,
581
- transformer: _optionalChain([opts, 'optionalAccess', _49 => _49.transformer])
545
+ ...schemaOptions
582
546
  });
583
547
  if (header.description) {
584
548
  headersSchema.properties[key].description = header.description;
@@ -602,15 +566,24 @@ function getResponseAsJSONSchema(operation, api, statusCode, opts) {
602
566
  if (!response) {
603
567
  return null;
604
568
  }
605
- let hasCircularRefs = false;
606
- let hasDiscriminatorMappingRefs = false;
607
- function refLogger(ref, type) {
608
- if (type === "ref") {
609
- hasCircularRefs = true;
610
- } else {
611
- hasDiscriminatorMappingRefs = true;
612
- }
613
- }
569
+ const usedSchemas = /* @__PURE__ */ new Map();
570
+ const seenRefs = /* @__PURE__ */ new Set();
571
+ const refsByGroup = /* @__PURE__ */ new Map();
572
+ function refLoggerForSchemaGroup(group) {
573
+ let set = refsByGroup.get(group);
574
+ if (!set) {
575
+ set = /* @__PURE__ */ new Set();
576
+ refsByGroup.set(group, set);
577
+ }
578
+ return set;
579
+ }
580
+ const baseSchemaOptions = {
581
+ addEnumsToDescriptions: true,
582
+ definition: api,
583
+ seenRefs,
584
+ usedSchemas,
585
+ refLogger: (ref) => refLoggerForSchemaGroup("body").add(ref)
586
+ };
614
587
  function getPreferredSchema(content, preferredContentType) {
615
588
  if (!content) {
616
589
  return null;
@@ -621,125 +594,108 @@ function getResponseAsJSONSchema(operation, api, statusCode, opts) {
621
594
  }
622
595
  if (preferredContentType) {
623
596
  if (contentTypes.includes(preferredContentType)) {
624
- const schema2 = _chunkB5WP4BJMcjs.cloneObject.call(void 0, content[preferredContentType].schema);
597
+ const schema2 = _chunk7RDMAMMIcjs.cloneObject.call(void 0, content[preferredContentType].schema);
625
598
  if (!schema2) {
626
599
  return null;
627
600
  }
628
- return _chunkB5WP4BJMcjs.toJSONSchema.call(void 0, schema2, {
629
- addEnumsToDescriptions: true,
630
- refLogger,
631
- transformer: _optionalChain([opts, 'optionalAccess', _50 => _50.transformer])
632
- });
601
+ return _chunk7RDMAMMIcjs.toJSONSchema.call(void 0, schema2, baseSchemaOptions);
633
602
  }
634
603
  return null;
635
604
  }
636
605
  for (let i = 0; i < contentTypes.length; i++) {
637
606
  if (isJSON(contentTypes[i])) {
638
- const schema2 = _chunkB5WP4BJMcjs.cloneObject.call(void 0, content[contentTypes[i]].schema);
607
+ const schema2 = _chunk7RDMAMMIcjs.cloneObject.call(void 0, content[contentTypes[i]].schema);
639
608
  if (!schema2) {
640
609
  return {};
641
610
  }
642
- return _chunkB5WP4BJMcjs.toJSONSchema.call(void 0, schema2, {
643
- addEnumsToDescriptions: true,
644
- refLogger,
645
- transformer: _optionalChain([opts, 'optionalAccess', _51 => _51.transformer])
646
- });
611
+ return _chunk7RDMAMMIcjs.toJSONSchema.call(void 0, schema2, baseSchemaOptions);
647
612
  }
648
613
  }
649
614
  const contentType = contentTypes.shift();
650
615
  if (!contentType) {
651
616
  return {};
652
617
  }
653
- const schema = _chunkB5WP4BJMcjs.cloneObject.call(void 0, content[contentType].schema);
618
+ const schema = _chunk7RDMAMMIcjs.cloneObject.call(void 0, content[contentType].schema);
654
619
  if (!schema) {
655
620
  return {};
656
621
  }
657
- return _chunkB5WP4BJMcjs.toJSONSchema.call(void 0, schema, {
658
- addEnumsToDescriptions: true,
659
- refLogger,
660
- transformer: _optionalChain([opts, 'optionalAccess', _52 => _52.transformer])
661
- });
622
+ return _chunk7RDMAMMIcjs.toJSONSchema.call(void 0, schema, baseSchemaOptions);
662
623
  }
663
- const foundSchema = getPreferredSchema(response.content, _optionalChain([opts, 'optionalAccess', _53 => _53.contentType]));
664
- if (_optionalChain([opts, 'optionalAccess', _54 => _54.contentType]) && !foundSchema) {
624
+ const foundSchema = getPreferredSchema(response.content, _optionalChain([opts, 'optionalAccess', _48 => _48.contentType]));
625
+ if (_optionalChain([opts, 'optionalAccess', _49 => _49.contentType]) && !foundSchema) {
665
626
  return null;
666
627
  }
667
628
  if (foundSchema) {
668
- const schema = _chunkB5WP4BJMcjs.cloneObject.call(void 0, foundSchema);
629
+ const schema = structuredClone(foundSchema);
630
+ let schemaType = foundSchema.type;
631
+ if (schemaType === void 0 && _chunkYPR7YTHMcjs.isRef.call(void 0, foundSchema) && usedSchemas.size > 0) {
632
+ const resolvedSchema = usedSchemas.get(foundSchema.$ref);
633
+ const resolvedType = resolvedSchema && typeof resolvedSchema === "object" && "type" in resolvedSchema ? resolvedSchema.type : void 0;
634
+ schemaType = Array.isArray(resolvedType) ? resolvedType[0] : resolvedType;
635
+ }
669
636
  const schemaWrapper = {
670
637
  // If there's no `type` then the root schema is a circular `$ref` that we likely won't be
671
638
  // able to render so instead of generating a JSON Schema with an `undefined` type we should
672
639
  // default to `string` so there's at least *something* the end-user can interact with.
673
- type: foundSchema.type || "string",
674
- schema: _chunkB5WP4BJMcjs.isPrimitive.call(void 0, schema) ? schema : {
640
+ type: _nullishCoalesce(schemaType, () => ( "string")),
641
+ schema: _chunk7RDMAMMIcjs.isPrimitive.call(void 0, schema) ? schema : {
675
642
  ...schema,
676
- $schema: _chunkB5WP4BJMcjs.getSchemaVersionString.call(void 0, schema, api)
643
+ $schema: _chunk7RDMAMMIcjs.getSchemaVersionString.call(void 0, schema, api)
677
644
  },
678
645
  label: "Response body"
679
646
  };
680
647
  if (response.description && schemaWrapper.schema) {
681
648
  schemaWrapper.description = response.description;
682
649
  }
683
- if (api.components && schemaWrapper.schema) {
684
- if (hasCircularRefs || hasDiscriminatorMappingRefs && _optionalChain([opts, 'optionalAccess', _55 => _55.includeDiscriminatorMappingRefs])) {
685
- schemaWrapper.schema.components = _chunkB5WP4BJMcjs.cloneObject.call(void 0,
686
- api.components
687
- );
650
+ _chunk7RDMAMMIcjs.applyDiscriminatorOneOfToUsedSchemas.call(void 0, api, usedSchemas, (ref) => {
651
+ if (usedSchemas.has(ref)) {
652
+ return usedSchemas.get(ref);
653
+ }
654
+ try {
655
+ const resolved = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, { $ref: ref }, api, seenRefs);
656
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, resolved)) return void 0;
657
+ const converted = _chunk7RDMAMMIcjs.toJSONSchema.call(void 0, structuredClone(resolved), {
658
+ ...baseSchemaOptions,
659
+ seenRefs
660
+ });
661
+ usedSchemas.set(ref, converted);
662
+ return converted;
663
+ } catch (e2) {
664
+ return void 0;
665
+ }
666
+ });
667
+ if (schemaWrapper.schema && usedSchemas.size > 0) {
668
+ const refsInGroup = _nullishCoalesce(refsByGroup.get("body"), () => ( /* @__PURE__ */ new Set()));
669
+ const referencedSchemas = _chunk7RDMAMMIcjs.filterRequiredRefsToReferenced.call(void 0, refsInGroup, usedSchemas);
670
+ if (referencedSchemas.size > 0) {
671
+ _chunk7RDMAMMIcjs.mergeReferencedSchemasIntoRoot.call(void 0, schemaWrapper.schema, referencedSchemas);
688
672
  }
689
673
  }
690
674
  jsonSchema.push(schemaWrapper);
691
675
  }
692
676
  if (response.headers) {
693
- jsonSchema.push(buildHeadersSchema(response, opts));
694
- }
695
- return jsonSchema.length ? jsonSchema : null;
696
- }
697
-
698
- // src/operation/lib/operationId.ts
699
- function hasOperationId(operation) {
700
- return Boolean("operationId" in operation && _optionalChain([operation, 'access', _56 => _56.operationId, 'optionalAccess', _57 => _57.length]));
701
- }
702
- function getOperationId(path, method, operation, opts = {}) {
703
- function sanitize(id) {
704
- return id.replace(_optionalChain([opts, 'optionalAccess', _58 => _58.camelCase]) || _optionalChain([opts, 'optionalAccess', _59 => _59.friendlyCase]) ? /[^a-zA-Z0-9_]/g : /[^a-zA-Z0-9]/g, "-").replace(/--+/g, "-").replace(/^-|-$/g, "");
705
- }
706
- const operationIdExists = hasOperationId(operation);
707
- let operationId;
708
- if (operationIdExists) {
709
- operationId = operation.operationId;
710
- } else {
711
- operationId = sanitize(path).toLowerCase();
712
- }
713
- const currMethod = method.toLowerCase();
714
- if (_optionalChain([opts, 'optionalAccess', _60 => _60.camelCase]) || _optionalChain([opts, 'optionalAccess', _61 => _61.friendlyCase])) {
715
- if (_optionalChain([opts, 'optionalAccess', _62 => _62.friendlyCase])) {
716
- operationId = operationId.replaceAll("_", " ");
717
- if (!operationIdExists) {
718
- operationId = operationId.replace(/[^a-zA-Z0-9_]+(.)/g, (_, chr) => ` ${chr}`).split(" ").filter((word, i, arr) => word !== arr[i - 1]).join(" ");
677
+ const headersWrapper = buildHeadersSchema(response, {
678
+ ...baseSchemaOptions,
679
+ refLogger: (ref) => refLoggerForSchemaGroup("headers").add(ref)
680
+ });
681
+ if (headersWrapper.schema && usedSchemas.size > 0) {
682
+ const refsInGroup = _nullishCoalesce(refsByGroup.get("headers"), () => ( /* @__PURE__ */ new Set()));
683
+ const referencedSchemas = _chunk7RDMAMMIcjs.filterRequiredRefsToReferenced.call(void 0, refsInGroup, usedSchemas);
684
+ if (referencedSchemas.size > 0) {
685
+ _chunk7RDMAMMIcjs.mergeReferencedSchemasIntoRoot.call(void 0, headersWrapper.schema, referencedSchemas);
719
686
  }
720
687
  }
721
- operationId = operationId.replace(/[^a-zA-Z0-9_]+(.)/g, (_, chr) => chr.toUpperCase());
722
- if (operationIdExists) {
723
- operationId = sanitize(operationId);
724
- }
725
- operationId = operationId.replace(/^[0-9]/g, (match) => `_${match}`);
726
- operationId = operationId.charAt(0).toLowerCase() + operationId.slice(1);
727
- if (operationId.startsWith(currMethod)) {
728
- return operationId;
729
- }
730
- if (operationIdExists) {
731
- return operationId;
732
- }
733
- operationId = operationId.charAt(0).toUpperCase() + operationId.slice(1);
734
- return `${currMethod}${operationId}`;
735
- } else if (operationIdExists) {
736
- return operationId;
688
+ jsonSchema.push(headersWrapper);
737
689
  }
738
- return `${currMethod}_${operationId}`;
690
+ return jsonSchema.length ? jsonSchema : null;
739
691
  }
740
692
 
741
693
  // src/operation/index.ts
742
- var Operation = class {
694
+ var Operation = (_class = class {
695
+ /**
696
+ * The `Oas` instance that this operation belongs to.
697
+ */
698
+
743
699
  /**
744
700
  * Schema of the operation from the API Definition.
745
701
  */
@@ -791,9 +747,17 @@ var Operation = class {
791
747
  * it doesn't initiate multiple dereferencing processes.
792
748
  */
793
749
 
794
- constructor(api, path, method, operation) {
750
+ /**
751
+ * Have the component schemas within this API definition been decorated with our
752
+ * `x-readme-ref-name` extension?
753
+ *
754
+ * @see {@link decorateComponentSchemas}
755
+ */
756
+ __init() {this.schemasDecorated = false}
757
+ constructor(oas, path, method, operation) {;_class.prototype.__init.call(this);
758
+ this.oas = oas;
795
759
  this.schema = operation;
796
- this.api = api;
760
+ this.api = oas.api;
797
761
  this.path = path;
798
762
  this.method = method;
799
763
  this.contentType = void 0;
@@ -819,11 +783,11 @@ var Operation = class {
819
783
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}
820
784
  */
821
785
  getSummary() {
822
- if (_optionalChain([this, 'access', _63 => _63.schema, 'optionalAccess', _64 => _64.summary]) && typeof this.schema.summary === "string") {
786
+ if (_optionalChain([this, 'access', _50 => _50.schema, 'optionalAccess', _51 => _51.summary]) && typeof this.schema.summary === "string") {
823
787
  return this.schema.summary;
824
788
  }
825
- const pathItem = _optionalChain([this, 'access', _65 => _65.api, 'access', _66 => _66.paths, 'optionalAccess', _67 => _67[this.path]]);
826
- if (_optionalChain([pathItem, 'optionalAccess', _68 => _68.summary]) && typeof pathItem.summary === "string") {
789
+ const pathItem = _optionalChain([this, 'access', _52 => _52.api, 'access', _53 => _53.paths, 'optionalAccess', _54 => _54[this.path]]);
790
+ if (_optionalChain([pathItem, 'optionalAccess', _55 => _55.summary]) && typeof pathItem.summary === "string") {
827
791
  return pathItem.summary;
828
792
  }
829
793
  return void 0;
@@ -835,11 +799,11 @@ var Operation = class {
835
799
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}
836
800
  */
837
801
  getDescription() {
838
- if (_optionalChain([this, 'access', _69 => _69.schema, 'optionalAccess', _70 => _70.description]) && typeof this.schema.description === "string") {
802
+ if (_optionalChain([this, 'access', _56 => _56.schema, 'optionalAccess', _57 => _57.description]) && typeof this.schema.description === "string") {
839
803
  return this.schema.description;
840
804
  }
841
- const pathItem = _optionalChain([this, 'access', _71 => _71.api, 'access', _72 => _72.paths, 'optionalAccess', _73 => _73[this.path]]);
842
- if (_optionalChain([pathItem, 'optionalAccess', _74 => _74.description]) && typeof pathItem.description === "string") {
805
+ const pathItem = _optionalChain([this, 'access', _58 => _58.api, 'access', _59 => _59.paths, 'optionalAccess', _60 => _60[this.path]]);
806
+ if (_optionalChain([pathItem, 'optionalAccess', _61 => _61.description]) && typeof pathItem.description === "string") {
843
807
  return pathItem.description;
844
808
  }
845
809
  return void 0;
@@ -857,19 +821,19 @@ var Operation = class {
857
821
  }
858
822
  let types = [];
859
823
  if (this.schema.requestBody) {
860
- if (_chunkVQBEI5WIcjs.isRef.call(void 0, this.schema.requestBody)) {
861
- this.schema.requestBody = _chunkB5WP4BJMcjs.dereferenceRef.call(void 0, this.schema.requestBody, this.api);
824
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, this.schema.requestBody)) {
825
+ this.schema.requestBody = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, this.schema.requestBody, this.api);
862
826
  }
863
827
  if (this.schema.requestBody && "content" in this.schema.requestBody) {
864
828
  types = Object.keys(this.schema.requestBody.content);
865
829
  }
866
830
  }
867
831
  this.contentType = "application/json";
868
- if (_optionalChain([types, 'optionalAccess', _75 => _75.length])) {
832
+ if (_optionalChain([types, 'optionalAccess', _62 => _62.length])) {
869
833
  this.contentType = types[0];
870
834
  }
871
835
  types.forEach((t) => {
872
- if (_chunkB5WP4BJMcjs.matches_mimetype_default.json(t)) {
836
+ if (_chunk7RDMAMMIcjs.matches_mimetype_default.json(t)) {
873
837
  this.contentType = t;
874
838
  }
875
839
  });
@@ -882,7 +846,7 @@ var Operation = class {
882
846
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}
883
847
  */
884
848
  isFormUrlEncoded() {
885
- return _chunkB5WP4BJMcjs.matches_mimetype_default.formUrlEncoded(this.getContentType());
849
+ return _chunk7RDMAMMIcjs.matches_mimetype_default.formUrlEncoded(this.getContentType());
886
850
  }
887
851
  /**
888
852
  * Checks if the current operation has a mutipart content type payload.
@@ -891,7 +855,7 @@ var Operation = class {
891
855
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}
892
856
  */
893
857
  isMultipart() {
894
- return _chunkB5WP4BJMcjs.matches_mimetype_default.multipart(this.getContentType());
858
+ return _chunk7RDMAMMIcjs.matches_mimetype_default.multipart(this.getContentType());
895
859
  }
896
860
  /**
897
861
  * Checks if the current operation has a JSON-like content type payload.
@@ -900,7 +864,7 @@ var Operation = class {
900
864
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}
901
865
  */
902
866
  isJson() {
903
- return _chunkB5WP4BJMcjs.matches_mimetype_default.json(this.getContentType());
867
+ return _chunk7RDMAMMIcjs.matches_mimetype_default.json(this.getContentType());
904
868
  }
905
869
  /**
906
870
  * Checks if the current operation has an XML content type payload.
@@ -909,7 +873,7 @@ var Operation = class {
909
873
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}
910
874
  */
911
875
  isXml() {
912
- return _chunkB5WP4BJMcjs.matches_mimetype_default.xml(this.getContentType());
876
+ return _chunk7RDMAMMIcjs.matches_mimetype_default.xml(this.getContentType());
913
877
  }
914
878
  /**
915
879
  * Checks if the current operation is a webhook or not.
@@ -928,7 +892,7 @@ var Operation = class {
928
892
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#security-requirement-object}
929
893
  */
930
894
  getSecurity() {
931
- if (!_optionalChain([this, 'access', _76 => _76.api, 'optionalAccess', _77 => _77.components, 'optionalAccess', _78 => _78.securitySchemes]) || !Object.keys(this.api.components.securitySchemes).length) {
895
+ if (!_optionalChain([this, 'access', _63 => _63.api, 'optionalAccess', _64 => _64.components, 'optionalAccess', _65 => _65.securitySchemes]) || !Object.keys(this.api.components.securitySchemes).length) {
932
896
  return [];
933
897
  }
934
898
  return this.schema.security || this.api.security || [];
@@ -948,20 +912,22 @@ var Operation = class {
948
912
  let keys;
949
913
  try {
950
914
  keys = Object.keys(requirement);
951
- } catch (e2) {
915
+ } catch (e3) {
952
916
  return false;
953
917
  }
954
918
  const keysWithTypes = keys.map((key) => {
955
919
  let security;
956
920
  try {
957
- if (!_optionalChain([this, 'access', _79 => _79.api, 'access', _80 => _80.components, 'optionalAccess', _81 => _81.securitySchemes, 'optionalAccess', _82 => _82[key]]) || _chunkVQBEI5WIcjs.isRef.call(void 0, this.api.components.securitySchemes[key])) {
958
- return false;
921
+ security = _optionalChain([this, 'access', _66 => _66.api, 'optionalAccess', _67 => _67.components, 'optionalAccess', _68 => _68.securitySchemes, 'optionalAccess', _69 => _69[key]]);
922
+ if (!security) return false;
923
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, security)) {
924
+ security = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, security, this.api);
925
+ if (!security || _chunkYPR7YTHMcjs.isRef.call(void 0, security)) return false;
959
926
  }
960
- security = this.api.components.securitySchemes[key];
961
- } catch (e3) {
927
+ } catch (e4) {
962
928
  return false;
963
929
  }
964
- if (!security) return false;
930
+ if (!security || _chunkYPR7YTHMcjs.isRef.call(void 0, security)) return false;
965
931
  let type = null;
966
932
  if (security.type === "http") {
967
933
  if (security.scheme === "basic") type = "Basic";
@@ -1004,7 +970,7 @@ var Operation = class {
1004
970
  if (!prev[security.type]) prev[security.type] = [];
1005
971
  const exists = prev[security.type].some((sec) => sec._key === security.security._key);
1006
972
  if (!exists) {
1007
- if (_optionalChain([security, 'access', _83 => _83.security, 'optionalAccess', _84 => _84._requirements])) delete security.security._requirements;
973
+ if (_optionalChain([security, 'access', _70 => _70.security, 'optionalAccess', _71 => _71._requirements])) delete security.security._requirements;
1008
974
  prev[security.type].push(security.security);
1009
975
  }
1010
976
  });
@@ -1034,37 +1000,56 @@ var Operation = class {
1034
1000
  if (this.schema.parameters) {
1035
1001
  this.headers.request = this.headers.request.concat(
1036
1002
  this.schema.parameters.map((p) => {
1037
- if (_chunkVQBEI5WIcjs.isRef.call(void 0, p)) {
1038
- return void 0;
1003
+ let param = p;
1004
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, param)) {
1005
+ param = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, param, this.api);
1006
+ if (!param || _chunkYPR7YTHMcjs.isRef.call(void 0, param)) return void 0;
1039
1007
  }
1040
- if (p.in && p.in === "header") return p.name;
1008
+ if (param.in && param.in === "header") return param.name;
1041
1009
  return void 0;
1042
1010
  }).filter((item) => item !== void 0)
1043
1011
  );
1044
1012
  }
1045
1013
  if (this.schema.responses) {
1046
1014
  this.headers.response = Object.keys(this.schema.responses).map((r) => {
1047
- const response = _optionalChain([this, 'access', _85 => _85.schema, 'access', _86 => _86.responses, 'optionalAccess', _87 => _87[r]]);
1048
- if (!response || _chunkVQBEI5WIcjs.isRef.call(void 0, response)) {
1049
- return [];
1015
+ let response = this.schema.responses[r];
1016
+ if (!response) return [];
1017
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
1018
+ this.schema.responses[r] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, response, this.api);
1019
+ response = this.schema.responses[r];
1020
+ if (!response || _chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
1021
+ return [];
1022
+ }
1050
1023
  }
1051
- return _optionalChain([response, 'optionalAccess', _88 => _88.headers]) ? Object.keys(response.headers) : [];
1024
+ return _optionalChain([response, 'optionalAccess', _72 => _72.headers]) ? Object.keys(response.headers) : [];
1052
1025
  }).reduce((a, b) => a.concat(b), []);
1053
1026
  }
1054
1027
  if (!this.headers.request.includes("Content-Type") && this.schema.requestBody) {
1055
- const requestBody = this.schema.requestBody;
1056
- if (requestBody && !_chunkVQBEI5WIcjs.isRef.call(void 0, requestBody) && "content" in requestBody && Object.keys(requestBody.content)) {
1057
- this.headers.request.push("Content-Type");
1028
+ let requestBody = this.schema.requestBody;
1029
+ if (requestBody) {
1030
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, requestBody)) {
1031
+ this.schema.requestBody = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, requestBody, this.api);
1032
+ requestBody = this.schema.requestBody;
1033
+ }
1034
+ if (requestBody && !_chunkYPR7YTHMcjs.isRef.call(void 0, requestBody) && "content" in requestBody && Object.keys(requestBody.content)) {
1035
+ this.headers.request.push("Content-Type");
1036
+ }
1058
1037
  }
1059
1038
  }
1060
1039
  if (this.schema.responses) {
1061
- if (Object.keys(this.schema.responses).some((r) => {
1062
- const response = _optionalChain([this, 'access', _89 => _89.schema, 'access', _90 => _90.responses, 'optionalAccess', _91 => _91[r]]);
1063
- if (!response || _chunkVQBEI5WIcjs.isRef.call(void 0, response)) {
1064
- return false;
1040
+ const hasResponseContent = Object.keys(this.schema.responses).some((r) => {
1041
+ let response = _optionalChain([this, 'access', _73 => _73.schema, 'access', _74 => _74.responses, 'optionalAccess', _75 => _75[r]]);
1042
+ if (!response) return false;
1043
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
1044
+ this.schema.responses[r] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, response, this.api);
1045
+ response = this.schema.responses[r];
1046
+ if (!response || _chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
1047
+ return false;
1048
+ }
1065
1049
  }
1066
- return _optionalChain([response, 'optionalAccess', _92 => _92.content]) && Object.keys(response.content).length > 0;
1067
- })) {
1050
+ return response.content && Object.keys(response.content).length > 0;
1051
+ });
1052
+ if (hasResponseContent) {
1068
1053
  if (!this.headers.request.includes("Accept")) this.headers.request.push("Accept");
1069
1054
  if (!this.headers.response.includes("Content-Type")) this.headers.response.push("Content-Type");
1070
1055
  }
@@ -1120,7 +1105,7 @@ var Operation = class {
1120
1105
  return [];
1121
1106
  }
1122
1107
  const oasTagMap = /* @__PURE__ */ new Map();
1123
- if (Array.isArray(_optionalChain([this, 'access', _93 => _93.api, 'optionalAccess', _94 => _94.tags]))) {
1108
+ if (Array.isArray(_optionalChain([this, 'access', _76 => _76.api, 'optionalAccess', _77 => _77.tags]))) {
1124
1109
  this.api.tags.forEach((tag) => {
1125
1110
  oasTagMap.set(tag.name, tag);
1126
1111
  });
@@ -1159,17 +1144,26 @@ var Operation = class {
1159
1144
  /**
1160
1145
  * Return the parameters (non-request body) on the operation.
1161
1146
  *
1162
- * @todo Add support for `ReferenceObject`
1163
1147
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationparameters}
1164
1148
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}
1165
1149
  */
1166
1150
  getParameters() {
1167
- let parameters = (_optionalChain([this, 'access', _95 => _95.schema, 'optionalAccess', _96 => _96.parameters]) || []).filter(
1168
- (param) => param && !_chunkVQBEI5WIcjs.isRef.call(void 0, param)
1169
- );
1170
- const commonParams = (_optionalChain([this, 'access', _97 => _97.api, 'optionalAccess', _98 => _98.paths, 'optionalAccess', _99 => _99[this.path], 'optionalAccess', _100 => _100.parameters]) || []).filter(
1171
- (param) => param && !_chunkVQBEI5WIcjs.isRef.call(void 0, param)
1172
- );
1151
+ let parameters = (_optionalChain([this, 'access', _78 => _78.schema, 'optionalAccess', _79 => _79.parameters]) || []).map((p) => {
1152
+ let param = p;
1153
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, param)) {
1154
+ param = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, param, this.api);
1155
+ if (!param || _chunkYPR7YTHMcjs.isRef.call(void 0, param)) return void 0;
1156
+ }
1157
+ return param;
1158
+ }).filter((param) => param !== void 0);
1159
+ const commonParams = (_optionalChain([this, 'access', _80 => _80.api, 'optionalAccess', _81 => _81.paths, 'optionalAccess', _82 => _82[this.path], 'optionalAccess', _83 => _83.parameters]) || []).map((p) => {
1160
+ let param = p;
1161
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, param)) {
1162
+ param = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, param, this.api);
1163
+ if (!param || _chunkYPR7YTHMcjs.isRef.call(void 0, param)) return void 0;
1164
+ }
1165
+ return param;
1166
+ }).filter((param) => param !== void 0);
1173
1167
  if (commonParams.length) {
1174
1168
  parameters = parameters.concat(dedupeCommonParameters(parameters, commonParams) || []);
1175
1169
  }
@@ -1188,26 +1182,54 @@ var Operation = class {
1188
1182
  * Convert the operation into an array of JSON Schema schemas for each available type of
1189
1183
  * parameter available on the operation.
1190
1184
  *
1185
+ * Note that this method is not compatible with an operation or OpenAPI definition that has been
1186
+ * processed with `.dereference()`. This method can only be called with the _original_ API
1187
+ * definition that was used to initialize the `Operation` and `Oas` instance. If a dereferenced
1188
+ * schema is present when this is called a `TypeError` will be thrown.
1189
+ *
1190
+ * @throws {TypeError} If the operation or OpenAPI definition has been run through `.dereference().`
1191
+ *
1191
1192
  */
1192
1193
  getParametersAsJSONSchema(opts = {}) {
1193
- return _chunkB5WP4BJMcjs.getParametersAsJSONSchema.call(void 0, this, this.api, {
1194
+ if (this.isDereferenced()) {
1195
+ throw new Error(
1196
+ "`.getParametersAsJSONSchema()` is not compatible with an operation or OpenAPI definition that has been run through `.dereference().`"
1197
+ );
1198
+ }
1199
+ if (!this.schemasDecorated) {
1200
+ _chunk7RDMAMMIcjs.decorateComponentSchemasWithRefName.call(void 0, this.api);
1201
+ this.schemasDecorated = true;
1202
+ }
1203
+ return _chunk7RDMAMMIcjs.getParametersAsJSONSchema.call(void 0, this, this.api, {
1194
1204
  includeDiscriminatorMappingRefs: true,
1195
- transformer: (s) => s,
1196
1205
  ...opts
1197
1206
  });
1198
1207
  }
1199
1208
  /**
1200
1209
  * Get a single response for this status code, formatted as JSON schema.
1201
1210
  *
1211
+ * Note that this method is not compatible with an operation or OpenAPI definition that has been
1212
+ * processed with `.dereference()`. This method can only be called with the _original_ API
1213
+ * definition that was used to initialize the `Operation` and `Oas` instance. If a dereferenced
1214
+ * schema is present when this is called a `TypeError` will be thrown.
1215
+ *
1202
1216
  * @param statusCode Status code to pull a JSON Schema response for.
1203
1217
  * @param opts Options for schema generation.
1204
1218
  * @param opts.contentType Optional content-type to use. If specified and the response doesn't have
1205
1219
  * this content-type, the function will return null.
1206
1220
  */
1207
1221
  getResponseAsJSONSchema(statusCode, opts = {}) {
1222
+ if (this.isDereferenced()) {
1223
+ throw new Error(
1224
+ "`.getResponseAsJSONSchema()` is not compatible with an operation or OpenAPI definition that has been run through `.dereference().`"
1225
+ );
1226
+ }
1227
+ if (!this.schemasDecorated) {
1228
+ _chunk7RDMAMMIcjs.decorateComponentSchemasWithRefName.call(void 0, this.api);
1229
+ this.schemasDecorated = true;
1230
+ }
1208
1231
  return getResponseAsJSONSchema(this, this.api, statusCode, {
1209
1232
  includeDiscriminatorMappingRefs: true,
1210
- transformer: (s) => s,
1211
1233
  ...opts
1212
1234
  });
1213
1235
  }
@@ -1218,6 +1240,30 @@ var Operation = class {
1218
1240
  getResponseStatusCodes() {
1219
1241
  return this.schema.responses ? Object.keys(this.schema.responses) : [];
1220
1242
  }
1243
+ /**
1244
+ * Retrieve an array of all content types that this operation can return.
1245
+ *
1246
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object}
1247
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#response-object}
1248
+ */
1249
+ getResponseContentTypes() {
1250
+ if (!this.schema.responses) return [];
1251
+ const contentTypes = /* @__PURE__ */ new Set();
1252
+ Object.values(this.schema.responses).forEach((response) => {
1253
+ let resp = response;
1254
+ if (!resp) return;
1255
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, resp)) {
1256
+ resp = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, resp, this.api);
1257
+ if (!resp || _chunkYPR7YTHMcjs.isRef.call(void 0, resp)) {
1258
+ return;
1259
+ }
1260
+ }
1261
+ Object.keys(resp.content || {}).forEach((mimeType) => {
1262
+ contentTypes.add(mimeType);
1263
+ });
1264
+ });
1265
+ return Array.from(contentTypes);
1266
+ }
1221
1267
  /**
1222
1268
  * Determine if the operation has any request bodies.
1223
1269
  *
@@ -1227,6 +1273,23 @@ var Operation = class {
1227
1273
  hasRequestBody() {
1228
1274
  return !!this.schema.requestBody;
1229
1275
  }
1276
+ /**
1277
+ * Return the current `requestBody` object, dereferencing it in the process if it's a `$ref`
1278
+ * pointer.
1279
+ *
1280
+ */
1281
+ getResolvedRequestBody() {
1282
+ let requestBody = this.schema.requestBody;
1283
+ if (!requestBody) return false;
1284
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, requestBody)) {
1285
+ this.schema.requestBody = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, requestBody, this.api);
1286
+ requestBody = this.schema.requestBody;
1287
+ if (!requestBody || _chunkYPR7YTHMcjs.isRef.call(void 0, requestBody)) {
1288
+ return false;
1289
+ }
1290
+ }
1291
+ return requestBody;
1292
+ }
1230
1293
  /**
1231
1294
  * Retrieve the list of all available media types that the operations request body can accept.
1232
1295
  *
@@ -1237,10 +1300,8 @@ var Operation = class {
1237
1300
  if (!this.hasRequestBody()) {
1238
1301
  return [];
1239
1302
  }
1240
- const requestBody = this.schema.requestBody;
1241
- if (!requestBody || _chunkVQBEI5WIcjs.isRef.call(void 0, requestBody)) {
1242
- return [];
1243
- }
1303
+ const requestBody = this.getResolvedRequestBody();
1304
+ if (!requestBody) return [];
1244
1305
  return Object.keys(requestBody.content);
1245
1306
  }
1246
1307
  /**
@@ -1253,10 +1314,8 @@ var Operation = class {
1253
1314
  if (!this.hasRequestBody()) {
1254
1315
  return false;
1255
1316
  }
1256
- const requestBody = this.schema.requestBody;
1257
- if (!requestBody || _chunkVQBEI5WIcjs.isRef.call(void 0, requestBody)) {
1258
- return false;
1259
- }
1317
+ const requestBody = this.getResolvedRequestBody();
1318
+ if (!requestBody) return false;
1260
1319
  if (requestBody.required) {
1261
1320
  return true;
1262
1321
  }
@@ -1282,10 +1341,8 @@ var Operation = class {
1282
1341
  if (!this.hasRequestBody()) {
1283
1342
  return false;
1284
1343
  }
1285
- const requestBody = this.schema.requestBody;
1286
- if (!requestBody || _chunkVQBEI5WIcjs.isRef.call(void 0, requestBody)) {
1287
- return false;
1288
- }
1344
+ const requestBody = this.getResolvedRequestBody();
1345
+ if (!requestBody) return false;
1289
1346
  if (mediaType) {
1290
1347
  if (!(mediaType in requestBody.content)) {
1291
1348
  return false;
@@ -1295,7 +1352,7 @@ var Operation = class {
1295
1352
  let availableMediaType;
1296
1353
  const mediaTypes = this.getRequestBodyMediaTypes();
1297
1354
  mediaTypes.forEach((mt) => {
1298
- if (!availableMediaType && _chunkB5WP4BJMcjs.matches_mimetype_default.json(mt)) {
1355
+ if (!availableMediaType && _chunk7RDMAMMIcjs.matches_mimetype_default.json(mt)) {
1299
1356
  availableMediaType = mt;
1300
1357
  }
1301
1358
  });
@@ -1322,11 +1379,11 @@ var Operation = class {
1322
1379
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#request-body-examples}
1323
1380
  */
1324
1381
  getRequestBodyExamples() {
1325
- const isRequestExampleValueDefined = typeof _optionalChain([this, 'access', _101 => _101.requestBodyExamples, 'optionalAccess', _102 => _102[0], 'optionalAccess', _103 => _103.examples, 'optionalAccess', _104 => _104[0], 'access', _105 => _105.value]) !== "undefined";
1382
+ const isRequestExampleValueDefined = typeof _optionalChain([this, 'access', _84 => _84.requestBodyExamples, 'optionalAccess', _85 => _85[0], 'optionalAccess', _86 => _86.examples, 'optionalAccess', _87 => _87[0], 'access', _88 => _88.value]) !== "undefined";
1326
1383
  if (this.requestBodyExamples && isRequestExampleValueDefined) {
1327
1384
  return this.requestBodyExamples;
1328
1385
  }
1329
- this.requestBodyExamples = getRequestBodyExamples(this.schema);
1386
+ this.requestBodyExamples = getRequestBodyExamples(this.schema, this.api);
1330
1387
  return this.requestBodyExamples;
1331
1388
  }
1332
1389
  /**
@@ -1340,9 +1397,14 @@ var Operation = class {
1340
1397
  if (!this.schema.responses) {
1341
1398
  return false;
1342
1399
  }
1343
- const response = this.schema.responses[statusCode];
1344
- if (!response || _chunkVQBEI5WIcjs.isRef.call(void 0, response)) {
1345
- return false;
1400
+ let response = this.schema.responses[statusCode];
1401
+ if (!response) return false;
1402
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
1403
+ this.schema.responses[statusCode] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, response, this.api);
1404
+ response = this.schema.responses[statusCode];
1405
+ if (!response || _chunkYPR7YTHMcjs.isRef.call(void 0, response)) {
1406
+ return false;
1407
+ }
1346
1408
  }
1347
1409
  return response;
1348
1410
  }
@@ -1356,7 +1418,7 @@ var Operation = class {
1356
1418
  if (this.responseExamples) {
1357
1419
  return this.responseExamples;
1358
1420
  }
1359
- this.responseExamples = getResponseExamples(this.schema);
1421
+ this.responseExamples = getResponseExamples(this.schema, this.api);
1360
1422
  return this.responseExamples;
1361
1423
  }
1362
1424
  /**
@@ -1379,15 +1441,28 @@ var Operation = class {
1379
1441
  */
1380
1442
  getCallback(identifier, expression, method) {
1381
1443
  if (!this.schema.callbacks) return false;
1382
- const callbackObj = this.schema.callbacks[identifier];
1383
- if (!callbackObj || _chunkVQBEI5WIcjs.isRef.call(void 0, callbackObj)) {
1384
- return false;
1444
+ let callbackObj = this.schema.callbacks[identifier];
1445
+ if (!callbackObj) return false;
1446
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, callbackObj)) {
1447
+ this.schema.callbacks[identifier] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, callbackObj, this.api);
1448
+ callbackObj = this.schema.callbacks[identifier];
1449
+ if (!callbackObj || _chunkYPR7YTHMcjs.isRef.call(void 0, callbackObj)) {
1450
+ return false;
1451
+ }
1385
1452
  }
1386
- const callback = callbackObj[expression];
1387
- if (!callback || _chunkVQBEI5WIcjs.isRef.call(void 0, callback) || !callback[method]) {
1453
+ let callback = callbackObj[expression];
1454
+ if (!callback) return false;
1455
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, callback)) {
1456
+ callbackObj[expression] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, callback, this.api);
1457
+ callback = callbackObj[expression];
1458
+ if (!callback || _chunkYPR7YTHMcjs.isRef.call(void 0, callback)) {
1459
+ return false;
1460
+ }
1461
+ }
1462
+ if (!callback[method]) {
1388
1463
  return false;
1389
1464
  }
1390
- return new Callback(this.api, expression, method, callback[method], identifier, callback);
1465
+ return new Callback(this.oas, expression, method, callback[method], identifier, callback);
1391
1466
  }
1392
1467
  /**
1393
1468
  * Retrieve an array of operations created from each callback.
@@ -1398,18 +1473,28 @@ var Operation = class {
1398
1473
  getCallbacks() {
1399
1474
  if (!this.hasCallbacks()) return [];
1400
1475
  const callbacks = [];
1401
- Object.keys(this.schema.callbacks || {}).forEach((callback) => {
1402
- const cb = _optionalChain([this, 'access', _106 => _106.schema, 'access', _107 => _107.callbacks, 'optionalAccess', _108 => _108[callback]]);
1403
- if (!cb || _chunkVQBEI5WIcjs.isRef.call(void 0, cb)) {
1404
- return;
1476
+ Object.keys(this.schema.callbacks).forEach((callback) => {
1477
+ let cb = _optionalChain([this, 'access', _89 => _89.schema, 'access', _90 => _90.callbacks, 'optionalAccess', _91 => _91[callback]]);
1478
+ if (!cb) return;
1479
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, cb)) {
1480
+ this.schema.callbacks[callback] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, cb, this.api);
1481
+ cb = this.schema.callbacks[callback];
1482
+ if (!cb || _chunkYPR7YTHMcjs.isRef.call(void 0, cb)) {
1483
+ return;
1484
+ }
1405
1485
  }
1406
1486
  Object.keys(cb).forEach((expression) => {
1407
- const exp = cb[expression];
1408
- if (!exp || _chunkVQBEI5WIcjs.isRef.call(void 0, exp)) {
1409
- return;
1487
+ let callbackPath = cb[expression];
1488
+ if (!callbackPath) return;
1489
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, callbackPath)) {
1490
+ cb[expression] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, callbackPath, this.api);
1491
+ callbackPath = cb[expression];
1492
+ if (!callbackPath || _chunkYPR7YTHMcjs.isRef.call(void 0, callbackPath)) {
1493
+ return;
1494
+ }
1410
1495
  }
1411
- Object.keys(exp).forEach((method) => {
1412
- if (!_chunkO3GIPZLCcjs.supportedMethods.includes(method)) return;
1496
+ Object.keys(callbackPath).forEach((method) => {
1497
+ if (!_chunk7RDMAMMIcjs.supportedMethods.includes(method)) return;
1413
1498
  const found = this.getCallback(callback, expression, method);
1414
1499
  if (found) {
1415
1500
  callbacks.push(found);
@@ -1429,7 +1514,7 @@ var Operation = class {
1429
1514
  if (this.callbackExamples) {
1430
1515
  return this.callbackExamples;
1431
1516
  }
1432
- this.callbackExamples = getCallbackExamples(this.schema);
1517
+ this.callbackExamples = getCallbackExamples(this.schema, this.api);
1433
1518
  return this.callbackExamples;
1434
1519
  }
1435
1520
  /**
@@ -1452,7 +1537,7 @@ var Operation = class {
1452
1537
  * @deprecated Use `oas.getExtension(extension, operation)` instead.
1453
1538
  */
1454
1539
  getExtension(extension) {
1455
- return _optionalChain([this, 'access', _109 => _109.schema, 'optionalAccess', _110 => _110[extension]]);
1540
+ return _optionalChain([this, 'access', _92 => _92.schema, 'optionalAccess', _93 => _93[extension]]);
1456
1541
  }
1457
1542
  /**
1458
1543
  * Returns an object with groups of all example definitions (body/header/query/path/response/etc.).
@@ -1486,18 +1571,13 @@ var Operation = class {
1486
1571
  });
1487
1572
  }
1488
1573
  this.dereferencing.processing = true;
1489
- const { children: discriminatorChildrenMap, inverted: discriminatorChildrenMapInverted } = findDiscriminatorChildren(this.api);
1490
- const { api, schema, promises } = this;
1491
- if (_optionalChain([api, 'optionalAccess', _111 => _111.components, 'optionalAccess', _112 => _112.schemas]) && typeof api.components.schemas === "object") {
1492
- Object.keys(api.components.schemas).forEach((schemaName) => {
1493
- if (_chunkB5WP4BJMcjs.isPrimitive.call(void 0, _optionalChain([api, 'access', _113 => _113.components, 'optionalAccess', _114 => _114.schemas, 'optionalAccess', _115 => _115[schemaName]])) || Array.isArray(_optionalChain([api, 'access', _116 => _116.components, 'optionalAccess', _117 => _117.schemas, 'optionalAccess', _118 => _118[schemaName]])) || _optionalChain([api, 'access', _119 => _119.components, 'optionalAccess', _120 => _120.schemas, 'optionalAccess', _121 => _121[schemaName]]) === null) {
1494
- return;
1495
- }
1496
- (_optionalChain([api, 'access', _122 => _122.components, 'optionalAccess', _123 => _123.schemas, 'optionalAccess', _124 => _124[schemaName]]))["x-readme-ref-name"] = schemaName;
1497
- });
1574
+ if (!this.schemasDecorated) {
1575
+ _chunk7RDMAMMIcjs.decorateComponentSchemasWithRefName.call(void 0, this.api);
1576
+ this.schemasDecorated = true;
1498
1577
  }
1578
+ const { api, schema, promises } = this;
1499
1579
  const circularRefs = /* @__PURE__ */ new Set();
1500
- const dereferencingOptions = _chunkB5WP4BJMcjs.getDereferencingOptions.call(void 0, circularRefs);
1580
+ const dereferencingOptions = _chunk7RDMAMMIcjs.getDereferencingOptions.call(void 0, circularRefs);
1501
1581
  const parser = new (0, _jsonschemarefparser.$RefParser)();
1502
1582
  return parser.dereference(
1503
1583
  "#/__INTERNAL__",
@@ -1530,30 +1610,12 @@ var Operation = class {
1530
1610
  if (path === "#/paths" || path.startsWith("#/paths/")) {
1531
1611
  return true;
1532
1612
  }
1533
- if (discriminatorChildrenMap.size > 0 || discriminatorChildrenMapInverted.size > 0) {
1534
- if (path.startsWith("#/components/") && path !== "#/components/schemas" && !path.startsWith("#/components/schemas/")) {
1535
- return true;
1536
- }
1537
- if (path.startsWith("#/components/schemas/")) {
1538
- const schemaName = path.split("/").pop();
1539
- if (schemaName && (discriminatorChildrenMap.has(schemaName) || discriminatorChildrenMapInverted.has(schemaName))) {
1540
- if (path === `#/components/schemas/${schemaName}` || path.startsWith(`#/components/schemas/${schemaName}/`)) {
1541
- return false;
1542
- }
1543
- return true;
1544
- }
1545
- }
1546
- return false;
1547
- }
1548
1613
  return path === "#/components" || path.startsWith("#/components/");
1549
1614
  }
1550
1615
  }
1551
1616
  }
1552
1617
  ).then((res) => {
1553
1618
  const dereferenced = res;
1554
- if (_optionalChain([dereferenced, 'optionalAccess', _125 => _125.components, 'optionalAccess', _126 => _126.schemas]) && discriminatorChildrenMap.size > 0) {
1555
- buildDiscriminatorOneOf({ components: dereferenced.components }, discriminatorChildrenMap);
1556
- }
1557
1619
  this.schema = dereferenced.__INTERNAL__;
1558
1620
  this.promises = promises;
1559
1621
  this.dereferencing = {
@@ -1562,7 +1624,7 @@ var Operation = class {
1562
1624
  // We need to convert our `Set` to an array in order to match the typings.
1563
1625
  circularRefs: [...circularRefs]
1564
1626
  };
1565
- if (_optionalChain([opts, 'optionalAccess', _127 => _127.cb])) {
1627
+ if (_optionalChain([opts, 'optionalAccess', _94 => _94.cb])) {
1566
1628
  opts.cb();
1567
1629
  }
1568
1630
  }).then(() => {
@@ -1573,6 +1635,15 @@ var Operation = class {
1573
1635
  throw err;
1574
1636
  });
1575
1637
  }
1638
+ /**
1639
+ * Determine if the current operation schema, or the OpenAPI definition it's part of, has been
1640
+ * dereferenced or not with `.dereference()`.
1641
+ *
1642
+ * @see Operation.dereference
1643
+ */
1644
+ isDereferenced() {
1645
+ return this.oas.isDereferenced() || this.dereferencing.processing || this.dereferencing.complete;
1646
+ }
1576
1647
  /**
1577
1648
  * Retrieve any circular `$ref` pointers that maybe present within operation schema.
1578
1649
  *
@@ -1586,7 +1657,7 @@ var Operation = class {
1586
1657
  }
1587
1658
  return this.dereferencing.circularRefs;
1588
1659
  }
1589
- };
1660
+ }, _class);
1590
1661
  var Callback = class extends Operation {
1591
1662
  /**
1592
1663
  * The identifier that this callback is set to.
@@ -1610,25 +1681,57 @@ var Callback = class extends Operation {
1610
1681
  getIdentifier() {
1611
1682
  return this.identifier;
1612
1683
  }
1684
+ /**
1685
+ * Retrieve the `summary` for this callback.
1686
+ *
1687
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationsummary}
1688
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}
1689
+ */
1613
1690
  getSummary() {
1614
- if (_optionalChain([this, 'access', _128 => _128.schema, 'optionalAccess', _129 => _129.summary]) && typeof this.schema.summary === "string") {
1691
+ if (_optionalChain([this, 'access', _95 => _95.schema, 'optionalAccess', _96 => _96.summary]) && typeof this.schema.summary === "string") {
1615
1692
  return this.schema.summary;
1616
1693
  } else if (this.parentSchema.summary && typeof this.parentSchema.summary === "string") {
1617
1694
  return this.parentSchema.summary;
1618
1695
  }
1619
1696
  return void 0;
1620
1697
  }
1698
+ /**
1699
+ * Retrieve the `description` for this operation.
1700
+ *
1701
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationdescription}
1702
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}
1703
+ */
1621
1704
  getDescription() {
1622
- if (_optionalChain([this, 'access', _130 => _130.schema, 'optionalAccess', _131 => _131.description]) && typeof this.schema.description === "string") {
1705
+ if (_optionalChain([this, 'access', _97 => _97.schema, 'optionalAccess', _98 => _98.description]) && typeof this.schema.description === "string") {
1623
1706
  return this.schema.description;
1624
1707
  } else if (this.parentSchema.description && typeof this.parentSchema.description === "string") {
1625
1708
  return this.parentSchema.description;
1626
1709
  }
1627
1710
  return void 0;
1628
1711
  }
1712
+ /**
1713
+ * Return the parameters (non-request body) on the operation.
1714
+ *
1715
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationparameters}
1716
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}
1717
+ */
1629
1718
  getParameters() {
1630
- let parameters = _optionalChain([this, 'access', _132 => _132.schema, 'optionalAccess', _133 => _133.parameters]) || [];
1631
- const commonParams = this.parentSchema.parameters || [];
1719
+ let parameters = (_optionalChain([this, 'access', _99 => _99.schema, 'optionalAccess', _100 => _100.parameters]) || []).map((p) => {
1720
+ let param = p;
1721
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, param)) {
1722
+ param = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, param, this.api);
1723
+ if (!param || _chunkYPR7YTHMcjs.isRef.call(void 0, param)) return void 0;
1724
+ }
1725
+ return param;
1726
+ }).filter((param) => param !== void 0);
1727
+ const commonParams = (this.parentSchema.parameters || []).map((p) => {
1728
+ let param = p;
1729
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, param)) {
1730
+ param = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, param, this.api);
1731
+ if (!param || _chunkYPR7YTHMcjs.isRef.call(void 0, param)) return void 0;
1732
+ }
1733
+ return param;
1734
+ }).filter((param) => param !== void 0);
1632
1735
  if (commonParams.length) {
1633
1736
  parameters = parameters.concat(dedupeCommonParameters(parameters, commonParams) || []);
1634
1737
  }
@@ -1636,29 +1739,43 @@ var Callback = class extends Operation {
1636
1739
  }
1637
1740
  };
1638
1741
  var Webhook = class extends Operation {
1742
+ /**
1743
+ * Retrieve the `summary` for this callback.
1744
+ *
1745
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationsummary}
1746
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}
1747
+ */
1639
1748
  getSummary() {
1640
- if (_optionalChain([this, 'access', _134 => _134.schema, 'optionalAccess', _135 => _135.summary]) && typeof this.schema.summary === "string") {
1749
+ if (_optionalChain([this, 'access', _101 => _101.schema, 'optionalAccess', _102 => _102.summary]) && typeof this.schema.summary === "string") {
1641
1750
  return this.schema.summary;
1751
+ } else if (!this.api.webhooks) {
1752
+ return void 0;
1642
1753
  }
1643
- const webhookPath = _optionalChain([this, 'access', _136 => _136.api, 'access', _137 => _137.webhooks, 'optionalAccess', _138 => _138[this.path]]);
1644
- if (webhookPath && !_chunkVQBEI5WIcjs.isRef.call(void 0, webhookPath)) {
1645
- if (_optionalChain([webhookPath, 'optionalAccess', _139 => _139.summary]) && typeof webhookPath.summary === "string") {
1646
- return webhookPath.summary;
1647
- }
1754
+ let webhookPath = this.api.webhooks[this.path];
1755
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, webhookPath)) {
1756
+ this.api.webhooks[this.path] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, webhookPath, this.api);
1757
+ webhookPath = this.api.webhooks[this.path];
1648
1758
  }
1649
- return void 0;
1759
+ return _optionalChain([webhookPath, 'optionalAccess', _103 => _103.summary]);
1650
1760
  }
1761
+ /**
1762
+ * Retrieve the `description` for this operation.
1763
+ *
1764
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationdescription}
1765
+ * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}
1766
+ */
1651
1767
  getDescription() {
1652
- if (_optionalChain([this, 'access', _140 => _140.schema, 'optionalAccess', _141 => _141.description]) && typeof this.schema.description === "string") {
1768
+ if (_optionalChain([this, 'access', _104 => _104.schema, 'optionalAccess', _105 => _105.description]) && typeof this.schema.description === "string") {
1653
1769
  return this.schema.description;
1770
+ } else if (!this.api.webhooks) {
1771
+ return void 0;
1654
1772
  }
1655
- const webhookPath = _optionalChain([this, 'access', _142 => _142.api, 'access', _143 => _143.webhooks, 'optionalAccess', _144 => _144[this.path]]);
1656
- if (webhookPath && !_chunkVQBEI5WIcjs.isRef.call(void 0, webhookPath)) {
1657
- if (_optionalChain([webhookPath, 'optionalAccess', _145 => _145.description]) && typeof webhookPath.description === "string") {
1658
- return webhookPath.description;
1659
- }
1773
+ let webhookPath = this.api.webhooks[this.path];
1774
+ if (_chunkYPR7YTHMcjs.isRef.call(void 0, webhookPath)) {
1775
+ this.api.webhooks[this.path] = _chunk7RDMAMMIcjs.dereferenceRef.call(void 0, webhookPath, this.api);
1776
+ webhookPath = this.api.webhooks[this.path];
1660
1777
  }
1661
- return void 0;
1778
+ return _optionalChain([webhookPath, 'optionalAccess', _106 => _106.description]);
1662
1779
  }
1663
1780
  };
1664
1781
 
@@ -1666,9 +1783,7 @@ var Webhook = class extends Operation {
1666
1783
 
1667
1784
 
1668
1785
 
1669
-
1670
-
1671
- exports.findDiscriminatorChildren = findDiscriminatorChildren; exports.buildDiscriminatorOneOf = buildDiscriminatorOneOf; exports.Operation = Operation; exports.Callback = Callback; exports.Webhook = Webhook;
1786
+ exports.Operation = Operation; exports.Callback = Callback; exports.Webhook = Webhook;
1672
1787
  /**
1673
1788
  * Portions of this file have been extracted and modified from Swagger UI.
1674
1789
  *
@@ -1681,4 +1796,4 @@ exports.findDiscriminatorChildren = findDiscriminatorChildren; exports.buildDisc
1681
1796
  * @license Apache-2.0
1682
1797
  * @see {@link https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/samples/fn.js}
1683
1798
  */
1684
- //# sourceMappingURL=chunk-BRYRBTD7.cjs.map
1799
+ //# sourceMappingURL=chunk-AQUZF2EA.cjs.map