oas 38.5.2 → 38.6.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 (59) hide show
  1. package/dist/analyzer/index.cjs +17 -17
  2. package/dist/analyzer/index.cjs.map +1 -1
  3. package/dist/analyzer/index.js +2 -2
  4. package/dist/analyzer/types.cjs.map +1 -1
  5. package/dist/{chunk-A7BAE2SN.js → chunk-3X7ZLPYE.js} +26 -19
  6. package/dist/chunk-3X7ZLPYE.js.map +1 -0
  7. package/dist/{chunk-EARDDQSB.cjs → chunk-47FD2BIN.cjs} +5 -2
  8. package/dist/chunk-47FD2BIN.cjs.map +1 -0
  9. package/dist/{chunk-7LQKUYC7.js → chunk-5745XRSJ.js} +3 -3
  10. package/dist/chunk-7PWF3F2W.cjs.map +1 -1
  11. package/dist/chunk-COHEPMUP.cjs.map +1 -1
  12. package/dist/{chunk-T4AJWZEL.cjs → chunk-HQEDOVWO.cjs} +47 -32
  13. package/dist/chunk-HQEDOVWO.cjs.map +1 -0
  14. package/dist/{chunk-DYHV2B4Z.js → chunk-JHDEAXSK.js} +4 -1
  15. package/dist/chunk-JHDEAXSK.js.map +1 -0
  16. package/dist/{chunk-MYFJ2GV3.cjs → chunk-OBYCSKPS.cjs} +28 -21
  17. package/dist/chunk-OBYCSKPS.cjs.map +1 -0
  18. package/dist/{chunk-IV2FDFXA.js → chunk-PZR3GKKO.js} +19 -4
  19. package/dist/chunk-PZR3GKKO.js.map +1 -0
  20. package/dist/{chunk-JQGHPVGV.cjs → chunk-RUHLHK66.cjs} +74 -74
  21. package/dist/chunk-RUHLHK66.cjs.map +1 -0
  22. package/dist/extensions.cjs +4 -2
  23. package/dist/extensions.cjs.map +1 -1
  24. package/dist/extensions.d.cts +1 -1
  25. package/dist/extensions.d.ts +1 -1
  26. package/dist/extensions.js +3 -1
  27. package/dist/{index-C6OzXwLp.d.ts → index-B097koLb.d.ts} +2 -0
  28. package/dist/{index-C4bupNyk.d.cts → index-BmHgGqbY.d.cts} +2 -0
  29. package/dist/index.cjs +53 -53
  30. package/dist/index.cjs.map +1 -1
  31. package/dist/index.d.cts +19 -1
  32. package/dist/index.d.ts +19 -1
  33. package/dist/index.js +3 -3
  34. package/dist/operation/index.cjs +4 -4
  35. package/dist/operation/index.cjs.map +1 -1
  36. package/dist/operation/index.js +3 -3
  37. package/dist/pruner/index.cjs +5 -5
  38. package/dist/pruner/index.cjs.map +1 -1
  39. package/dist/pruner/index.d.cts +1 -1
  40. package/dist/pruner/index.d.ts +1 -1
  41. package/dist/pruner/index.js +4 -4
  42. package/dist/reducer/index.cjs +5 -5
  43. package/dist/reducer/index.cjs.map +1 -1
  44. package/dist/reducer/index.d.cts +1 -1
  45. package/dist/reducer/index.d.ts +1 -1
  46. package/dist/reducer/index.js +4 -4
  47. package/dist/types.cjs.map +1 -1
  48. package/dist/utils.cjs +3 -3
  49. package/dist/utils.cjs.map +1 -1
  50. package/dist/utils.js +2 -2
  51. package/package.json +1 -1
  52. package/dist/chunk-A7BAE2SN.js.map +0 -1
  53. package/dist/chunk-DYHV2B4Z.js.map +0 -1
  54. package/dist/chunk-EARDDQSB.cjs.map +0 -1
  55. package/dist/chunk-IV2FDFXA.js.map +0 -1
  56. package/dist/chunk-JQGHPVGV.cjs.map +0 -1
  57. package/dist/chunk-MYFJ2GV3.cjs.map +0 -1
  58. package/dist/chunk-T4AJWZEL.cjs.map +0 -1
  59. /package/dist/{chunk-7LQKUYC7.js.map → chunk-5745XRSJ.js.map} +0 -0
@@ -3,12 +3,13 @@
3
3
  var _chunkCOHEPMUPcjs = require('./chunk-COHEPMUP.cjs');
4
4
 
5
5
 
6
- var _chunkJQGHPVGVcjs = require('./chunk-JQGHPVGV.cjs');
6
+ var _chunkRUHLHK66cjs = require('./chunk-RUHLHK66.cjs');
7
7
 
8
8
 
9
9
 
10
10
 
11
- var _chunkMYFJ2GV3cjs = require('./chunk-MYFJ2GV3.cjs');
11
+
12
+ var _chunkOBYCSKPScjs = require('./chunk-OBYCSKPS.cjs');
12
13
 
13
14
 
14
15
 
