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,128 +1,29 @@
1
1
  import {
2
- supportedMethods
3
- } from "./chunk-VA3NKXX7.js";
4
- import {
2
+ applyDiscriminatorOneOfToUsedSchemas,
5
3
  cloneObject,
4
+ decorateComponentSchemasWithRefName,
6
5
  dereferenceRef,
6
+ filterRequiredRefsToReferenced,
7
7
  getDereferencingOptions,
8
8
  getParametersAsJSONSchema,
9
9
  getSchemaVersionString,
10
10
  isObject,
11
11
  isPrimitive,
12
12
  matches_mimetype_default,
13
+ mergeReferencedSchemasIntoRoot,
14
+ supportedMethods,
13
15
  toJSONSchema
14
- } from "./chunk-5EP6HY2E.js";
16
+ } from "./chunk-HYH37HS2.js";
15
17
  import {
16
18
  getExtension
17
19
  } from "./chunk-S27IGTVG.js";
18
20
  import {
19
21
  isRef
20
- } from "./chunk-7MARUOFZ.js";
22
+ } from "./chunk-MNOEMVCF.js";
21
23
 
22
24
  // src/operation/index.ts
23
25
  import { $RefParser } from "@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 (isRef(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 (!api?.components?.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
- invertedChildrenMap.get(value)?.push(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 (!api?.components?.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(cloneObject(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 = cloneObject(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) => {
@@ -374,12 +275,14 @@ 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 = operation.responses?.[status];
280
+ let response = operation.responses?.[status];
380
281
  let onlyHeaders = false;
381
- if (!response || isRef(response)) {
382
- return false;
282
+ if (!response) return false;
283
+ if (isRef(response)) {
284
+ response = dereferenceRef(response, definition);
285
+ if (!response || isRef(response)) return false;
383
286
  }
384
287
  const mediaTypes = {};
385
288
  (response?.content ? Object.keys(response.content) : []).forEach((mediaType) => {
@@ -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 = operation.callbacks?.[identifier];
419
- if (!callback || isRef(callback)) {
420
- return [];
321
+ let callback = operation.callbacks?.[identifier];
322
+ if (!callback) return [];
323
+ if (isRef(callback)) {
324
+ callback = dereferenceRef(callback, definition);
325
+ if (!callback || isRef(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 (isRef(callbackPath)) {
331
+ callbackPath = dereferenceRef(callbackPath, definition);
332
+ if (!callbackPath || isRef(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,
@@ -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 (isRef(paramExample)) {
499
- return;
412
+ let example = paramExample;
413
+ if (isRef(example)) {
414
+ example = dereferenceRef(example, operation.api);
415
+ if (!example || isRef(example)) return;
500
416
  }
501
417
  groups[exampleKey] = {
502
418
  ...groups[exampleKey],
503
- name: groups[exampleKey]?.name || paramExample.summary || exampleKey,
419
+ name: groups[exampleKey]?.name || example.summary || exampleKey,
504
420
  request: {
505
421
  ...groups[exampleKey]?.request,
506
422
  [param.in]: {
507
423
  ...groups[exampleKey]?.request?.[param.in],
508
- [param.name]: paramExample.value
424
+ [param.name]: example.value
509
425
  }
510
426
  }
511
427
  };
@@ -538,8 +454,13 @@ 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;
457
+ function getRequestBodyExamples(operation, definition) {
458
+ let requestBody = operation.requestBody;
459
+ if (!requestBody) {
460
+ return [];
461
+ } else if (isRef(requestBody)) {
462
+ requestBody = dereferenceRef(requestBody, definition);
463
+ }
543
464
  if (!requestBody || isRef(requestBody) || !requestBody.content) {
544
465
  return [];
545
466
  }
@@ -559,9 +480,52 @@ function getRequestBodyExamples(operation) {
559
480
  }).filter((item) => item !== false);
560
481
  }
561
482
 
562
- // src/operation/lib/get-response-as-json-schema.ts
483
+ // src/operation/lib/operationId.ts
484
+ function hasOperationId(operation) {
485
+ return Boolean("operationId" in operation && operation.operationId?.length);
486
+ }
487
+ function getOperationId(path, method, operation, opts = {}) {
488
+ function sanitize(id) {
489
+ return id.replace(opts?.camelCase || opts?.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 (opts?.camelCase || opts?.friendlyCase) {
500
+ if (opts?.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
563
527
  var isJSON = matches_mimetype_default.json;
564
- function buildHeadersSchema(response, opts) {
528
+ function buildHeadersSchema(response, schemaOptions) {
565
529
  const headersSchema = {
566
530
  type: "object",
567
531
  properties: {}
@@ -578,7 +542,7 @@ function buildHeadersSchema(response, opts) {
578
542
  }
579
543
  headersSchema.properties[key] = toJSONSchema(header.schema, {
580
544
  addEnumsToDescriptions: true,
581
- transformer: opts?.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;
@@ -625,11 +598,7 @@ function getResponseAsJSONSchema(operation, api, statusCode, opts) {
625
598
  if (!schema2) {
626
599
  return null;
627
600
  }
628
- return toJSONSchema(schema2, {
629
- addEnumsToDescriptions: true,
630
- refLogger,
631
- transformer: opts?.transformer
632
- });
601
+ return toJSONSchema(schema2, baseSchemaOptions);
633
602
  }
634
603
  return null;
635
604
  }
@@ -639,11 +608,7 @@ function getResponseAsJSONSchema(operation, api, statusCode, opts) {
639
608
  if (!schema2) {
640
609
  return {};
641
610
  }
642
- return toJSONSchema(schema2, {
643
- addEnumsToDescriptions: true,
644
- refLogger,
645
- transformer: opts?.transformer
646
- });
611
+ return toJSONSchema(schema2, baseSchemaOptions);
647
612
  }
648
613
  }
649
614
  const contentType = contentTypes.shift();
@@ -654,23 +619,25 @@ function getResponseAsJSONSchema(operation, api, statusCode, opts) {
654
619
  if (!schema) {
655
620
  return {};
656
621
  }
657
- return toJSONSchema(schema, {
658
- addEnumsToDescriptions: true,
659
- refLogger,
660
- transformer: opts?.transformer
661
- });
622
+ return toJSONSchema(schema, baseSchemaOptions);
662
623
  }
663
624
  const foundSchema = getPreferredSchema(response.content, opts?.contentType);
664
625
  if (opts?.contentType && !foundSchema) {
665
626
  return null;
666
627
  }
667
628
  if (foundSchema) {
668
- const schema = cloneObject(foundSchema);
629
+ const schema = structuredClone(foundSchema);
630
+ let schemaType = foundSchema.type;
631
+ if (schemaType === void 0 && isRef(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",
640
+ type: schemaType ?? "string",
674
641
  schema: isPrimitive(schema) ? schema : {
675
642
  ...schema,
676
643
  $schema: getSchemaVersionString(schema, api)
@@ -680,66 +647,55 @@ function getResponseAsJSONSchema(operation, api, statusCode, opts) {
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 && opts?.includeDiscriminatorMappingRefs) {
685
- schemaWrapper.schema.components = cloneObject(
686
- api.components
687
- );
650
+ applyDiscriminatorOneOfToUsedSchemas(api, usedSchemas, (ref) => {
651
+ if (usedSchemas.has(ref)) {
652
+ return usedSchemas.get(ref);
653
+ }
654
+ try {
655
+ const resolved = dereferenceRef({ $ref: ref }, api, seenRefs);
656
+ if (isRef(resolved)) return void 0;
657
+ const converted = toJSONSchema(structuredClone(resolved), {
658
+ ...baseSchemaOptions,
659
+ seenRefs
660
+ });
661
+ usedSchemas.set(ref, converted);
662
+ return converted;
663
+ } catch {
664
+ return void 0;
665
+ }
666
+ });
667
+ if (schemaWrapper.schema && usedSchemas.size > 0) {
668
+ const refsInGroup = refsByGroup.get("body") ?? /* @__PURE__ */ new Set();
669
+ const referencedSchemas = filterRequiredRefsToReferenced(refsInGroup, usedSchemas);
670
+ if (referencedSchemas.size > 0) {
671
+ mergeReferencedSchemasIntoRoot(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 && operation.operationId?.length);
701
- }
702
- function getOperationId(path, method, operation, opts = {}) {
703
- function sanitize(id) {
704
- return id.replace(opts?.camelCase || opts?.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 (opts?.camelCase || opts?.friendlyCase) {
715
- if (opts?.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 = refsByGroup.get("headers") ?? /* @__PURE__ */ new Set();
683
+ const referencedSchemas = filterRequiredRefsToReferenced(refsInGroup, usedSchemas);
684
+ if (referencedSchemas.size > 0) {
685
+ mergeReferencedSchemasIntoRoot(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
694
  var Operation = class {
695
+ /**
696
+ * The `Oas` instance that this operation belongs to.
697
+ */
698
+ oas;
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
  dereferencing;
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
+ schemasDecorated = false;
757
+ constructor(oas, path, method, operation) {
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;
@@ -954,14 +918,16 @@ var Operation = class {
954
918
  const keysWithTypes = keys.map((key) => {
955
919
  let security;
956
920
  try {
957
- if (!this.api.components?.securitySchemes?.[key] || isRef(this.api.components.securitySchemes[key])) {
958
- return false;
921
+ security = this.api?.components?.securitySchemes?.[key];
922
+ if (!security) return false;
923
+ if (isRef(security)) {
924
+ security = dereferenceRef(security, this.api);
925
+ if (!security || isRef(security)) return false;
959
926
  }
960
- security = this.api.components.securitySchemes[key];
961
927
  } catch {
962
928
  return false;
963
929
  }
964
- if (!security) return false;
930
+ if (!security || isRef(security)) return false;
965
931
  let type = null;
966
932
  if (security.type === "http") {
967
933
  if (security.scheme === "basic") type = "Basic";
@@ -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 (isRef(p)) {
1038
- return void 0;
1003
+ let param = p;
1004
+ if (isRef(param)) {
1005
+ param = dereferenceRef(param, this.api);
1006
+ if (!param || isRef(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 = this.schema.responses?.[r];
1048
- if (!response || isRef(response)) {
1049
- return [];
1015
+ let response = this.schema.responses[r];
1016
+ if (!response) return [];
1017
+ if (isRef(response)) {
1018
+ this.schema.responses[r] = dereferenceRef(response, this.api);
1019
+ response = this.schema.responses[r];
1020
+ if (!response || isRef(response)) {
1021
+ return [];
1022
+ }
1050
1023
  }
1051
1024
  return response?.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 && !isRef(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 (isRef(requestBody)) {
1031
+ this.schema.requestBody = dereferenceRef(requestBody, this.api);
1032
+ requestBody = this.schema.requestBody;
1033
+ }
1034
+ if (requestBody && !isRef(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 = this.schema.responses?.[r];
1063
- if (!response || isRef(response)) {
1064
- return false;
1040
+ const hasResponseContent = Object.keys(this.schema.responses).some((r) => {
1041
+ let response = this.schema.responses?.[r];
1042
+ if (!response) return false;
1043
+ if (isRef(response)) {
1044
+ this.schema.responses[r] = dereferenceRef(response, this.api);
1045
+ response = this.schema.responses[r];
1046
+ if (!response || isRef(response)) {
1047
+ return false;
1048
+ }
1065
1049
  }
1066
- return response?.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
  }
@@ -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 = (this.schema?.parameters || []).filter(
1168
- (param) => param && !isRef(param)
1169
- );
1170
- const commonParams = (this.api?.paths?.[this.path]?.parameters || []).filter(
1171
- (param) => param && !isRef(param)
1172
- );
1151
+ let parameters = (this.schema?.parameters || []).map((p) => {
1152
+ let param = p;
1153
+ if (isRef(param)) {
1154
+ param = dereferenceRef(param, this.api);
1155
+ if (!param || isRef(param)) return void 0;
1156
+ }
1157
+ return param;
1158
+ }).filter((param) => param !== void 0);
1159
+ const commonParams = (this.api?.paths?.[this.path]?.parameters || []).map((p) => {
1160
+ let param = p;
1161
+ if (isRef(param)) {
1162
+ param = dereferenceRef(param, this.api);
1163
+ if (!param || isRef(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 = {}) {
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
+ decorateComponentSchemasWithRefName(this.api);
1201
+ this.schemasDecorated = true;
1202
+ }
1193
1203
  return getParametersAsJSONSchema(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
+ decorateComponentSchemasWithRefName(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 (isRef(resp)) {
1256
+ resp = dereferenceRef(resp, this.api);
1257
+ if (!resp || isRef(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 (isRef(requestBody)) {
1285
+ this.schema.requestBody = dereferenceRef(requestBody, this.api);
1286
+ requestBody = this.schema.requestBody;
1287
+ if (!requestBody || isRef(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 || isRef(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 || isRef(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 || isRef(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;
@@ -1326,7 +1383,7 @@ var Operation = class {
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 || isRef(response)) {
1345
- return false;
1400
+ let response = this.schema.responses[statusCode];
1401
+ if (!response) return false;
1402
+ if (isRef(response)) {
1403
+ this.schema.responses[statusCode] = dereferenceRef(response, this.api);
1404
+ response = this.schema.responses[statusCode];
1405
+ if (!response || isRef(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 || isRef(callbackObj)) {
1384
- return false;
1444
+ let callbackObj = this.schema.callbacks[identifier];
1445
+ if (!callbackObj) return false;
1446
+ if (isRef(callbackObj)) {
1447
+ this.schema.callbacks[identifier] = dereferenceRef(callbackObj, this.api);
1448
+ callbackObj = this.schema.callbacks[identifier];
1449
+ if (!callbackObj || isRef(callbackObj)) {
1450
+ return false;
1451
+ }
1452
+ }
1453
+ let callback = callbackObj[expression];
1454
+ if (!callback) return false;
1455
+ if (isRef(callback)) {
1456
+ callbackObj[expression] = dereferenceRef(callback, this.api);
1457
+ callback = callbackObj[expression];
1458
+ if (!callback || isRef(callback)) {
1459
+ return false;
1460
+ }
1385
1461
  }
1386
- const callback = callbackObj[expression];
1387
- if (!callback || isRef(callback) || !callback[method]) {
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,17 +1473,27 @@ 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 = this.schema.callbacks?.[callback];
1403
- if (!cb || isRef(cb)) {
1404
- return;
1476
+ Object.keys(this.schema.callbacks).forEach((callback) => {
1477
+ let cb = this.schema.callbacks?.[callback];
1478
+ if (!cb) return;
1479
+ if (isRef(cb)) {
1480
+ this.schema.callbacks[callback] = dereferenceRef(cb, this.api);
1481
+ cb = this.schema.callbacks[callback];
1482
+ if (!cb || isRef(cb)) {
1483
+ return;
1484
+ }
1405
1485
  }
1406
1486
  Object.keys(cb).forEach((expression) => {
1407
- const exp = cb[expression];
1408
- if (!exp || isRef(exp)) {
1409
- return;
1487
+ let callbackPath = cb[expression];
1488
+ if (!callbackPath) return;
1489
+ if (isRef(callbackPath)) {
1490
+ cb[expression] = dereferenceRef(callbackPath, this.api);
1491
+ callbackPath = cb[expression];
1492
+ if (!callbackPath || isRef(callbackPath)) {
1493
+ return;
1494
+ }
1410
1495
  }
1411
- Object.keys(exp).forEach((method) => {
1496
+ Object.keys(callbackPath).forEach((method) => {
1412
1497
  if (!supportedMethods.includes(method)) return;
1413
1498
  const found = this.getCallback(callback, expression, method);
1414
1499
  if (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
  /**
@@ -1486,16 +1571,11 @@ 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 (api?.components?.schemas && typeof api.components.schemas === "object") {
1492
- Object.keys(api.components.schemas).forEach((schemaName) => {
1493
- if (isPrimitive(api.components?.schemas?.[schemaName]) || Array.isArray(api.components?.schemas?.[schemaName]) || api.components?.schemas?.[schemaName] === null) {
1494
- return;
1495
- }
1496
- (api.components?.schemas?.[schemaName])["x-readme-ref-name"] = schemaName;
1497
- });
1574
+ if (!this.schemasDecorated) {
1575
+ decorateComponentSchemasWithRefName(this.api);
1576
+ this.schemasDecorated = true;
1498
1577
  }
1578
+ const { api, schema, promises } = this;
1499
1579
  const circularRefs = /* @__PURE__ */ new Set();
1500
1580
  const dereferencingOptions = getDereferencingOptions(circularRefs);
1501
1581
  const parser = new $RefParser();
@@ -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 (dereferenced?.components?.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 = {
@@ -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
  *
@@ -1610,6 +1681,12 @@ 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
1691
  if (this.schema?.summary && typeof this.schema.summary === "string") {
1615
1692
  return this.schema.summary;
@@ -1618,6 +1695,12 @@ var Callback = class extends Operation {
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
1705
  if (this.schema?.description && typeof this.schema.description === "string") {
1623
1706
  return this.schema.description;
@@ -1626,9 +1709,29 @@ var Callback = class extends Operation {
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 = this.schema?.parameters || [];
1631
- const commonParams = this.parentSchema.parameters || [];
1719
+ let parameters = (this.schema?.parameters || []).map((p) => {
1720
+ let param = p;
1721
+ if (isRef(param)) {
1722
+ param = dereferenceRef(param, this.api);
1723
+ if (!param || isRef(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 (isRef(param)) {
1730
+ param = dereferenceRef(param, this.api);
1731
+ if (!param || isRef(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,35 +1739,47 @@ 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
1749
  if (this.schema?.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 = this.api.webhooks?.[this.path];
1644
- if (webhookPath && !isRef(webhookPath)) {
1645
- if (webhookPath?.summary && typeof webhookPath.summary === "string") {
1646
- return webhookPath.summary;
1647
- }
1754
+ let webhookPath = this.api.webhooks[this.path];
1755
+ if (isRef(webhookPath)) {
1756
+ this.api.webhooks[this.path] = dereferenceRef(webhookPath, this.api);
1757
+ webhookPath = this.api.webhooks[this.path];
1648
1758
  }
1649
- return void 0;
1759
+ return webhookPath?.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
1768
  if (this.schema?.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 = this.api.webhooks?.[this.path];
1656
- if (webhookPath && !isRef(webhookPath)) {
1657
- if (webhookPath?.description && typeof webhookPath.description === "string") {
1658
- return webhookPath.description;
1659
- }
1773
+ let webhookPath = this.api.webhooks[this.path];
1774
+ if (isRef(webhookPath)) {
1775
+ this.api.webhooks[this.path] = dereferenceRef(webhookPath, this.api);
1776
+ webhookPath = this.api.webhooks[this.path];
1660
1777
  }
1661
- return void 0;
1778
+ return webhookPath?.description;
1662
1779
  }
1663
1780
  };
1664
1781
 
1665
1782
  export {
1666
- findDiscriminatorChildren,
1667
- buildDiscriminatorOneOf,
1668
1783
  Operation,
1669
1784
  Callback,
1670
1785
  Webhook
@@ -1681,4 +1796,4 @@ export {
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-HGVFNEKW.js.map
1799
+ //# sourceMappingURL=chunk-ORCSXEZP.js.map