@@ -102,10 +103,12 @@ var OpenAPITransformer = (_class2 = class {
102
103
  * retaining them would result in an invalid OpenAPI definition.
103
104
  */
104
105
  __init2() {this.$refs = /* @__PURE__ */ new Set()}
106
+ /** Inheritance dependencies discovered by the same helper used for JSON Schema generation. */
107
+ __init3() {this.discriminatorChildrenByParentRef = /* @__PURE__ */ new Map()}
105
108
  /**
106
109
  * A collection of OpenAPI tags that are used within the transformed API definition.
107
110
  */
108
- __init3() {this.usedTags = /* @__PURE__ */ new Set()}
111
+ __init4() {this.usedTags = /* @__PURE__ */ new Set()}
109
112
  /**
110
113
  * A collection of OpenAPI paths and operations that are cross-referenced from any other paths
111
114
  * and operations that we're retaining. This collection is used to ensure that those operations
@@ -114,13 +117,13 @@ var OpenAPITransformer = (_class2 = class {
114
117
  *
115
118
  * A `*` method means the entire Path Item is referenced (e.g. `$ref: '#/paths/~1pets'`).
116
119
  */
117
- __init4() {this.retainPathMethods = /* @__PURE__ */ new Set()}
120
+ __init5() {this.retainPathMethods = /* @__PURE__ */ new Set()}
118
121
  /**
119
122
  * Paths whose Path Item *fields* (parameters, servers, summary, …) are referenced without
120
123
  * targeting a specific operation. The path container must remain even if every HTTP operation is
121
124
  * filtered out.
122
125
  */
123
- __init5() {this.retainPathContainers = /* @__PURE__ */ new Set()}
126
+ __init6() {this.retainPathContainers = /* @__PURE__ */ new Set()}
124
127
  /**
125
128
  * A collection of OpenAPI webhook names and methods that are cross-referenced from any other
126
129
  * schemas. This collection, like `retainPathMethods`, is used to ensure that those operations are
@@ -129,30 +132,40 @@ var OpenAPITransformer = (_class2 = class {
129
132
  *
130
133
  * A `*` method means the entire webhook Path Item is referenced (e.g. `$ref: '#/webhooks/newPet'`).
131
134
  */
132
- __init6() {this.retainWebhookMethods = /* @__PURE__ */ new Set()}
135
+ __init7() {this.retainWebhookMethods = /* @__PURE__ */ new Set()}
133
136
  /**
134
137
  * Webhooks whose Path Item fields are referenced without targeting a specific operation.
135
138
  */
136
- __init7() {this.retainWebhookContainers = /* @__PURE__ */ new Set()}
139
+ __init8() {this.retainWebhookContainers = /* @__PURE__ */ new Set()}
137
140
  /** An array of OpenAPI tags selected for the current transformation. */
138
- __init8() {this.tagSelection = []}
141
+ __init9() {this.tagSelection = []}
139
142
  /** A collection of operation IDs selected for the current transformation. */
140
- __init9() {this.operationIdSelection = /* @__PURE__ */ new Set()}
143
+ __init10() {this.operationIdSelection = /* @__PURE__ */ new Set()}
141
144
  /** A collection of OpenAPI paths and operations selected for the current transformation. */
142
- __init10() {this.pathSelection = new OperationSelection()}
145
+ __init11() {this.pathSelection = new OperationSelection()}
143
146
  /** A collection of OpenAPI webhooks selected for the current transformation. */
144
- __init11() {this.webhookSelection = new OperationSelection()}
145
- __init12() {this.hasTagSelection = false}
146
- __init13() {this.hasOperationIdSelection = false}
147
- __init14() {this.hasPathSelection = false}
148
- __init15() {this.hasWebhookSelection = false}
147
+ __init12() {this.webhookSelection = new OperationSelection()}
148
+ __init13() {this.hasTagSelection = false}
149
+ __init14() {this.hasOperationIdSelection = false}
150
+ __init15() {this.hasPathSelection = false}
151
+ __init16() {this.hasWebhookSelection = false}
149
152
  /**
150
153
  * @param definition OpenAPI definition to transform.
151
154
  * @param options Transformation mode.
152
155
  */
153
- constructor(definition, options) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);
156
+ constructor(definition, options) {;_class2.prototype.__init2.call(this);_class2.prototype.__init3.call(this);_class2.prototype.__init4.call(this);_class2.prototype.__init5.call(this);_class2.prototype.__init6.call(this);_class2.prototype.__init7.call(this);_class2.prototype.__init8.call(this);_class2.prototype.__init9.call(this);_class2.prototype.__init10.call(this);_class2.prototype.__init11.call(this);_class2.prototype.__init12.call(this);_class2.prototype.__init13.call(this);_class2.prototype.__init14.call(this);_class2.prototype.__init15.call(this);_class2.prototype.__init16.call(this);
154
157
  this.definition = structuredClone(definition);
155
158
  this.mode = options.mode;
159
+ const { children, refs } = _chunkOBYCSKPScjs.findDiscriminatorChildren.call(void 0, this.definition);
160
+ children.forEach((childNames, parentName) => {
161
+ const parentRef = refs.get(parentName);
162
+ if (parentRef) {
163
+ this.discriminatorChildrenByParentRef.set(
164
+ parentRef,
165
+ childNames.flatMap((name) => _nullishCoalesce(refs.get(name), () => ( [])))
166
+ );
167
+ }
168
+ });
156
169
  }
157
170
  /**
158
171
  * Select an OpenAPI tag. Operations with this tag are retained when reducing and removed when
@@ -254,7 +267,7 @@ var OpenAPITransformer = (_class2 = class {
254
267
  if ("components" in this.definition) {
255
268
  Object.keys(this.definition.components || {}).forEach((componentType) => {
256
269
  Object.keys(_optionalChain([this, 'access', _3 => _3.definition, 'access', _4 => _4.components, 'optionalAccess', _5 => _5[componentType]]) || {}).forEach((component) => {
257
- const componentPointer = `#/components/${componentType}/${_chunkMYFJ2GV3cjs.encodePointer.call(void 0, component)}`;
270
+ const componentPointer = `#/components/${componentType}/${_chunkOBYCSKPScjs.encodePointer.call(void 0, component)}`;
258
271
  const refIsUsed = this.$refs.has(componentPointer) || Array.from(this.$refs).some((ref) => {
259
272
  return ref.startsWith(`${componentPointer}/`);
260
273
  });
@@ -298,7 +311,9 @@ var OpenAPITransformer = (_class2 = class {
298
311
  if ($refSchema === void 0) {
299
312
  return;
300
313
  }
301
- this.queryForRefPointers($refSchema).forEach(({ value: currRef }) => {
314
+ const referencedValues = this.queryForRefPointers($refSchema).map(({ value }) => value);
315
+ referencedValues.push(..._nullishCoalesce(this.discriminatorChildrenByParentRef.get($ref), () => ( [])));
316
+ referencedValues.forEach((currRef) => {
302
317
  const foundRef = this.toRefString(currRef);
303
318
  if (!foundRef) {
304
319
  return;
@@ -348,12 +363,12 @@ var OpenAPITransformer = (_class2 = class {
348
363
  if (!_optionalChain([match, 'optionalAccess', _19 => _19[1]])) {
349
364
  return null;
350
365
  }
351
- const path = _chunkMYFJ2GV3cjs.decodePointer.call(void 0, match[1]);
366
+ const path = _chunkOBYCSKPScjs.decodePointer.call(void 0, match[1]);
352
367
  const segment = match[2];
353
368
  if (!segment) {
354
369
  return { path, retention: "all" };
355
370
  }
356
- if (_chunkMYFJ2GV3cjs.supportedMethods.includes(segment.toLowerCase())) {
371
+ if (_chunkOBYCSKPScjs.supportedMethods.includes(segment.toLowerCase())) {
357
372
  return { path, method: segment, retention: "operation" };
358
373
  }
359
374
  return { path, retention: "container" };
@@ -370,12 +385,12 @@ var OpenAPITransformer = (_class2 = class {
370
385
  if (!_optionalChain([match, 'optionalAccess', _20 => _20[1]])) {
371
386
  return null;
372
387
  }
373
- const name = _chunkMYFJ2GV3cjs.decodePointer.call(void 0, match[1]);
388
+ const name = _chunkOBYCSKPScjs.decodePointer.call(void 0, match[1]);
374
389
  const segment = match[2];
375
390
  if (!segment) {
376
391
  return { name, retention: "all" };
377
392
  }
378
- if (_chunkMYFJ2GV3cjs.supportedMethods.includes(segment.toLowerCase())) {
393
+ if (_chunkOBYCSKPScjs.supportedMethods.includes(segment.toLowerCase())) {
379
394
  return { name, method: segment, retention: "operation" };
380
395
  }
381
396
  return { name, retention: "container" };
@@ -398,7 +413,7 @@ var OpenAPITransformer = (_class2 = class {
398
413
  * so they match the same form used for authored `$ref`s (`foo/bar` → `foo~1bar`).
399
414
  */
400
415
  retainSecurityScheme(scheme) {
401
- this.$refs.add(`#/components/securitySchemes/${_chunkMYFJ2GV3cjs.encodePointer.call(void 0, scheme)}`);
416
+ this.$refs.add(`#/components/securitySchemes/${_chunkOBYCSKPScjs.encodePointer.call(void 0, scheme)}`);
402
417
  }
403
418
  /** Record a `#/paths` `$ref` so the target Path Item or operation is not dropped. */
404
419
  recordPathRef($ref) {
@@ -463,7 +478,7 @@ var OpenAPITransformer = (_class2 = class {
463
478
  return;
464
479
  }
465
480
  Object.entries(pathItem).forEach(([key, value]) => {
466
- if (_chunkMYFJ2GV3cjs.supportedMethods.includes(key.toLowerCase()) || value === void 0) {
481
+ if (_chunkOBYCSKPScjs.supportedMethods.includes(key.toLowerCase()) || value === void 0) {
467
482
  return;
468
483
  }
469
484
  this.queryForRefPointers(value).forEach(({ value: ref }) => {
@@ -519,7 +534,7 @@ var OpenAPITransformer = (_class2 = class {
519
534
  shouldRetainOperation(selection, key, method, operation) {
520
535
  if (this.mode === "reduce") {
521
536
  if (selection.hasSelections && !selection.matches(key, method)) return false;
522
- if (this.hasOperationIdSelection && !this.operationIdSelection.has(_chunkJQGHPVGVcjs.Operation.getOperationId(key, method, operation))) {
537
+ if (this.hasOperationIdSelection && !this.operationIdSelection.has(_chunkRUHLHK66cjs.Operation.getOperationId(key, method, operation))) {
523
538
  return false;
524
539
  }
525
540
  if (this.hasTagSelection && !(operation.tags || []).some((tag) => this.tagSelection.includes(tag.toLowerCase()))) {
@@ -527,7 +542,7 @@ var OpenAPITransformer = (_class2 = class {
527
542
  }
528
543
  } else {
529
544
  if (selection.hasSelections && selection.matches(key, method)) return false;
530
- if (this.hasOperationIdSelection && this.operationIdSelection.has(_chunkJQGHPVGVcjs.Operation.getOperationId(key, method, operation))) {
545
+ if (this.hasOperationIdSelection && this.operationIdSelection.has(_chunkRUHLHK66cjs.Operation.getOperationId(key, method, operation))) {
531
546
  return false;
532
547
  }
533
548
  if (this.hasTagSelection && (operation.tags || []).some((tag) => this.tagSelection.includes(tag.toLowerCase()))) {
@@ -538,7 +553,7 @@ var OpenAPITransformer = (_class2 = class {
538
553
  }
539
554
  /** Determine whether a path item contains at least one HTTP operation. */
540
555
  hasOperations(pathItem) {
541
- return Boolean(pathItem && _chunkMYFJ2GV3cjs.supportedMethods.some((method) => method in pathItem));
556
+ return Boolean(pathItem && _chunkOBYCSKPScjs.supportedMethods.some((method) => method in pathItem));
542
557
  }
543
558
  /**
544
559
  * Accumulate any `$ref` pointers that are used by common Path Item parameters.
@@ -583,7 +598,7 @@ var OpenAPITransformer = (_class2 = class {
583
598
  this.accumulateParameterRefs(_optionalChain([pathItem, 'optionalAccess', _27 => _27.parameters]));
584
599
  }
585
600
  Object.keys(pathItem || {}).forEach((method) => {
586
- if (method === "parameters" || !_chunkMYFJ2GV3cjs.supportedMethods.includes(method.toLowerCase())) {
601
+ if (method === "parameters" || !_chunkOBYCSKPScjs.supportedMethods.includes(method.toLowerCase())) {
587
602
  return;
588
603
  }
589
604
  const operation = _optionalChain([this, 'access', _28 => _28.definition, 'access', _29 => _29.paths, 'optionalAccess', _30 => _30[path], 'optionalAccess', _31 => _31[method]]);
@@ -642,7 +657,7 @@ var OpenAPITransformer = (_class2 = class {
642
657
  this.accumulateParameterRefs(webhook.parameters);
643
658
  }
644
659
  Object.keys(webhook).forEach((method) => {
645
- if (method === "parameters" || !_chunkMYFJ2GV3cjs.supportedMethods.includes(method.toLowerCase())) {
660
+ if (method === "parameters" || !_chunkOBYCSKPScjs.supportedMethods.includes(method.toLowerCase())) {
646
661
  return;
647
662
  }
648
663
  const operation = webhook[method];
@@ -699,7 +714,7 @@ var OpenAPITransformer = (_class2 = class {
699
714
  let removedOperation = false;
700
715
  Object.keys(pathItem || {}).forEach((method) => {
701
716
  const methodLC = method.toLowerCase();
702
- if (method === "parameters" || !_chunkMYFJ2GV3cjs.supportedMethods.includes(methodLC)) {
717
+ if (method === "parameters" || !_chunkOBYCSKPScjs.supportedMethods.includes(methodLC)) {
703
718
  return;
704
719
  }
705
720
  const retainedByRef = this.isPathOperationRetainedByRef(pathLC, methodLC);
@@ -779,7 +794,7 @@ var OpenAPITransformer = (_class2 = class {
779
794
  let removedOperation = false;
780
795
  Object.keys(webhook).forEach((method) => {
781
796
  const methodLC = method.toLowerCase();
782
- if (method === "parameters" || !_chunkMYFJ2GV3cjs.supportedMethods.includes(methodLC)) {
797
+ if (method === "parameters" || !_chunkOBYCSKPScjs.supportedMethods.includes(methodLC)) {
783
798
  return;
784
799
  }
785
800
  const operation = webhook[method];
@@ -822,4 +837,4 @@ var OpenAPITransformer = (_class2 = class {
822
837
 
823
838
 
824
839
  exports.OpenAPITransformer = OpenAPITransformer;
825
- //# sourceMappingURL=chunk-T4AJWZEL.cjs.map
840
+ //# sourceMappingURL=chunk-HQEDOVWO.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/darrenyong/Desktop/oas-stuff/oas/packages/oas/dist/chunk-HQEDOVWO.cjs","../src/lib/transformer/index.ts","../src/lib/transformer/operation-selection.ts"],"names":[],"mappings":"AAAA;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACF,wDAA6B;AAC7B;AACA;ACPA,oGAAwB;ADSxB;AACA;AEhBO,IAAM,mBAAA,YAAN,MAAyB;AAAA,iBACtB,WAAA,kBAA6C,IAAI,GAAA,CAAI,EAAA;AAAA;AAAA,EAG7D,IAAI,aAAA,CAAA,EAAyB;AAC3B,IAAA,OAAO,IAAA,CAAK,UAAA,CAAW,KAAA,EAAO,CAAA;AAAA,EAChC;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EAOA,MAAA,CAAO,GAAA,EAAmB;AACxB,IAAA,IAAA,CAAK,UAAA,CAAW,GAAA,CAAI,IAAA,CAAK,SAAA,CAAU,GAAG,CAAA,EAAG,GAAG,CAAA;AAAA,EAC9C;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA,EASA,YAAA,CAAa,GAAA,EAAa,MAAA,EAAsB;AAC9C,IAAA,MAAM,cAAA,EAAgB,IAAA,CAAK,SAAA,CAAU,GAAG,CAAA;AACxC,IAAA,MAAM,iBAAA,EAAmB,IAAA,CAAK,SAAA,CAAU,MAAM,CAAA;AAC9C,IAAA,MAAM,UAAA,EAAY,IAAA,CAA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AACF,EAAA;AAAA;AAAA;AAAA;AAKkC,EAAA;AACG,IAAA;AACjC,MAAA;AACwE,IAAA;AACxE,MAAA;AACF,IAAA;AAEwB,IAAA;AAEsC,IAAA;AACrB,MAAA;AAC0C,MAAA;AAEpC,MAAA;AACF,QAAA;AACe,UAAA;AACxD,QAAA;AAEwC,QAAA;AACxC,QAAA;AACF,MAAA;AAEiD,MAAA;AACJ,MAAA;AAC3C,QAAA;AACF,MAAA;AAOoB,MAAA;AAC0C,QAAA;AAClB,UAAA;AAC1C,QAAA;AAEA,QAAA;AACF,MAAA;AAEuB,MAAA;AACgB,MAAA;AACD,QAAA;AACgD,QAAA;AAClF,UAAA;AACF,QAAA;AAE+C,QAAA;AAC/B,QAAA;AAC4D,UAAA;AAC5E,QAAA;AAE2E,QAAA;AACF,QAAA;AAC3B,UAAA;AAChC,YAAA;AACwD,cAAA;AAClE,YAAA;AACF,UAAA;AAEoB,UAAA;AACkB,YAAA;AACjB,YAAA;AACnB,YAAA;AACF,UAAA;AACF,QAAA;AAI+C,QAAA;AAEC,QAAA;AACzB,UAAA;AACtB,QAAA;AAEsD,QAAA;AAClB,UAAA;AACD,YAAA;AACjC,UAAA;AACF,QAAA;AACF,MAAA;AAIuC,MAAA;AAGE,QAAA;AAC1C,MAAA;AACD,IAAA;AAEoE,IAAA;AACjD,MAAA;AACpB,IAAA;AACF,EAAA;AACF;AD7N6F;AACA;AACA;AACA","file":"/Users/darrenyong/Desktop/oas-stuff/oas/packages/oas/dist/chunk-HQEDOVWO.cjs","sourcesContent":[null,"import type {\n ComponentsObject,\n HttpMethods,\n OASDocument,\n OperationObject,\n PathItemObject,\n TagObject,\n} from '../../types.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport jsonPointer from 'jsonpointer';\n\nimport { query } from '../../analyzer/util.js';\nimport { Operation } from '../../operation/index.js';\nimport { isOpenAPI31, isRef } from '../../types.js';\nimport { supportedMethods } from '../../utils.js';\nimport { findDiscriminatorChildren } from '../build-discriminator-one-of.js';\nimport { decodePointer, encodePointer } from '../refs.js';\n\nimport { OperationSelection } from './operation-selection.js';\n\ninterface OpenAPITransformerOptions {\n /** Whether selected paths, operations, and webhooks should be retained or removed. */\n mode: 'prune' | 'reduce';\n}\n\n/**\n * Internal engine for selecting operations and transforming an OpenAPI definition down to its\n * reachable paths, webhooks, components, and tags.\n */\nexport class OpenAPITransformer {\n private definition: OASDocument;\n\n private readonly mode: 'prune' | 'reduce';\n\n /**\n * A collection of `$ref` pointers that are used within our transformed API definition. This is\n * used to ensure that all referenced schemas are retained in our resulting API definition. Not\n * retaining them would result in an invalid OpenAPI definition.\n */\n private $refs: Set<string> = new Set();\n\n /** Inheritance dependencies discovered by the same helper used for JSON Schema generation. */\n private discriminatorChildrenByParentRef = new Map<string, string[]>();\n\n /**\n * A collection of OpenAPI tags that are used within the transformed API definition.\n */\n private usedTags: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI paths and operations that are cross-referenced from any other paths\n * and operations that we're retaining. This collection is used to ensure that those operations\n * are retained in our resulting API definition. Not retaining them would result in an invalid\n * OpenAPI definition.\n *\n * A `*` method means the entire Path Item is referenced (e.g. `$ref: '#/paths/~1pets'`).\n */\n private retainPathMethods: Set<`${string}|${string}`> = new Set();\n\n /**\n * Paths whose Path Item *fields* (parameters, servers, summary, …) are referenced without\n * targeting a specific operation. The path container must remain even if every HTTP operation is\n * filtered out.\n */\n private retainPathContainers: Set<string> = new Set();\n\n /**\n * A collection of OpenAPI webhook names and methods that are cross-referenced from any other\n * schemas. This collection, like `retainPathMethods`, is used to ensure that those operations are\n * retained in our resulting API definition. Not retaining them would result in an invalid\n * OpenAPI definition.\n *\n * A `*` method means the entire webhook Path Item is referenced (e.g. `$ref: '#/webhooks/newPet'`).\n */\n private retainWebhookMethods: Set<`${string}|${string}`> = new Set();\n\n /**\n * Webhooks whose Path Item fields are referenced without targeting a specific operation.\n */\n private retainWebhookContainers: Set<string> = new Set();\n\n /** An array of OpenAPI tags selected for the current transformation. */\n private tagSelection: string[] = [];\n\n /** A collection of operation IDs selected for the current transformation. */\n private operationIdSelection = new Set<string>();\n\n /** A collection of OpenAPI paths and operations selected for the current transformation. */\n private pathSelection = new OperationSelection();\n\n /** A collection of OpenAPI webhooks selected for the current transformation. */\n private webhookSelection = new OperationSelection();\n\n private hasTagSelection: boolean = false;\n private hasOperationIdSelection: boolean = false;\n private hasPathSelection: boolean = false;\n private hasWebhookSelection: boolean = false;\n\n /**\n * @param definition OpenAPI definition to transform.\n * @param options Transformation mode.\n */\n protected constructor(definition: OASDocument, options: OpenAPITransformerOptions) {\n this.definition = structuredClone(definition);\n this.mode = options.mode;\n\n const { children, refs } = findDiscriminatorChildren(this.definition);\n children.forEach((childNames, parentName) => {\n const parentRef = refs.get(parentName);\n if (parentRef) {\n this.discriminatorChildrenByParentRef.set(\n parentRef,\n childNames.flatMap(name => refs.get(name) ?? []),\n );\n }\n });\n }\n\n /**\n * Select an OpenAPI tag. Operations with this tag are retained when reducing and removed when\n * pruning. Tag casing does not matter.\n *\n * @param tag Tag to select.\n */\n protected selectTag(tag: string): void {\n this.tagSelection.push(tag.toLowerCase());\n }\n\n /**\n * Select an entire OpenAPI path and all operations that it contains. Selected paths are retained\n * when reducing and removed when pruning. Path casing does not matter.\n *\n * @param path Path to select.\n */\n protected selectPath(path: string): void {\n this.pathSelection.addAll(path);\n }\n\n /**\n * Select a single OpenAPI operation. Selected operations are retained when reducing and removed\n * when pruning. Path and method casing does not matter.\n *\n * In reduce mode, selecting an operation after its entire path replaces the all-operation\n * selection with that operation and any operations selected afterward. Prune mode keeps the\n * entire path selected.\n *\n * @param path Path containing the operation.\n * @param method HTTP method of the operation to select.\n */\n protected selectOperation(path: string, method: string): void {\n if (this.mode === 'reduce' && this.pathSelection.matchesAll(path)) {\n this.pathSelection.clear(path);\n }\n\n this.pathSelection.addOperation(path, method);\n }\n\n /**\n * Select an OpenAPI operation by its operation ID. IDs are matched exactly and are generated\n * from the operation path and method when one is not authored in the definition.\n *\n * @param operationId Operation ID to select.\n */\n protected selectOperationId(operationId: string): void {\n this.operationIdSelection.add(operationId);\n }\n\n /**\n * Select an OpenAPI webhook or one of its operations. Selected webhooks are retained when\n * reducing and removed when pruning. Webhook and method casing does not matter.\n *\n * @param webhookName Webhook to select.\n * @param method Optional HTTP method of an individual webhook operation to select.\n */\n protected selectWebhook(webhookName: string, method?: string): void {\n if (!method) {\n this.webhookSelection.addAll(webhookName);\n return;\n }\n\n if (this.mode === 'reduce' && this.webhookSelection.matchesAll(webhookName)) {\n this.webhookSelection.clear(webhookName);\n }\n\n this.webhookSelection.addOperation(webhookName, method);\n }\n\n /** Transform the OpenAPI definition according to the configured mode and selections. */\n protected transform(): OASDocument {\n if (!this.definition.openapi) {\n throw new Error('Sorry, only OpenAPI definitions are supported.');\n }\n\n this.hasTagSelection = Boolean(this.tagSelection.length);\n this.hasOperationIdSelection = this.operationIdSelection.size > 0;\n this.hasPathSelection = this.pathSelection.hasSelections;\n this.hasWebhookSelection = this.webhookSelection.hasSelections;\n\n // Retain any root-level security definitions, regardless if they're used or not on operations\n // that we're retaining.\n if ('security' in this.definition) {\n Object.values(this.definition.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n }\n\n this.walkPaths();\n this.walkWebhooks();\n\n // Recursively accumulate any components that are in use.\n this.$refs.forEach($ref => {\n this.accumulateUsedRefs(this.definition, this.$refs, $ref);\n });\n\n this.$refs.forEach(ref => {\n this.recordPathRef(ref);\n this.recordWebhookRef(ref);\n });\n\n /**\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n * Targets of those `$ref`s are already retained (see `retainReferencedPathItem`).\n */\n this.transformPaths();\n this.transformWebhooks();\n\n // Require at least one path or one webhook in the result.\n const hasPaths = Boolean(this.definition.paths && Object.keys(this.definition.paths).length);\n const hasWebhooks = Boolean(\n 'webhooks' in this.definition && this.definition.webhooks && Object.keys(this.definition.webhooks).length,\n );\n\n // If we don't have any paths or webhooks left, retain the reducer's no-match error to help catch\n // invalid selections. An empty definition is valid OpenAPI so we allow it when pruning.\n if (this.mode === 'reduce' && !hasPaths && !hasWebhooks) {\n throw new Error(\n 'All paths and webhooks in the API definition were removed. Did you supply the right path, operation, or webhook to reduce by?',\n );\n }\n\n // Remove any unused components.\n if ('components' in this.definition) {\n Object.keys(this.definition.components || {}).forEach(componentType => {\n Object.keys(this.definition.components?.[componentType as keyof ComponentsObject] || {}).forEach(component => {\n // Authored `$ref`s JSON-Pointer-encode `/` and `~` in the component name\n // (`foo/bar` → `foo~1bar`). Compare against that encoded form or cleanup\n // deletes a still-referenced target.\n const componentPointer = `#/components/${componentType}/${encodePointer(component)}`;\n const refIsUsed =\n this.$refs.has(componentPointer) ||\n Array.from(this.$refs).some(ref => {\n // Because you can have a `$ref` like `#/components/examples/event-min/value`, which\n // would be accumulated via our `$refs` query, we want to make sure we account for them.\n // If we don't look for these then we'll end up removing them from the transformed\n // definition, resulting in data loss and schema corruption.\n return ref.startsWith(`${componentPointer}/`);\n });\n\n if (!refIsUsed) {\n delete this.definition.components?.[componentType as keyof ComponentsObject]?.[component];\n }\n });\n\n // If this component group is now empty, delete it.\n if (!Object.keys(this.definition.components?.[componentType as keyof ComponentsObject] || {}).length) {\n delete this.definition.components?.[componentType as keyof ComponentsObject];\n }\n });\n\n // If this path no longer has any components, delete it.\n if (!Object.keys(this.definition.components || {}).length) {\n delete this.definition.components;\n }\n }\n\n // Remove any unused tags.\n if ('tags' in this.definition) {\n this.definition.tags = (this.definition.tags ?? []).filter((tag): tag is TagObject => {\n return Boolean(tag) && this.usedTags.has(tag.name);\n });\n\n if (!this.definition.tags?.length) {\n delete this.definition.tags;\n }\n }\n\n return this.definition;\n }\n\n /**\n * Recursively process a `$ref` pointer and accumulate any other `$ref` pointers that it or its\n * children use. This handles circular references by skipping `$ref` pointers we have already seen.\n * Additionally when a `$ref` points to `#/paths` we record the used path + method so we can\n * retain cross-operation references within the transformed definition.\n *\n * @param schema JSON Schema object to look for and accumulate any `$ref` pointers that it may have.\n * @param $refs Known set of `$ref` pointers.\n * @param $ref `$ref` pointer to fetch a schema from out of the supplied schema.\n */\n private accumulateUsedRefs(schema: Record<string, unknown>, $refs: Set<string>, $ref: string): void {\n // Record `$ref` pointers aimed at `#/paths` or `#/webhooks` so we can retain any\n // cross-operation or Path Item references.\n this.recordPathRef($ref);\n this.recordWebhookRef($ref);\n\n let $refSchema: unknown;\n if (typeof $ref === 'string') $refSchema = jsonPointer.get(schema, $ref.substring(1));\n if ($refSchema === undefined) {\n // If the schema we have wasn't fully dereferenced or bundled for whatever reason and this\n // `$ref` that we have doesn't exist here we shouldn't try to search for more `$ref` pointers\n // in a schema that doesn't exist.\n return;\n }\n\n const referencedValues = this.queryForRefPointers($refSchema).map(({ value }) => value);\n // allOf children point back to their parent, so ordinary forward $ref traversal misses them.\n referencedValues.push(...(this.discriminatorChildrenByParentRef.get($ref) ?? []));\n\n referencedValues.forEach(currRef => {\n // Because it's possible to have a schema property named `$ref` that is not a `$ref` pointer,\n // which our JSONPath query would pick up as a false positive, we want to exclude that from\n // `$ref` matching as it's not a reference pointer.\n const foundRef = this.toRefString(currRef);\n if (!foundRef) {\n return;\n }\n\n // If we've already processed this `$ref` then don't send us into an infinite loop of processing\n // circular references.\n if ($refs.has(foundRef)) {\n return;\n }\n\n $refs.add(foundRef);\n this.accumulateUsedRefs(schema, $refs, foundRef);\n });\n }\n\n /**\n * Query a JSON Schema object for any `$ref` pointers using JSONPath and return any pointers that\n * exist.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc9535}\n * @param schema JSON Schema object to look for any `$ref` pointers within it.\n */\n private queryForRefPointers(schema: any) {\n return query([\"$..['$ref']\"], schema);\n }\n\n /**\n * Normalize a value from a `jsonpath-plus` `$ref` query to a `$ref` pointer because JSONPath\n * queries may return the property value or the parent.\n *\n */\n private toRefString(value: unknown): string | null {\n if (typeof value === 'string') {\n return value;\n } else if (value && typeof value === 'object' && '$ref' in value && typeof value.$ref === 'string') {\n return value.$ref;\n }\n\n return null;\n }\n\n /**\n * If the given `$ref` points into a path, classify how that path must be retained:\n *\n * - `#/paths/~1pets` — the entire Path Item (operations included)\n * - `#/paths/~1pets/get/...` — a single operation\n * - `#/paths/~1pets/parameters/...` — a Path Item field, so the container must remain\n */\n private parsePathRef(\n $ref: string,\n ):\n | { path: string; retention: 'all' }\n | { path: string; retention: 'operation'; method: string }\n | { path: string; retention: 'container' }\n | null {\n if (typeof $ref !== 'string' || !$ref.startsWith('#/paths/')) {\n return null;\n }\n\n const match = $ref.match(/^#\\/paths\\/([^/]+)(?:\\/([^/]+))?(?:\\/|$)/);\n if (!match?.[1]) {\n return null;\n }\n\n const path = decodePointer(match[1]);\n const segment = match[2];\n if (!segment) {\n return { path, retention: 'all' };\n }\n\n if (supportedMethods.includes(segment.toLowerCase() as HttpMethods)) {\n return { path, method: segment, retention: 'operation' };\n }\n\n return { path, retention: 'container' };\n }\n\n /**\n * If the given `$ref` points into webhooks, classify how that webhook must be retained. Same\n * retention rules as {@link parsePathRef}.\n */\n private parseWebhookRef(\n $ref: string,\n ):\n | { name: string; retention: 'all' }\n | { name: string; retention: 'operation'; method: string }\n | { name: string; retention: 'container' }\n | null {\n if (typeof $ref !== 'string' || !$ref.startsWith('#/webhooks/')) {\n return null;\n }\n\n const match = $ref.match(/^#\\/webhooks\\/([^/]+)(?:\\/([^/]+))?(?:\\/|$)/);\n if (!match?.[1]) {\n return null;\n }\n\n const name = decodePointer(match[1]);\n const segment = match[2];\n if (!segment) {\n return { name, retention: 'all' };\n }\n\n if (supportedMethods.includes(segment.toLowerCase() as HttpMethods)) {\n return { name, method: segment, retention: 'operation' };\n }\n\n return { name, retention: 'container' };\n }\n\n /**\n * If a Path Item we must keep is itself a `$ref`, retain that target and walk it for further\n * `$ref`s. `#/paths/~1foo/get/…` (and the webhook equivalent) do not resolve through a\n * ref-only `/foo` via JSON Pointer, so without this the component is deleted while `/foo`\n * remains as a dangling `$ref`.\n */\n private retainReferencedPathItem(pathItem: PathItemObject | undefined): void {\n if (!isRef(pathItem) || this.$refs.has(pathItem.$ref)) {\n return;\n }\n\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n }\n\n /**\n * Record a security scheme so component cleanup keeps it. Scheme names are JSON-Pointer-encoded\n * so they match the same form used for authored `$ref`s (`foo/bar` → `foo~1bar`).\n */\n private retainSecurityScheme(scheme: string): void {\n this.$refs.add(`#/components/securitySchemes/${encodePointer(scheme)}`);\n }\n\n /** Record a `#/paths` `$ref` so the target Path Item or operation is not dropped. */\n private recordPathRef($ref: string): void {\n const parsed = this.parsePathRef($ref);\n if (!parsed) {\n return;\n }\n\n const pathLC = parsed.path.toLowerCase();\n if (parsed.retention === 'all') {\n this.retainPathMethods.add(`${pathLC}|*`);\n } else if (parsed.retention === 'operation') {\n this.retainPathMethods.add(`${pathLC}|${parsed.method.toLowerCase()}`);\n } else if (!this.retainPathContainers.has(pathLC)) {\n // Field-level pointers keep every sibling Path Item field, so walk those fields for\n // component `$ref`s. Traversing only the pointed-to entry would let component cleanup\n // delete a sibling's target and leave a dangling pointer.\n this.retainPathContainers.add(pathLC);\n this.accumulateContainerFieldRefs(this.findPathItem(parsed.path));\n }\n\n this.retainReferencedPathItem(this.findPathItem(parsed.path));\n }\n\n /** Record a `#/webhooks` `$ref` so the target webhook Path Item or operation is not dropped. */\n private recordWebhookRef($ref: string): void {\n const parsed = this.parseWebhookRef($ref);\n if (!parsed) {\n return;\n }\n\n const nameLC = parsed.name.toLowerCase();\n if (parsed.retention === 'all') {\n this.retainWebhookMethods.add(`${nameLC}|*`);\n } else if (parsed.retention === 'operation') {\n this.retainWebhookMethods.add(`${nameLC}|${parsed.method.toLowerCase()}`);\n } else if (!this.retainWebhookContainers.has(nameLC)) {\n this.retainWebhookContainers.add(nameLC);\n this.accumulateContainerFieldRefs(this.findWebhook(parsed.name));\n }\n\n this.retainReferencedPathItem(this.findWebhook(parsed.name));\n }\n\n /** Look up a Path Item by its path, ignoring key casing. */\n private findPathItem(path: string): PathItemObject | undefined {\n const pathLC = path.toLowerCase();\n const key = Object.keys(this.definition.paths || {}).find(candidate => candidate.toLowerCase() === pathLC);\n return key ? this.definition.paths?.[key] : undefined;\n }\n\n /** Look up a webhook Path Item by name, ignoring key casing. */\n private findWebhook(name: string): PathItemObject | undefined {\n if (!isOpenAPI31(this.definition) || !this.definition.webhooks) {\n return undefined;\n }\n\n const nameLC = name.toLowerCase();\n const key = Object.keys(this.definition.webhooks).find(candidate => candidate.toLowerCase() === nameLC);\n return key ? (this.definition.webhooks[key] as PathItemObject | undefined) : undefined;\n }\n\n /**\n * Accumulate `$ref` pointers from the Path Item fields we keep when a container is retained\n * (parameters, servers, summary, … — everything except HTTP operations).\n */\n private accumulateContainerFieldRefs(pathItem: PathItemObject | undefined): void {\n if (!pathItem) {\n return;\n }\n\n if (isRef(pathItem)) {\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n return;\n }\n\n Object.entries(pathItem).forEach(([key, value]) => {\n if (supportedMethods.includes(key.toLowerCase() as HttpMethods) || value === undefined) {\n return;\n }\n\n this.queryForRefPointers(value).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n });\n }\n\n /** Whether any `$ref` requires this path (or one of its operations) to remain. */\n private isPathRetainedByRef(pathLC: string): boolean {\n return (\n this.retainPathContainers.has(pathLC) ||\n Array.from(this.retainPathMethods).some(key => key.startsWith(`${pathLC}|`))\n );\n }\n\n /** Whether a `$ref` requires this specific path operation — or the entire Path Item — to remain. */\n private isPathOperationRetainedByRef(pathLC: string, methodLC: string): boolean {\n return this.retainPathMethods.has(`${pathLC}|*`) || this.retainPathMethods.has(`${pathLC}|${methodLC}`);\n }\n\n /**\n * Whether the path container must remain after its operations have been filtered. Whole-path\n * `$ref`s also keep the container (and its operations).\n */\n private isPathContainerKept(pathLC: string): boolean {\n return this.retainPathContainers.has(pathLC) || this.retainPathMethods.has(`${pathLC}|*`);\n }\n\n /** Whether any `$ref` requires this webhook (or one of its operations) to remain. */\n private isWebhookRetainedByRef(nameLC: string): boolean {\n return (\n this.retainWebhookContainers.has(nameLC) ||\n Array.from(this.retainWebhookMethods).some(key => key.startsWith(`${nameLC}|`))\n );\n }\n\n /** Whether a `$ref` requires this specific webhook operation — or the entire webhook — to remain. */\n private isWebhookOperationRetainedByRef(nameLC: string, methodLC: string): boolean {\n return this.retainWebhookMethods.has(`${nameLC}|*`) || this.retainWebhookMethods.has(`${nameLC}|${methodLC}`);\n }\n\n /**\n * Whether the webhook container must remain after its operations have been filtered.\n */\n private isWebhookContainerKept(nameLC: string): boolean {\n return this.retainWebhookContainers.has(nameLC) || this.retainWebhookMethods.has(`${nameLC}|*`);\n }\n\n /** Determine whether a path or webhook is excluded in the current transformation mode. */\n private isContainerExcluded(selection: OperationSelection, key: string): boolean {\n if (this.mode === 'prune') {\n return selection.matchesAll(key);\n }\n\n return !selection.has(key);\n }\n\n /**\n * Determine whether an operation passes the configured filters before cross-operation references\n * are considered.\n */\n private shouldRetainOperation(\n selection: OperationSelection,\n key: string,\n method: string,\n operation: OperationObject,\n ): boolean {\n if (this.mode === 'reduce') {\n // Reduction filters intersect, so an operation must match every configured filter.\n if (selection.hasSelections && !selection.matches(key, method)) return false;\n if (\n this.hasOperationIdSelection &&\n !this.operationIdSelection.has(Operation.getOperationId(key, method, operation))\n ) {\n return false;\n }\n if (this.hasTagSelection && !(operation.tags || []).some(tag => this.tagSelection.includes(tag.toLowerCase()))) {\n return false;\n }\n } else {\n // Pruning filters are additive, so matching any configured filter removes an operation.\n if (selection.hasSelections && selection.matches(key, method)) return false;\n if (\n this.hasOperationIdSelection &&\n this.operationIdSelection.has(Operation.getOperationId(key, method, operation))\n ) {\n return false;\n }\n if (this.hasTagSelection && (operation.tags || []).some(tag => this.tagSelection.includes(tag.toLowerCase()))) {\n return false;\n }\n }\n\n // No configured filter excluded this operation, so retain it in the transformed definition.\n return true;\n }\n\n /** Determine whether a path item contains at least one HTTP operation. */\n private hasOperations(pathItem: PathItemObject | undefined): boolean {\n return Boolean(pathItem && supportedMethods.some(method => method in pathItem));\n }\n\n /**\n * Accumulate any `$ref` pointers that are used by common Path Item parameters.\n *\n * @param parameters Common Path Item parameters to inspect for `$ref` pointers.\n */\n private accumulateParameterRefs(parameters: PathItemObject['parameters'] | undefined): void {\n if (!parameters) {\n return;\n }\n\n this.queryForRefPointers(parameters).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n }\n\n /**\n * Walk through the `paths` in our OpenAPI definition and determine which operations we want to\n * retain. Accumulate any `$ref` pointers that they use so their referenced schemas can also be\n * retained in our resulting API definition.\n *\n */\n private walkPaths(): void {\n if (!('paths' in this.definition) || !this.definition.paths) {\n return;\n }\n\n Object.keys(this.definition.paths).forEach(path => {\n // When only webhooks were requested (no path/operation filter), ignore all paths, but don't\n // delete them yet because a selected webhook may reference one of their operations. We'll\n // remove any that aren't referenced later.\n if (this.mode === 'reduce' && this.hasWebhookSelection && !this.hasPathSelection) {\n return;\n } else if (this.hasPathSelection && this.isContainerExcluded(this.pathSelection, path)) {\n return;\n }\n\n const pathItem = this.definition.paths?.[path];\n\n /**\n * Referenced Path Items that remain in the result are preserved intact rather than partially\n * transformed. Retain the target and continue walking any local sibling fields so that we\n * retain their dependencies too.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(pathItem)) {\n this.$refs.add(pathItem.$ref);\n this.accumulateUsedRefs(this.definition, this.$refs, pathItem.$ref);\n }\n\n // If this Path Item has no operations then it will remain in our resulting API definition,\n // so we need to retain any components referenced by its common parameters.\n if (!this.hasOperations(pathItem)) {\n this.accumulateParameterRefs(pathItem?.parameters);\n }\n\n Object.keys(pathItem || {}).forEach(method => {\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(method.toLowerCase() as HttpMethods)) {\n return;\n }\n\n const operation = this.definition.paths?.[path]?.[method as HttpMethods] as OperationObject;\n if (!operation) {\n throw new Error(`Operation \\`${method} ${path}\\` not found`);\n }\n\n // If this operation isn't part of our resulting API definition then ignore it. We'll\n // remove it later.\n if (!this.shouldRetainOperation(this.pathSelection, path, method, operation)) {\n return;\n }\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n // Skipped by the `method === 'parameters'` guard above; accumulate here so refs are only\n // retained when at least one operation on this path passes all filters.\n this.accumulateParameterRefs(pathItem?.parameters);\n\n this.queryForRefPointers(operation).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n\n // Re-run through any `$ref` pointers that we found within this operation and search for\n // any `$ref` pointers that they also may be using. This also records `#/paths` and\n // `#/webhooks` targets so they are retained.\n this.accumulateUsedRefs(this.definition, this.$refs, refStr);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n });\n }\n\n /**\n * Walk through the `webhooks` in our OpenAPI definition and determine which operations we want\n * to retain. Accumulate any `$ref` pointers that they use so their referenced schemas can also be\n * retained in our resulting API definition.\n *\n */\n private walkWebhooks() {\n if (!isOpenAPI31(this.definition)) {\n return;\n } else if (!('webhooks' in this.definition) || !this.definition.webhooks) {\n return;\n }\n\n const definition = this.definition satisfies OpenAPIV3_1.Document;\n\n Object.keys(definition.webhooks || {}).forEach(webhookName => {\n if (this.hasWebhookSelection && this.isContainerExcluded(this.webhookSelection, webhookName)) {\n return;\n }\n\n const webhook: PathItemObject | undefined = definition.webhooks?.[webhookName];\n if (!webhook || typeof webhook !== 'object') {\n return;\n }\n\n /**\n * Referenced webhook Path Items that remain in the result are preserved intact rather than\n * partially transformed. Retain the target and continue walking any local sibling fields so\n * that we retain their dependencies too.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (typeof webhook.$ref === 'string') {\n this.$refs.add(webhook.$ref);\n this.accumulateUsedRefs(definition, this.$refs, webhook.$ref);\n }\n\n // If this webhook has no operations then it will remain in our resulting API definition, so\n // we need to retain any components referenced by its common parameters.\n if (!this.hasOperations(webhook)) {\n this.accumulateParameterRefs(webhook.parameters);\n }\n\n Object.keys(webhook).forEach(method => {\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(method.toLowerCase() as HttpMethods)) {\n return;\n }\n\n const operation = webhook[method as HttpMethods] as OperationObject;\n if (!operation) {\n throw new Error(`Webhook operation \\`${method} ${webhookName}\\` not found`);\n }\n\n // If this operation isn't part of our resulting API definition then ignore it. We'll\n // remove it later.\n if (!this.shouldRetainOperation(this.webhookSelection, webhookName, method, operation)) {\n return;\n }\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n // Skipped by the `method === 'parameters'` guard above; accumulate here so refs are only\n // retained when at least one operation on this webhook passes all filters.\n this.accumulateParameterRefs(webhook.parameters);\n\n this.queryForRefPointers(operation).forEach(({ value: ref }) => {\n const refStr = this.toRefString(ref);\n if (!refStr) {\n return;\n }\n\n this.$refs.add(refStr);\n this.accumulateUsedRefs(definition, this.$refs, refStr);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n });\n }\n\n /**\n * Transform our `paths` object according to the paths and operations that we've selected.\n */\n private transformPaths(): void {\n if (!('paths' in this.definition) || !this.definition.paths) {\n return;\n }\n\n Object.keys(this.definition.paths).forEach(path => {\n const pathLC = path.toLowerCase();\n const excludePathItem =\n (this.hasPathSelection && this.isContainerExcluded(this.pathSelection, path)) ||\n (this.mode === 'reduce' && this.hasWebhookSelection && !this.hasPathSelection);\n\n if (this.mode === 'prune' && excludePathItem) {\n if (this.isPathRetainedByRef(pathLC)) {\n throw new Error(`Cannot remove path \\`${path}\\` because one of its operations is referenced.`);\n }\n\n delete this.definition.paths?.[path];\n return;\n }\n\n const pathItem = this.definition.paths?.[path];\n\n /**\n * Referenced Path Items are preserved intact during operation-level filtering. If the whole\n * Path Item is excluded, remove it unless a surviving operation references it.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(pathItem)) {\n if (excludePathItem && !this.isPathRetainedByRef(pathLC)) {\n delete this.definition.paths?.[path];\n }\n\n return;\n }\n\n let removedOperation = false;\n Object.keys(pathItem || {}).forEach(method => {\n const methodLC = method.toLowerCase();\n\n // Only process operations and retain any common path-level common properties like\n // `parameters`, `servers`, `summary`, etc.\n if (method === 'parameters' || !supportedMethods.includes(methodLC as HttpMethods)) {\n return;\n }\n\n const retainedByRef = this.isPathOperationRetainedByRef(pathLC, methodLC);\n\n const operation = this.definition.paths?.[path]?.[method as HttpMethods];\n if (!operation) {\n throw new Error(`Operation \\`${method} ${path}\\` not found`);\n }\n\n if (excludePathItem || !this.shouldRetainOperation(this.pathSelection, path, method, operation)) {\n if (this.mode === 'prune' && retainedByRef) {\n throw new Error(`Cannot remove operation \\`${method.toUpperCase()} ${path}\\` because it is referenced.`);\n }\n\n if (!retainedByRef) {\n delete this.definition.paths?.[path]?.[method as HttpMethods];\n removedOperation = true;\n return;\n }\n }\n\n // This operation remains in the transformed definition, so retain any components\n // referenced by its common Path Item parameters.\n this.accumulateParameterRefs(pathItem?.parameters);\n\n // Accumulate a list of used tags so we can filter out any ones that we don't need later.\n if ('tags' in operation) {\n operation.tags?.forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n }\n\n // Accumulate any used operation-level security schemas that we need to retain.\n if ('security' in operation) {\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n }\n });\n\n // If filtering removed every operation from this path then remove its path-level properties\n // as well. We leave path items that were authored without operations untouched.\n if (\n !this.isPathContainerKept(pathLC) &&\n (((removedOperation || (this.mode === 'reduce' && excludePathItem)) && !this.hasOperations(pathItem)) ||\n (this.mode === 'reduce' && !Object.keys(this.definition.paths?.[path] || {}).length))\n ) {\n delete this.definition.paths?.[path];\n }\n });\n\n // If we don't have any paths left then retain the reducer's no-match error. An empty Paths\n // Object is valid OpenAPI so we allow it when pruning.\n if (!Object.keys(this.definition.paths || {}).length) {\n if (this.mode === 'reduce' && !(this.definition.webhooks && Object.keys(this.definition.webhooks).length)) {\n throw new Error(\n 'All paths in the API definition were removed. Did you supply the right path name to reduce by?',\n );\n }\n\n if (this.definition.webhooks && Object.keys(this.definition.webhooks).length) {\n delete this.definition.paths;\n }\n }\n }\n\n /**\n * Transform our `webhooks` object according to the webhooks and operations that we've selected.\n */\n private transformWebhooks(): void {\n if (!isOpenAPI31(this.definition)) {\n return;\n } else if (!('webhooks' in this.definition) || !this.definition.webhooks) {\n return;\n }\n\n const definition = this.definition satisfies OpenAPIV3_1.Document;\n\n Object.keys(definition.webhooks || {}).forEach(webhookName => {\n const nameLC = webhookName.toLowerCase();\n const excludeWebhook = this.hasWebhookSelection && this.isContainerExcluded(this.webhookSelection, webhookName);\n\n if (this.mode === 'prune' && excludeWebhook) {\n if (this.isWebhookRetainedByRef(nameLC)) {\n throw new Error(`Cannot remove webhook \\`${webhookName}\\` because one of its operations is referenced.`);\n }\n\n delete definition.webhooks?.[webhookName];\n return;\n }\n\n const webhook = definition.webhooks?.[webhookName];\n if (!webhook || typeof webhook !== 'object') {\n return;\n }\n\n /**\n * Referenced webhook Path Items are preserved intact during operation-level filtering. If\n * the whole webhook is excluded, remove it unless a surviving operation references it.\n * @fixme Resolve referenced Path Items so their operations can be transformed individually.\n */\n if (isRef(webhook)) {\n if (excludeWebhook && !this.isWebhookRetainedByRef(nameLC)) {\n delete definition.webhooks?.[webhookName];\n }\n\n return;\n }\n\n let removedOperation = false;\n Object.keys(webhook).forEach(method => {\n const methodLC = method.toLowerCase();\n if (method === 'parameters' || !supportedMethods.includes(methodLC as HttpMethods)) {\n return;\n }\n\n const operation = webhook[method as HttpMethods];\n if (!operation) {\n throw new Error(`Webhook operation \\`${method} ${webhookName}\\` not found`);\n }\n\n const retainedByRef = this.isWebhookOperationRetainedByRef(nameLC, methodLC);\n if (excludeWebhook || !this.shouldRetainOperation(this.webhookSelection, webhookName, method, operation)) {\n if (this.mode === 'prune' && retainedByRef) {\n throw new Error(\n `Cannot remove operation \\`${method.toUpperCase()} ${webhookName}\\` because it is referenced.`,\n );\n }\n\n if (!retainedByRef) {\n delete webhook[method as HttpMethods];\n removedOperation = true;\n return;\n }\n }\n\n // This operation remains in the transformed definition, so retain any components\n // referenced by its common Path Item parameters.\n this.accumulateParameterRefs(webhook.parameters);\n\n (operation.tags || []).forEach((tag: string) => {\n this.usedTags.add(tag);\n });\n\n Object.values(operation.security || {}).forEach(sec => {\n Object.keys(sec).forEach(scheme => {\n this.retainSecurityScheme(scheme);\n });\n });\n });\n\n if (\n !this.isWebhookContainerKept(nameLC) &&\n (((removedOperation || (this.mode === 'reduce' && excludeWebhook)) && !this.hasOperations(webhook)) ||\n (this.mode === 'reduce' && !Object.keys(definition.webhooks?.[webhookName] || {}).length))\n ) {\n delete definition.webhooks?.[webhookName];\n }\n });\n\n if (definition.webhooks && !Object.keys(definition.webhooks).length) {\n delete definition.webhooks;\n }\n }\n}\n","/**\n * Track selected HTTP operations within OpenAPI paths or webhooks. Container keys and HTTP methods\n * are matched without regard to casing.\n */\nexport class OperationSelection {\n private selections: Map<string, '*' | Set<string>> = new Map();\n\n /** Whether any paths or webhooks have been selected. */\n get hasSelections(): boolean {\n return this.selections.size > 0;\n }\n\n /**\n * Select every operation within a path or webhook.\n *\n * @param key Path or webhook key whose operations should be selected.\n */\n addAll(key: string): void {\n this.selections.set(this.normalize(key), '*');\n }\n\n /**\n * Add an operation to the selection for a path or webhook. If every operation for the key is\n * already selected, that selection remains unchanged.\n *\n * @param key Path or webhook key that contains the operation.\n * @param method HTTP method of the operation to select.\n */\n addOperation(key: string, method: string): void {\n const normalizedKey = this.normalize(key);\n const normalizedMethod = this.normalize(method);\n const selection = this.selections.get(normalizedKey);\n\n if (selection === '*') {\n return;\n }\n\n if (selection instanceof Set) {\n selection.add(normalizedMethod);\n return;\n }\n\n this.selections.set(normalizedKey, new Set([normalizedMethod]));\n }\n\n /**\n * Clear every operation selection for a path or webhook.\n *\n * @param key Path or webhook key to clear.\n */\n clear(key: string): void {\n this.selections.delete(this.normalize(key));\n }\n\n /**\n * Determine whether a path or webhook has any selected operations.\n *\n * @param key Path or webhook key to check.\n */\n has(key: string): boolean {\n return this.selections.has(this.normalize(key));\n }\n\n /**\n * Determine whether every operation within a path or webhook is selected.\n *\n * @param key Path or webhook key to check.\n */\n matchesAll(key: string): boolean {\n return this.selections.get(this.normalize(key)) === '*';\n }\n\n /**\n * Determine whether an operation is selected.\n *\n * @param key Path or webhook key that contains the operation.\n * @param method HTTP method of the operation to check.\n */\n matches(key: string, method: string): boolean {\n const selection = this.selections.get(this.normalize(key));\n return selection === '*' || Boolean(selection?.has(this.normalize(method)));\n }\n\n /** Normalize path, webhook, and method casing for comparisons. */\n private normalize(value: string): string {\n return value.toLowerCase();\n }\n}\n"]}
@@ -9,10 +9,12 @@ var PARAMETER_ORDERING = "parameter-ordering";
9
9
  var PROXY_ENABLED = "proxy-enabled";
10
10
  var SAMPLES_LANGUAGES = "samples-languages";
11
11
  var SIMPLE_MODE = "simple-mode";
12
+ var APPLY_ENDPOINT_ORDER = "apply-endpoint-order";
12
13
  var APPLY_TAG_CHANGES = "apply-tag-changes";
13
14
  var DISABLE_TAG_SORTING = "disable-tag-sorting";
14
15
  var STATUS_URL = "status-url";
15
16
  var extensionDefaults = {
17
+ [APPLY_ENDPOINT_ORDER]: false,
16
18
  [APPLY_TAG_CHANGES]: false,
17
19
  [CODE_SAMPLES]: void 0,
18
20
  [DISABLE_TAG_SORTING]: false,
@@ -90,6 +92,7 @@ export {
90
92
  PROXY_ENABLED,
91
93
  SAMPLES_LANGUAGES,
92
94
  SIMPLE_MODE,
95
+ APPLY_ENDPOINT_ORDER,
93
96
  APPLY_TAG_CHANGES,
94
97
  DISABLE_TAG_SORTING,
95
98
  STATUS_URL,
@@ -98,4 +101,4 @@ export {
98
101
  getExtension,
99
102
  validateParameterOrdering
100
103
  };
101
- //# sourceMappingURL=chunk-DYHV2B4Z.js.map
104
+ //# sourceMappingURL=chunk-JHDEAXSK.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["../src/extensions.ts"],"sourcesContent":["import type { Operation } from './operation/index.js';\nimport type { OASDocument } from './types.js';\n\n/**\n * Enables custom-written code samples to be set for your operations. Use this if you have specific\n * formatting that may not be followed by the auto-generated code samples. Custom code samples are\n * treated as static content.\n *\n * This extension only be placed at the operation level.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#custom-code-samples}\n * @example\n * {\n * \"x-readme\": {\n * \"code-samples\": [\n * {\n * \"language\": \"curl\",\n * \"code\": \"curl -X POST https://api.example.com/v2/alert\",\n * \"name\": \"Custom cURL snippet\",\n * \"install\": \"brew install curl\"\n * },\n * {\n * \"language\": \"php\",\n * \"code\": \"<?php echo \\\"This is our custom PHP code snippet.\\\"; ?>\",\n * \"name\": \"Custom PHP snippet\"\n * }\n * ]\n * }\n * }\n */\nexport const CODE_SAMPLES = 'code-samples';\n\n/**\n * Disables the API Explorer's \"Try It\" button, preventing users from making API requests from\n * within your docs. Users will still be able to fill out any entry fields (path or query\n * parameters, etc.), and code snippets will be auto-generated based on the user's input, however\n * to interact with your API the user will need to copy the code snippet and execute it outside of\n * your docs.\n *\n * This **does not** disable your API Reference documentation.\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-the-api-explorer}\n * @example\n * {\n * \"x-readme\": {\n * \"explorer-enabled\": true\n * }\n * }\n */\nexport const EXPLORER_ENABLED = 'explorer-enabled';\n\n/**\n * Adds static headers to add to each request. Use this when there are specific headers unique to\n * your API.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#static-headers}\n * @example\n * {\n * \"x-readme\": {\n * \"headers\": [\n * {\n * \"key\": \"X-Static-Header-One\",\n * \"value\": \"owlbert\"\n * },\n * {\n * \"key\": \"X-Static-Header-Two\",\n * \"value\": \"owlivia\"\n * }\n * ]\n * }\n * }\n */\nexport const HEADERS = 'headers';\n\n/**\n * Allows you to mark an API endpoint, or _every_ API endpoint if defined in the root, as being\n * internal and hidden from your public API reference.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#internal}\n * @example\n * {\n * \"x-internal\": true\n * }\n * @example\n * {\n * \"x-readme\": {\n * \"internal\": true\n * }\n * }\n */\nexport const INTERNAL = 'internal';\n\n/**\n * Disables API requests from the API Explorer's \"Try It\" button from being sent into our [API\n * Metrics](https://readme.com/metrics) for you and your users. Additionally on any API endpoint\n * that this is disabled on your users will not see lists or graphs of previous requests they've\n * made against that API endpoint — either through the API Explorer's interactivity or through one\n * of our [Metrics SDKs](https://docs.readme.com/main/docs/api-metrics-setup) (if you have those\n * installed on your API).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-api-metrics}\n * @example\n * {\n * \"x-readme\": {\n * \"metrics-defaults\": false\n * }\n * }\n */\nexport const METRICS_ENABLED = 'metrics-enabled';\n\n/**\n * Configuration options for OAuth flows in the API Explorer.\n *\n * @defaultValue {}\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#oauth-configuration-options}\n * @example\n * {\n * \"x-readme\": {\n * \"oauth-options\": {\n * \"scopeSeparator\": \",\",\n * \"useInsecureClientAuthentication\": true,\n * \"usePkce\": false\n * }\n * }\n * }\n */\nexport const OAUTH_OPTIONS = 'oauth-options';\n\n/**\n * Controls the order of parameters on your API Reference pages.\n *\n * Your custom ordering **must** contain all of our available parameter types:\n *\n * - `path`: Path parameters\n * - `query`: Query parameters\n * - `body`: Non-`application/x-www-form-urlencoded` request body payloads\n * - `cookie`: Cookie parameters\n * - `form`: `application/x-www-form-urlencoded` request body payloads\n * - `header`: Header parameters\n *\n * @defaultValue ['path', 'query', 'body', 'cookie', 'form', 'header']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#parameter-ordering}\n * @example\n * {\n * \"x-readme\": {\n * \"parameter-ordering\": ['path', 'query', 'header', 'cookie', 'body', 'form']\n * }\n * }\n */\nexport const PARAMETER_ORDERING = 'parameter-ordering';\n\n/**\n * Toggles the CORS proxy used when making API requests from within your docs (via the \"Try It\"\n * button). If your API is already set up to return CORS headers, you can safely disable this\n * feature.\n *\n * Disabling the CORS proxy will make the request directly from the user's browser and will prevent\n * [Metrics](https://docs.readme.com/main/docs/getting-started-with-metrics) data from being logged\n * by us unless [Metrics have already set up on your backend](https://docs.readme.com/main/docs/api-metrics-setup).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#cors-proxy-enabled}\n * @example\n * {\n * \"x-readme\": {\n * \"proxy-enabled\": true\n * }\n * }\n */\nexport const PROXY_ENABLED = 'proxy-enabled';\n\n/**\n * Toggles what languages are shown by default for code samples in the API Explorer. This only\n * affects what languages are initially shown to the user; if the user picks another language from\n * the three-dot menu, that language and the respective auto-generated code snippet will also appear\n * as an option in the API Explorer.\n *\n * @defaultValue ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#code-sample-languages}\n * @example\n * {\n * \"x-readme\": {\n * \"samples-languages\": [\"shell\", \"node\", \"ruby\", \"javascript\", \"python\"]\n * }\n * }\n */\nexport const SAMPLES_LANGUAGES = 'samples-languages';\n\n/**\n * Toggles if you will see code snippets for ReadMe's SDK code generator tool `api`.\n *\n * @defaultValue true\n * @see {@link https://api.readme.dev}\n * @example\n * {\n * \"x-readme\": {\n * \"simple-mode\": false\n * }\n * }\n */\nexport const SIMPLE_MODE = 'simple-mode';\n\n/**\n * Reorders API operation pages within their current parent to match the order in the API definition\n * when it is updated. Operation pages retain any manual nesting, and operations that have been\n * moved to another category are not affected.\n *\n * This extension may only be placed at the API definition root level.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions}\n * @example\n * {\n * \"x-readme\": {\n * \"apply-endpoint-order\": true\n * }\n * }\n */\nexport const APPLY_ENDPOINT_ORDER = 'apply-endpoint-order';\n\n/**\n * Moves existing API operation pages within their current API category to match their tags when\n * the API definition is updated. Operations that have been moved to another category are not\n * affected.\n *\n * This extension may only be placed at the API definition root level.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions}\n * @example\n * {\n * \"x-readme\": {\n * \"apply-tag-changes\": true\n * }\n * }\n */\nexport const APPLY_TAG_CHANGES = 'apply-tag-changes';\n\n/**\n * If `true`, tags are generated from the file top-down. If `false`, we sort the tags\n * based off the `tags` array in the OAS file.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-tag-sorting}\n * @example\n * {\n * \"x-readme\": {\n * \"disable-tag-sorting\": true\n * }\n * }\n */\nexport const DISABLE_TAG_SORTING = 'disable-tag-sorting';\n\n/**\n * A customer-declared health/status URL for the API. When present, it's surfaced to AI agents as\n * the RFC 9727 `status` link relation in the project's `/.well-known/api-catalog`.\n *\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions}\n * @see {@link https://www.rfc-editor.org/rfc/rfc9727}\n * @example\n * {\n * \"x-readme\": {\n * \"status-url\": \"https://status.example.com\"\n * }\n * }\n */\nexport const STATUS_URL = 'status-url';\n\nexport interface Extensions {\n [APPLY_ENDPOINT_ORDER]: boolean;\n [APPLY_TAG_CHANGES]: boolean;\n [CODE_SAMPLES]:\n | {\n /**\n * Custom code snippet\n * @example \"curl -X POST https://api.example.com/v2/alert\"\n */\n code: string;\n /**\n * Corresponding response example\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#corresponding-response-examples}\n */\n correspondingExample?: string;\n /**\n * Library installation instructions\n * @example \"brew install httpie\"\n * @example \"npm install node-fetch@2 --save\"\n */\n install?: string;\n /**\n * Language for syntax highlighting\n * @example shell\n */\n language: string;\n /**\n * Optional title for code sample\n * @example \"Custom cURL snippet\"\n */\n name?: string;\n }[]\n | undefined;\n [DISABLE_TAG_SORTING]: boolean;\n [EXPLORER_ENABLED]: boolean;\n [HEADERS]: Record<string, number | string>[] | undefined;\n [INTERNAL]: boolean;\n [METRICS_ENABLED]: boolean;\n [OAUTH_OPTIONS]: {\n /**\n * Scope separator for passing scopes. This value will be URL-encoded.\n *\n * @example \",\"\n * @example \"+\"\n * @default \" \"\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.3} Scope separators information from OAuth 2.0 specification\n */\n scopeSeparator?: string;\n\n /**\n * When enabled, the client credentials (i.e., `client_id` and `client_secret`) are sent in the request body (NOT recommended).\n * When disabled (the default), client credentials are sent using the HTTP Basic Authentication scheme.\n *\n * This is applicable for all requests to the token endpoint.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.2}\n *\n * @example true\n * @default false\n */\n useInsecureClientAuthentication?: boolean;\n\n /**\n * When enabled, uses PKCE (Proof Key for Code Exchange) for the authorization code flow.\n * The client secret is replaced with an auto-generated code verifier and code challenge.\n * When disabled, uses the standard OAuth 2.0 authorization code flow with client credentials.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.1}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc7636#section-4.2}\n *\n * @example true\n * @default false\n */\n usePkce?: boolean;\n };\n [PARAMETER_ORDERING]: ('body' | 'cookie' | 'form' | 'header' | 'path' | 'query')[];\n [PROXY_ENABLED]: boolean;\n [SAMPLES_LANGUAGES]: string[];\n [SIMPLE_MODE]: boolean;\n [STATUS_URL]: string | undefined;\n}\n\nexport const extensionDefaults: Extensions = {\n [APPLY_ENDPOINT_ORDER]: false,\n [APPLY_TAG_CHANGES]: false,\n [CODE_SAMPLES]: undefined,\n [DISABLE_TAG_SORTING]: false,\n [EXPLORER_ENABLED]: true,\n [HEADERS]: undefined,\n [INTERNAL]: false,\n [METRICS_ENABLED]: true,\n [OAUTH_OPTIONS]: {},\n [PARAMETER_ORDERING]: ['path', 'query', 'body', 'cookie', 'form', 'header'],\n [PROXY_ENABLED]: true,\n [SAMPLES_LANGUAGES]: ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp'],\n [SIMPLE_MODE]: true,\n [STATUS_URL]: undefined,\n};\n\n/**\n * Determing if an OpenAPI definition has an extension set in its root schema.\n *\n */\nexport function hasRootExtension(extension: string | keyof Extensions, api: OASDocument): boolean {\n return Boolean(api && extension in api);\n}\n\n/**\n * Retrieve a custom specification extension off of the API definition.\n *\n */\nexport function getExtension(extension: string | keyof Extensions, api: OASDocument, operation?: Operation): any {\n if (operation) {\n if (operation.hasExtension('x-readme')) {\n const data = operation.getExtension('x-readme') as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (operation.hasExtension(`x-${extension}`)) {\n return operation.getExtension(`x-${extension}`);\n } else if (operation.hasExtension(extension)) {\n return operation.getExtension(extension);\n }\n }\n\n // Because our `code-samples` extension is intended for operation-level use, if it's instead\n // placed at the API definition root level then we should ignore it and return our set defaults.\n if (extension === CODE_SAMPLES) {\n return extensionDefaults[extension];\n }\n\n if (hasRootExtension('x-readme', api)) {\n const data = api?.['x-readme'] as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (hasRootExtension(`x-${extension}`, api)) {\n return api?.[`x-${extension}`];\n } else if (hasRootExtension(extension, api)) {\n return api?.[extension];\n }\n\n // If this is otherwise an extension of our own then we should return the default value for it.\n if (extension in extensionDefaults) {\n return extensionDefaults[extension as keyof Extensions];\n }\n\n return undefined;\n}\n\n/**\n * Validate that the data for an instanceof our `PARAMETER_ORDERING` extension is properly\n * configured.\n *\n * @private\n */\nexport function validateParameterOrdering(\n ordering: (typeof extensionDefaults)[typeof PARAMETER_ORDERING] | undefined,\n extension: string,\n): void {\n if (!ordering) {\n return;\n }\n\n const defaultValue = extensionDefaults[PARAMETER_ORDERING];\n const requiredLength = defaultValue.length;\n const defaultsHuman = `${defaultValue.slice(0, -1).join(', ')}, and ${defaultValue.slice(-1)}`;\n\n if (ordering.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n\n const intersection = ordering.filter(value => defaultValue.includes(value.toLowerCase() as any));\n if (intersection.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n}\n"],"mappings":";AA+BO,IAAM,eAAe;AAoBrB,IAAM,mBAAmB;AAwBzB,IAAM,UAAU;AAmBhB,IAAM,WAAW;AAmBjB,IAAM,kBAAkB;AAkBxB,IAAM,gBAAgB;AAuBtB,IAAM,qBAAqB;AAoB3B,IAAM,gBAAgB;AAiBtB,IAAM,oBAAoB;AAc1B,IAAM,cAAc;AAkBpB,IAAM,uBAAuB;AAkB7B,IAAM,oBAAoB;AAe1B,IAAM,sBAAsB;AAe5B,IAAM,aAAa;AAqFnB,IAAM,oBAAgC;AAAA,EAC3C,CAAC,oBAAoB,GAAG;AAAA,EACxB,CAAC,iBAAiB,GAAG;AAAA,EACrB,CAAC,YAAY,GAAG;AAAA,EAChB,CAAC,mBAAmB,GAAG;AAAA,EACvB,CAAC,gBAAgB,GAAG;AAAA,EACpB,CAAC,OAAO,GAAG;AAAA,EACX,CAAC,QAAQ,GAAG;AAAA,EACZ,CAAC,eAAe,GAAG;AAAA,EACnB,CAAC,aAAa,GAAG,CAAC;AAAA,EAClB,CAAC,kBAAkB,GAAG,CAAC,QAAQ,SAAS,QAAQ,UAAU,QAAQ,QAAQ;AAAA,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AM,eAAe,kBAAkB,kBAAkB;AACzD,QAAM,iBAAiB,aAAa;AACpC,QAAM,gBAAgB,GAAG,aAAa,MAAM,GAAG,EAAE,EAAE,KAAK,IAAI,CAAC,SAAS,aAAa,MAAM,EAAE,CAAC;AAE5F,MAAI,SAAS,WAAW,gBAAgB;AACtC,UAAM,IAAI,UAAU,IAAI,SAAS,kBAAkB,cAAc,wBAAwB,aAAa,EAAE;AAAA,EAC1G;AAEA,QAAM,eAAe,SAAS,OAAO,WAAS,aAAa,SAAS,MAAM,YAAY,CAAQ,CAAC;AAC/F,MAAI,aAAa,WAAW,gBAAgB;AAC1C,UAAM,IAAI,UAAU,IAAI,SAAS,kBAAkB,cAAc,wBAAwB,aAAa,EAAE;AAAA,EAC1G;AACF;","names":[]}
@@ -1,7 +1,7 @@
1
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; }
2
2
 
3
3
 
4
- var _chunkEARDDQSBcjs = require('./chunk-EARDDQSB.cjs');
4
+ var _chunk47FD2BINcjs = require('./chunk-47FD2BIN.cjs');
5
5
 
6
6
 
7
7
 
@@ -309,7 +309,7 @@ function allOfReferencesSchema(schema, targetSchemaName) {
309
309
  return schema.allOf.some((item) => {
310
310
  if (_chunk7PWF3F2Wcjs.isRef.call(void 0, item)) {
311
311
  const refParts = item.$ref.split("/");
312
- const refSchemaName = refParts[refParts.length - 1];
312
+ const refSchemaName = decodePointer(refParts[refParts.length - 1]);
313
313
  return refSchemaName === targetSchemaName;
314
314
  }
315
315
  return false;
@@ -333,7 +333,13 @@ function findDiscriminatorChildren(definition) {
333
333
  if (discriminator.mapping && typeof discriminator.mapping === "object") {
334
334
  const mappingRefs = Object.values(discriminator.mapping);
335
335
  if (mappingRefs.length > 0) {
336
- childSchemaNames = mappingRefs.map((ref) => ref.split("/").pop()).filter((name) => {
336
+ childSchemaNames = mappingRefs.map((value) => {
337
+ if (Object.hasOwn(schemas, value)) {
338
+ return value;
339
+ }
340
+ const encodedName = _nullishCoalesce(value.split("/").pop(), () => ( ""));
341
+ return decodePointer(encodedName);
342
+ }).filter((name) => {
337
343
  if (!name) return false;
338
344
  const childSchema = schemas[name];
339
345
  return !!childSchema && allOfReferencesSchema(childSchema, baseName);
@@ -348,10 +354,10 @@ function findDiscriminatorChildren(definition) {
348
354
  }
349
355
  if (childSchemaNames.length) {
350
356
  for (const childName of childSchemaNames) {
351
- childrenRefMap.set(childName, `#/components/schemas/${childName}`);
357
+ childrenRefMap.set(childName, `#/components/schemas/${encodePointer(childName)}`);
352
358
  }
353
359
  childrenMap.set(baseName, childSchemaNames);
354
- childrenRefMap.set(baseName, `#/components/schemas/${baseName}`);
360
+ childrenRefMap.set(baseName, `#/components/schemas/${encodePointer(baseName)}`);
355
361
  }
356
362
  }
357
363
  return { children: childrenMap, refs: childrenRefMap };
@@ -718,21 +724,21 @@ function searchForValueByPropAndPointer(property, pointer, schemas = []) {
718
724
  }
719
725
  let foundValue;
720
726
  const rev = [...schemas].toReversed();
721
- for (let i = 0; i < pointers.length; i += 1) {
722
- for (let ii = 0; ii < rev.length; ii += 1) {
723
- let schema = rev[ii];
724
- if (property === "example") {
725
- if ("example" in schema) {
726
- schema = schema.example;
727
- } else {
728
- if (!Array.isArray(schema.examples) || !schema.examples.length) {
729
- continue;
730
- }
731
- schema = [...schema.examples].shift();
732
- }
727
+ for (let ii = 0; ii < rev.length; ii += 1) {
728
+ let schema = rev[ii];
729
+ if (property === "example") {
730
+ if ("example" in schema) {
731
+ schema = schema.example;
733
732
  } else {
734
- schema = schema.default;
733
+ if (!Array.isArray(schema.examples) || !schema.examples.length) {
734
+ continue;
735
+ }
736
+ schema = [...schema.examples].shift();
735
737
  }
738
+ } else {
739
+ schema = schema.default;
740
+ }
741
+ for (let i = pointers.length - 1; i >= 0; i -= 1) {
736
742
  try {
737
743
  foundValue = _jsonpointer2.default.get(schema, pointers[i]);
738
744
  } catch (e7) {
@@ -1536,7 +1542,7 @@ function getParametersAsJSONSchema(operation, api, opts) {
1536
1542
  if (!operation.hasParameters() && !operation.hasRequestBody()) {
1537
1543
  return null;
1538
1544
  }
1539
- const typeKeys = _chunkEARDDQSBcjs.getExtension.call(void 0, _chunkEARDDQSBcjs.PARAMETER_ORDERING, api, operation).map((k) => k.toLowerCase());
1545
+ const typeKeys = _chunk47FD2BINcjs.getExtension.call(void 0, _chunk47FD2BINcjs.PARAMETER_ORDERING, api, operation).map((k) => k.toLowerCase());
1540
1546
  typeKeys[typeKeys.indexOf("form")] = "formData";
1541
1547
  typeKeys.push("metadata");
1542
1548
  const jsonSchema = [transformRequestBody()].concat(...transformParameters()).filter((item) => item !== null);
@@ -1602,5 +1608,6 @@ var SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\]]+)}/g;
1602
1608
 
1603
1609
 
1604
1610
 
1605
- exports.isObject = isObject; exports.isPrimitive = isPrimitive; exports.toPointer = toPointer; exports.decorateComponentSchemasWithRefName = decorateComponentSchemasWithRefName; exports.encodePointer = encodePointer; exports.decodePointer = decodePointer; exports.dereferenceRef = dereferenceRef; exports.dereferenceRefDeep = dereferenceRefDeep; exports.collectRefsInSchema = collectRefsInSchema; exports.filterRequiredRefsToReferenced = filterRequiredRefsToReferenced; exports.mergeReferencedSchemasIntoRoot = mergeReferencedSchemasIntoRoot; exports.matches_mimetype_default = matches_mimetype_default; exports.getParameterContentType = getParameterContentType; exports.cloneObject = cloneObject; exports.applyDiscriminatorOneOfToUsedSchemas = applyDiscriminatorOneOfToUsedSchemas; exports.getSchemaVersionString = getSchemaVersionString; exports.toJSONSchema = toJSONSchema; exports.types = types; exports.getParametersAsJSONSchema = getParametersAsJSONSchema; exports.supportedMethods = supportedMethods; exports.SERVER_VARIABLE_REGEX = SERVER_VARIABLE_REGEX;
1606
- //# sourceMappingURL=chunk-MYFJ2GV3.cjs.map
1611
+
1612
+ exports.isObject = isObject; exports.isPrimitive = isPrimitive; exports.toPointer = toPointer; exports.decorateComponentSchemasWithRefName = decorateComponentSchemasWithRefName; exports.encodePointer = encodePointer; exports.decodePointer = decodePointer; exports.dereferenceRef = dereferenceRef; exports.dereferenceRefDeep = dereferenceRefDeep; exports.collectRefsInSchema = collectRefsInSchema; exports.filterRequiredRefsToReferenced = filterRequiredRefsToReferenced; exports.mergeReferencedSchemasIntoRoot = mergeReferencedSchemasIntoRoot; exports.matches_mimetype_default = matches_mimetype_default; exports.getParameterContentType = getParameterContentType; exports.cloneObject = cloneObject; exports.findDiscriminatorChildren = findDiscriminatorChildren; exports.applyDiscriminatorOneOfToUsedSchemas = applyDiscriminatorOneOfToUsedSchemas; exports.getSchemaVersionString = getSchemaVersionString; exports.toJSONSchema = toJSONSchema; exports.types = types; exports.getParametersAsJSONSchema = getParametersAsJSONSchema; exports.supportedMethods = supportedMethods; exports.SERVER_VARIABLE_REGEX = SERVER_VARIABLE_REGEX;
1613
+ //# sourceMappingURL=chunk-OBYCSKPS.cjs.map