oas 39.0.0 → 39.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -3,7 +3,7 @@ import {
3
3
  } from "./chunk-QTPMJRIE.js";
4
4
  import {
5
5
  Operation
6
- } from "./chunk-O7F6GOHG.js";
6
+ } from "./chunk-QPYBJJ5G.js";
7
7
  import {
8
8
  decodePointer,
9
9
  encodePointer,
@@ -839,4 +839,4 @@ var OpenAPITransformer = class {
839
839
  export {
840
840
  OpenAPITransformer
841
841
  };
842
- //# sourceMappingURL=chunk-RSLFW7GA.js.map
842
+ //# sourceMappingURL=chunk-3RELUPCS.js.map
@@ -1252,8 +1252,9 @@ var Operation = class {
1252
1252
  if (!security || _chunkX7BGCIJNcjs.isRef.call(void 0, security)) return false;
1253
1253
  let type = null;
1254
1254
  if (security.type === "http") {
1255
- if (security.scheme === "basic") type = "Basic";
1256
- else if (security.scheme === "bearer") type = "Bearer";
1255
+ const httpScheme = _optionalChain([security, 'access', _86 => _86.scheme, 'optionalAccess', _87 => _87.toLowerCase, 'call', _88 => _88()]);
1256
+ if (httpScheme === "basic") type = "Basic";
1257
+ else if (httpScheme === "bearer") type = "Bearer";
1257
1258
  else type = security.type;
1258
1259
  } else if (security.type === "oauth2") {
1259
1260
  type = "OAuth2";
@@ -1292,7 +1293,7 @@ var Operation = class {
1292
1293
  if (!prev[security.type]) prev[security.type] = [];
1293
1294
  const exists = prev[security.type].some((sec) => sec._key === security.security._key);
1294
1295
  if (!exists) {
1295
- if (_optionalChain([security, 'access', _86 => _86.security, 'optionalAccess', _87 => _87._requirements])) delete security.security._requirements;
1296
+ if (_optionalChain([security, 'access', _89 => _89.security, 'optionalAccess', _90 => _90._requirements])) delete security.security._requirements;
1296
1297
  prev[security.type].push(security.security);
1297
1298
  }
1298
1299
  });
@@ -1343,7 +1344,7 @@ var Operation = class {
1343
1344
  return [];
1344
1345
  }
1345
1346
  }
1346
- return _optionalChain([response, 'optionalAccess', _88 => _88.headers]) ? Object.keys(response.headers) : [];
1347
+ return _optionalChain([response, 'optionalAccess', _91 => _91.headers]) ? Object.keys(response.headers) : [];
1347
1348
  }).reduce((a, b) => a.concat(b), []);
1348
1349
  }
1349
1350
  if (!this.headers.request.includes("Content-Type") && this.schema.requestBody) {
@@ -1360,7 +1361,7 @@ var Operation = class {
1360
1361
  }
1361
1362
  if (this.schema.responses) {
1362
1363
  const hasResponseContent = Object.keys(this.schema.responses).some((r) => {
1363
- let response = _optionalChain([this, 'access', _89 => _89.schema, 'access', _90 => _90.responses, 'optionalAccess', _91 => _91[r]]);
1364
+ let response = _optionalChain([this, 'access', _92 => _92.schema, 'access', _93 => _93.responses, 'optionalAccess', _94 => _94[r]]);
1364
1365
  if (!response) return false;
1365
1366
  if (_chunkX7BGCIJNcjs.isRef.call(void 0, response)) {
1366
1367
  this.schema.responses[r] = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, response, this.api);
@@ -1427,7 +1428,7 @@ var Operation = class {
1427
1428
  return [];
1428
1429
  }
1429
1430
  const oasTagMap = /* @__PURE__ */ new Map();
1430
- if (Array.isArray(_optionalChain([this, 'access', _92 => _92.api, 'optionalAccess', _93 => _93.tags]))) {
1431
+ if (Array.isArray(_optionalChain([this, 'access', _95 => _95.api, 'optionalAccess', _96 => _96.tags]))) {
1431
1432
  this.api.tags.forEach((tag) => {
1432
1433
  oasTagMap.set(tag.name, tag);
1433
1434
  });
@@ -1470,7 +1471,7 @@ var Operation = class {
1470
1471
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}
1471
1472
  */
1472
1473
  getParameters() {
1473
- let parameters = (_optionalChain([this, 'access', _94 => _94.schema, 'optionalAccess', _95 => _95.parameters]) || []).map((p) => {
1474
+ let parameters = (_optionalChain([this, 'access', _97 => _97.schema, 'optionalAccess', _98 => _98.parameters]) || []).map((p) => {
1474
1475
  let param = p;
1475
1476
  if (_chunkX7BGCIJNcjs.isRef.call(void 0, param)) {
1476
1477
  param = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, param, this.api);
@@ -1478,7 +1479,7 @@ var Operation = class {
1478
1479
  }
1479
1480
  return param;
1480
1481
  }).filter((param) => param !== void 0);
1481
- const commonParams = (_optionalChain([this, 'access', _96 => _96.getCommonParameterContainer, 'call', _97 => _97(), 'optionalAccess', _98 => _98.parameters]) || []).map((p) => {
1482
+ const commonParams = (_optionalChain([this, 'access', _99 => _99.getCommonParameterContainer, 'call', _100 => _100(), 'optionalAccess', _101 => _101.parameters]) || []).map((p) => {
1482
1483
  let param = p;
1483
1484
  if (_chunkX7BGCIJNcjs.isRef.call(void 0, param)) {
1484
1485
  param = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, param, this.api);
@@ -1496,7 +1497,7 @@ var Operation = class {
1496
1497
  * parameters defined on a referenced Path Item (including `components.pathItems`) remain visible.
1497
1498
  */
1498
1499
  getCommonParameterContainer() {
1499
- const pathItem = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _99 => _99.api, 'optionalAccess', _100 => _100.paths, 'optionalAccess', _101 => _101[this.path]]), this.api);
1500
+ const pathItem = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _102 => _102.api, 'optionalAccess', _103 => _103.paths, 'optionalAccess', _104 => _104[this.path]]), this.api);
1500
1501
  if (!pathItem || _chunkX7BGCIJNcjs.isRef.call(void 0, pathItem)) {
1501
1502
  return void 0;
1502
1503
  }
@@ -1566,7 +1567,7 @@ var Operation = class {
1566
1567
  if (key.startsWith("x-")) {
1567
1568
  return false;
1568
1569
  }
1569
- const response = _optionalChain([this, 'access', _102 => _102.schema, 'access', _103 => _103.responses, 'optionalAccess', _104 => _104[key]]);
1570
+ const response = _optionalChain([this, 'access', _105 => _105.schema, 'access', _106 => _106.responses, 'optionalAccess', _107 => _107[key]]);
1570
1571
  return response && typeof response === "object";
1571
1572
  });
1572
1573
  }
@@ -1713,7 +1714,7 @@ var Operation = class {
1713
1714
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#request-body-examples}
1714
1715
  */
1715
1716
  getRequestBodyExamples() {
1716
- const isRequestExampleValueDefined = typeof _optionalChain([this, 'access', _105 => _105.requestBodyExamples, 'optionalAccess', _106 => _106[0], 'optionalAccess', _107 => _107.examples, 'optionalAccess', _108 => _108[0], 'access', _109 => _109.value]) !== "undefined";
1717
+ const isRequestExampleValueDefined = typeof _optionalChain([this, 'access', _108 => _108.requestBodyExamples, 'optionalAccess', _109 => _109[0], 'optionalAccess', _110 => _110.examples, 'optionalAccess', _111 => _111[0], 'access', _112 => _112.value]) !== "undefined";
1717
1718
  if (this.requestBodyExamples && isRequestExampleValueDefined) {
1718
1719
  return this.requestBodyExamples;
1719
1720
  }
@@ -1810,7 +1811,7 @@ var Operation = class {
1810
1811
  if (!this.hasCallbacks()) return [];
1811
1812
  const callbacks = [];
1812
1813
  Object.keys(this.schema.callbacks).forEach((callback) => {
1813
- let cb = _optionalChain([this, 'access', _110 => _110.schema, 'access', _111 => _111.callbacks, 'optionalAccess', _112 => _112[callback]]);
1814
+ let cb = _optionalChain([this, 'access', _113 => _113.schema, 'access', _114 => _114.callbacks, 'optionalAccess', _115 => _115[callback]]);
1814
1815
  if (!cb) return;
1815
1816
  if (_chunkX7BGCIJNcjs.isRef.call(void 0, cb)) {
1816
1817
  this.schema.callbacks[callback] = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, cb, this.api);
@@ -1873,7 +1874,7 @@ var Operation = class {
1873
1874
  * @deprecated Use `oas.getExtension(extension, operation)` instead.
1874
1875
  */
1875
1876
  getExtension(extension) {
1876
- return _optionalChain([this, 'access', _113 => _113.schema, 'optionalAccess', _114 => _114[extension]]);
1877
+ return _optionalChain([this, 'access', _116 => _116.schema, 'optionalAccess', _117 => _117[extension]]);
1877
1878
  }
1878
1879
  /**
1879
1880
  * Returns an object with groups of all example definitions (body/header/query/path/response/etc.).
@@ -1923,7 +1924,7 @@ var Callback = class extends Operation {
1923
1924
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}
1924
1925
  */
1925
1926
  getSummary() {
1926
- if (_optionalChain([this, 'access', _115 => _115.schema, 'optionalAccess', _116 => _116.summary]) && typeof this.schema.summary === "string") {
1927
+ if (_optionalChain([this, 'access', _118 => _118.schema, 'optionalAccess', _119 => _119.summary]) && typeof this.schema.summary === "string") {
1927
1928
  return this.schema.summary;
1928
1929
  } else if (this.parentSchema.summary && typeof this.parentSchema.summary === "string") {
1929
1930
  return this.parentSchema.summary;
@@ -1937,7 +1938,7 @@ var Callback = class extends Operation {
1937
1938
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}
1938
1939
  */
1939
1940
  getDescription() {
1940
- if (_optionalChain([this, 'access', _117 => _117.schema, 'optionalAccess', _118 => _118.description]) && typeof this.schema.description === "string") {
1941
+ if (_optionalChain([this, 'access', _120 => _120.schema, 'optionalAccess', _121 => _121.description]) && typeof this.schema.description === "string") {
1941
1942
  return this.schema.description;
1942
1943
  } else if (this.parentSchema.description && typeof this.parentSchema.description === "string") {
1943
1944
  return this.parentSchema.description;
@@ -1951,7 +1952,7 @@ var Callback = class extends Operation {
1951
1952
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}
1952
1953
  */
1953
1954
  getParameters() {
1954
- let parameters = (_optionalChain([this, 'access', _119 => _119.schema, 'optionalAccess', _120 => _120.parameters]) || []).map((p) => {
1955
+ let parameters = (_optionalChain([this, 'access', _122 => _122.schema, 'optionalAccess', _123 => _123.parameters]) || []).map((p) => {
1955
1956
  let param = p;
1956
1957
  if (_chunkX7BGCIJNcjs.isRef.call(void 0, param)) {
1957
1958
  param = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, param, this.api);
@@ -1979,7 +1980,7 @@ var Webhook = class extends Operation {
1979
1980
  * defined on a referenced Path Item remain visible.
1980
1981
  */
1981
1982
  getCommonParameterContainer() {
1982
- const pathItem = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _121 => _121.api, 'optionalAccess', _122 => _122.webhooks, 'optionalAccess', _123 => _123[this.path]]), this.api);
1983
+ const pathItem = _chunkXEZRUXJ4cjs.dereferenceRef.call(void 0, _optionalChain([this, 'access', _124 => _124.api, 'optionalAccess', _125 => _125.webhooks, 'optionalAccess', _126 => _126[this.path]]), this.api);
1983
1984
  if (!pathItem || _chunkX7BGCIJNcjs.isRef.call(void 0, pathItem)) {
1984
1985
  return void 0;
1985
1986
  }
@@ -1992,7 +1993,7 @@ var Webhook = class extends Operation {
1992
1993
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}
1993
1994
  */
1994
1995
  getSummary() {
1995
- if (_optionalChain([this, 'access', _124 => _124.schema, 'optionalAccess', _125 => _125.summary]) && typeof this.schema.summary === "string") {
1996
+ if (_optionalChain([this, 'access', _127 => _127.schema, 'optionalAccess', _128 => _128.summary]) && typeof this.schema.summary === "string") {
1996
1997
  return this.schema.summary;
1997
1998
  } else if (!this.api.webhooks) {
1998
1999
  return void 0;
@@ -2010,7 +2011,7 @@ var Webhook = class extends Operation {
2010
2011
  * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}
2011
2012
  */
2012
2013
  getDescription() {
2013
- if (_optionalChain([this, 'access', _126 => _126.schema, 'optionalAccess', _127 => _127.description]) && typeof this.schema.description === "string") {
2014
+ if (_optionalChain([this, 'access', _129 => _129.schema, 'optionalAccess', _130 => _130.description]) && typeof this.schema.description === "string") {
2014
2015
  return this.schema.description;
2015
2016
  } else if (!this.api.webhooks) {
2016
2017
  return void 0;
@@ -2049,4 +2050,4 @@ exports.getUserVariable = getUserVariable; exports.escapeRegExp = escapeRegExp;
2049
2050
  * @license Apache-2.0
2050
2051
  * @see {@link https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/samples/fn.js}
2051
2052
  */
2052
- //# sourceMappingURL=chunk-QRWBDGLR.cjs.map
2053
+ //# sourceMappingURL=chunk-ACIEB3SB.cjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-ACIEB3SB.cjs","../src/operation/index.ts","../src/lib/urls.ts","../src/lib/get-user-variable.ts","../src/operation/lib/dedupe-common-parameters.ts","../src/samples/index.ts","../src/samples/utils.ts","../src/operation/lib/get-mediatype-examples.ts","../src/operation/lib/get-response-examples.ts","../src/operation/lib/get-callback-examples.ts","../src/operation/lib/get-example-groups.ts","../src/operation/lib/get-requestbody-examples.ts","../src/operation/lib/operationId.ts","../src/operation/transformers/get-response-as-json-schema.ts"],"names":["schema","normalizeURL"],"mappings":"AAAA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACQA,uDAA6B;ADN7B;AACA;AExBA;AACA,8CAAoC;AF0BpC;AACA;AGrBe,SAAR,eAAA,CAAiC,IAAA,EAAY,QAAA,EAAkB,WAAA,EAAwC;AAC5G,EAAA,IAAI,IAAA,EAAwB,IAAA;AAE5B,EAAA,GAAA,CAAI,OAAA,GAAU,KAAA,GAAQ,KAAA,CAAM,OAAA,CAAQ,IAAA,CAAK,IAAI,EAAA,GAAK,IAAA,CAAK,IAAA,CAAK,MAAA,EAAQ;AAClE,IAAA,GAAA,CAAI,WAAA,EAAa;AACf,MAAA,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,IAAA,CAAK,CAAA,CAAA,EAAA,GAAK,CAAA,CAAE,KAAA,IAAS,WAAW,CAAA;AAAA,IAClD,EAAA,KAAO;AACL,MAAA,IAAA,EAAM,IAAA,CAAK,IAAA,CAAK,CAAC,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ACT,IAAA;AAEM,IAAA;AACD,IAAA;AACI,MAAA;AACT,IAAA;AAEO,IAAA;AACT,EAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAQA,EAAA;AACW,IAAA;AACA,MAAA;AACG,IAAA;AACH,MAAA;AACT,IAAA;AAEM,IAAA;AACD,IAAA;AACI,MAAA;AACT,IAAA;AAEO,IAAA;AACT,EAAA;AACF;AD+qBiB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-ACIEB3SB.cjs","sourcesContent":[null,"import type { Extensions } from '../extensions.js';\nimport type Oas from '../index.js';\nimport type { SplitUrlResult } from '../lib/urls.js';\nimport type {\n HttpMethods,\n KeyedSecuritySchemeObject,\n MediaTypeObject,\n OAS31Document,\n OASDocument,\n OperationObject,\n ParameterObject,\n PathItemObject,\n ReferenceObject,\n RequestBodyObject,\n ResponseObject,\n SchemaWrapper,\n SecurityRequirementObject,\n SecuritySchemeObject,\n SecurityType,\n ServerObject,\n ServerVariable,\n ServerVariablesObject,\n TagObject,\n} from '../types.js';\nimport type { CallbackExample } from './lib/get-callback-examples.js';\nimport type { ExampleGroups } from './lib/get-example-groups.js';\nimport type { RequestBodyExample } from './lib/get-requestbody-examples.js';\nimport type { ResponseExample } from './lib/get-response-examples.js';\nimport type { OperationIDGeneratorOptions } from './lib/operationId.js';\nimport type { getParametersAsJSONSchemaOptions } from './transformers/get-parameters-as-json-schema.js';\nimport type { ResponseSchemaObject } from './transformers/get-response-as-json-schema.js';\n\nimport { normalizeURL } from '@readme/openapi-parser/lib/urls';\n\nimport matchesMimeType from '../lib/matches-mimetype.js';\nimport { decorateComponentSchemasWithRefName, dereferenceRef } from '../lib/refs.js';\nimport { defaultVariablesFromServers, splitUrlFromServers, variablesFromServers } from '../lib/urls.js';\nimport { isRef } from '../types.js';\nimport { supportedMethods } from '../utils.js';\n\nimport { dedupeCommonParameters } from './lib/dedupe-common-parameters.js';\nimport { getCallbackExamples } from './lib/get-callback-examples.js';\nimport { getExampleGroups } from './lib/get-example-groups.js';\nimport { getRequestBodyExamples } from './lib/get-requestbody-examples.js';\nimport { getResponseExamples } from './lib/get-response-examples.js';\nimport { getOperationId, hasOperationId } from './lib/operationId.js';\nimport { getParametersAsJSONSchema } from './transformers/get-parameters-as-json-schema.js';\nimport { getResponseAsJSONSchema } from './transformers/get-response-as-json-schema.js';\n\n// Re-exported so `Operation.getParametersAsJSONSchema()`'s parameter type is publicly nameable.\nexport type { getParametersAsJSONSchemaOptions };\n\nexport class Operation {\n /**\n * The `Oas` instance that this operation belongs to.\n */\n oas: Oas;\n\n /**\n * Schema of the operation from the API Definition.\n */\n schema: OperationObject;\n\n /**\n * OpenAPI API Definition that this operation originated from.\n */\n api: OASDocument;\n\n /**\n * Path that this operation is targeted towards.\n */\n path: string;\n\n /**\n * HTTP Method that this operation is targeted towards.\n */\n method: HttpMethods;\n\n /**\n * The primary Content Type that this operation accepts.\n */\n contentType: string | undefined;\n\n /**\n * An object with groups of all example definitions (body/header/query/path/response/etc.)\n */\n exampleGroups: ExampleGroups | undefined;\n\n /**\n * Request body examples for this operation.\n */\n requestBodyExamples: RequestBodyExample[] | undefined;\n\n /**\n * Response examples for this operation.\n */\n responseExamples: ResponseExample[] | undefined;\n\n /**\n * Callback examples for this operation (if it has callbacks).\n */\n callbackExamples: CallbackExample[] | undefined;\n\n /**\n * Flattened out arrays of both request and response headers that are utilized on this operation.\n */\n headers: {\n request: string[];\n response: string[];\n };\n\n constructor(oas: Oas, path: string, method: HttpMethods, operation: OperationObject) {\n this.oas = oas;\n this.schema = operation;\n this.api = oas.api;\n this.path = path;\n this.method = method;\n\n this.contentType = undefined;\n this.requestBodyExamples = undefined;\n this.responseExamples = undefined;\n this.callbackExamples = undefined;\n this.exampleGroups = undefined;\n this.headers = {\n request: [],\n response: [],\n };\n }\n\n /**\n * Retrieve the `summary` for this operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationsummary}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}\n */\n getSummary(): string | undefined {\n if (this.schema?.summary && typeof this.schema.summary === 'string') {\n return this.schema.summary;\n }\n\n const pathItem = this.getPathItem();\n if (pathItem?.summary && typeof pathItem.summary === 'string') {\n return pathItem.summary;\n }\n\n return undefined;\n }\n\n /**\n * Retrieve the `description` for this operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationdescription}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}\n */\n getDescription(): string | undefined {\n if (this.schema?.description && typeof this.schema.description === 'string') {\n return this.schema.description;\n }\n\n const pathItem = this.getPathItem();\n if (pathItem?.description && typeof pathItem.description === 'string') {\n return pathItem.description;\n }\n\n return undefined;\n }\n\n /**\n * Resolve this operation's Path Item, including when the live document still has a `$ref`.\n * Does not write the target back into `this.api.paths`.\n */\n private getPathItem(): PathItemObject | undefined {\n const pathItem = dereferenceRef(this.api.paths?.[this.path], this.api);\n if (!pathItem || isRef(pathItem)) {\n return undefined;\n }\n\n return pathItem;\n }\n\n /**\n * Retrieve the server objects that apply to this operation, using OpenAPI server precedence:\n * operation-level servers, then path-item servers, then root-level servers.\n */\n getServers(): ServerObject[] {\n if (this.schema.servers?.length) {\n return this.schema.servers;\n }\n\n if (this.api.paths?.[this.path]) {\n const pathItem = dereferenceRef(this.api.paths[this.path], this.api);\n if (pathItem && !isRef(pathItem) && pathItem.servers?.length) {\n return pathItem.servers;\n }\n }\n\n return this.api.servers || [];\n }\n\n url(selected = 0, variables?: ServerVariable): string {\n const url = this.getServers()[selected]?.url;\n const resolvedUrl = url ? this.oas.replaceUrl(url, variables || this.defaultVariables(selected)) : undefined;\n return normalizeURL(resolvedUrl).trim();\n }\n\n variables(selected = 0): ServerVariablesObject {\n return variablesFromServers(this.getServers(), selected);\n }\n\n defaultVariables(selected = 0): ServerVariable {\n return defaultVariablesFromServers(this.getServers(), selected, this.oas.user);\n }\n\n splitUrl(selected = 0): SplitUrlResult {\n return splitUrlFromServers(this.getServers(), selected);\n }\n\n /**\n * Retrieve the primary content type for this operation. If multiple exist, the first JSON-like\n * type will be returned.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-requestbodycontent}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}\n */\n getContentType(): string {\n if (this.contentType) {\n return this.contentType;\n }\n\n let types: string[] = [];\n if (this.schema.requestBody) {\n if (isRef(this.schema.requestBody)) {\n this.schema.requestBody = dereferenceRef(this.schema.requestBody, this.api);\n }\n\n if (this.schema.requestBody && 'content' in this.schema.requestBody) {\n types = Object.keys(this.schema.requestBody.content);\n }\n }\n\n this.contentType = 'application/json';\n if (types?.length) {\n this.contentType = types[0];\n }\n\n // Favor JSON if it exists\n types.forEach(t => {\n if (matchesMimeType.json(t)) {\n this.contentType = t;\n }\n });\n\n return this.contentType;\n }\n\n /**\n * Checks if the current operation has a `x-www-form-urlencoded` content type payload.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-requestbodycontent}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}\n */\n isFormUrlEncoded(): boolean {\n return matchesMimeType.formUrlEncoded(this.getContentType());\n }\n\n /**\n * Checks if the current operation has a mutipart content type payload.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-requestbodycontent}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}\n */\n isMultipart(): boolean {\n return matchesMimeType.multipart(this.getContentType());\n }\n\n /**\n * Checks if the current operation has a JSON-like content type payload.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-requestbodycontent}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}\n */\n isJson(): boolean {\n return matchesMimeType.json(this.getContentType());\n }\n\n /**\n * Checks if the current operation has an XML content type payload.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-requestbodycontent}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-request-body-content}\n */\n isXml(): boolean {\n return matchesMimeType.xml(this.getContentType());\n }\n\n /**\n * Checks if the current operation is a webhook or not.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#oas-webhooks}\n */\n isWebhook(): boolean {\n return this instanceof Webhook;\n }\n\n /**\n * Returns an array of all security requirements associated wtih this operation. If none are\n * defined at the operation level, the securities for the entire API definition are returned\n * (with an empty array as a final fallback).\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#security-requirement-object}\n */\n getSecurity(): SecurityRequirementObject[] {\n // If this definition doesn't have any security schemes defined then regardless if there are\n // `security` requirements defined anywhere we should return an empty array because they're all\n // invalid an unusable without the accompanying schemes.\n if (!this.api?.components?.securitySchemes || !Object.keys(this.api.components.securitySchemes).length) {\n return [];\n }\n\n return this.schema.security || this.api.security || [];\n }\n\n /**\n * Retrieve a collection of grouped security schemes. The inner array determines AND-grouped\n * security schemes, the outer array determines OR-groups.\n *\n * @see {@link https://swagger.io/docs/specification/authentication/#multiple}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-requirement-object}\n * @param filterInvalid Optional flag that, when set to `true`, filters out invalid/nonexistent\n * security schemes, rather than returning `false`.\n */\n getSecurityWithTypes(\n filterInvalid = false,\n ): ((false | { security: KeyedSecuritySchemeObject; type: SecurityType })[] | false)[] {\n return this.getSecurity().map(requirement => {\n let keys: string[];\n try {\n keys = Object.keys(requirement);\n } catch {\n return false;\n }\n\n const keysWithTypes = keys.map(key => {\n let security: SecuritySchemeObject | ReferenceObject | undefined;\n try {\n security = this.api?.components?.securitySchemes?.[key];\n if (!security) return false;\n if (isRef(security)) {\n security = dereferenceRef(security, this.api);\n if (!security || isRef(security)) return false;\n }\n } catch {\n return false;\n }\n\n if (!security || isRef(security)) return false;\n\n let type: SecurityType | null = null;\n\n if (security.type === 'http') {\n // HTTP authentication scheme names are case-insensitive (RFC 7235).\n const httpScheme = security.scheme?.toLowerCase();\n if (httpScheme === 'basic') type = 'Basic';\n else if (httpScheme === 'bearer') type = 'Bearer';\n else type = security.type;\n } else if (security.type === 'oauth2') {\n type = 'OAuth2';\n } else if (security.type === 'apiKey') {\n if (security.in === 'query') type = 'Query';\n else if (security.in === 'header') type = 'Header';\n else if (security.in === 'cookie') type = 'Cookie';\n else type = security.type;\n } else {\n return false;\n }\n\n return {\n type,\n security: {\n ...security,\n _key: key,\n _requirements: requirement[key],\n },\n };\n });\n\n if (filterInvalid) return keysWithTypes.filter(key => key !== false);\n\n return keysWithTypes;\n });\n }\n\n /**\n * Retrieve an object where the keys are unique scheme types, and the values are arrays\n * containing each security scheme of that type.\n *\n */\n prepareSecurity(): Record<SecurityType, KeyedSecuritySchemeObject[]> {\n return this.getSecurityWithTypes().reduce(\n (prev, securities) => {\n if (!securities) return prev;\n\n securities.forEach(security => {\n // Remove non-existent schemes\n if (!security) return;\n if (!prev[security.type]) prev[security.type] = [];\n\n // Only add schemes we haven't seen yet.\n const exists = prev[security.type].some(sec => sec._key === security.security._key);\n if (!exists) {\n // Since an operation can require the same security scheme several times (each with\n // different scope requirements), including the `_requirements` in this object would be\n // misleading since we dedupe the security schemes.\n if (security.security?._requirements) delete security.security._requirements;\n prev[security.type].push(security.security);\n }\n });\n\n return prev;\n },\n {} as Record<SecurityType, KeyedSecuritySchemeObject[]>,\n );\n }\n\n /**\n * Retrieve all of the headers, request and response, that are associated with this operation.\n *\n */\n getHeaders(): Operation['headers'] {\n const security = this.prepareSecurity();\n if (security.Header) {\n this.headers.request = security.Header.map((h: KeyedSecuritySchemeObject) => {\n // Only `apiKey` security schemes contain headers.\n if (!('name' in h)) return false;\n return h.name;\n }).filter((item): item is string => item !== false);\n }\n\n if (security.Bearer || security.Basic || security.OAuth2) {\n this.headers.request.push('Authorization');\n }\n\n if (security.Cookie) {\n this.headers.request.push('Cookie');\n }\n\n if (this.schema.parameters) {\n this.headers.request = this.headers.request.concat(\n this.schema.parameters\n .map(p => {\n let param = p;\n if (isRef(param)) {\n param = dereferenceRef(param, this.api);\n if (!param || isRef(param)) return;\n }\n\n if (param.in && param.in === 'header') return param.name;\n // oxlint-disable-next-line no-useless-return\n return;\n })\n .filter((item): item is string => item !== undefined),\n );\n }\n\n if (this.schema.responses) {\n this.headers.response = Object.keys(this.schema.responses)\n .map(r => {\n let response = this.schema.responses![r];\n if (!response) return [];\n if (isRef(response)) {\n this.schema.responses![r] = dereferenceRef(response, this.api);\n response = this.schema.responses![r];\n if (!response || isRef(response)) {\n return [];\n }\n }\n\n return response?.headers ? Object.keys(response.headers) : [];\n })\n .reduce((a, b) => a.concat(b), []);\n }\n\n // If the operation doesn't already specify a `content-type` request header, we check if the\n // path operation request body contains content, which implies that we should also include the\n // `content-type` header.\n if (!this.headers.request.includes('Content-Type') && this.schema.requestBody) {\n let requestBody = this.schema.requestBody;\n if (requestBody) {\n if (isRef(requestBody)) {\n this.schema.requestBody = dereferenceRef(requestBody, this.api);\n requestBody = this.schema.requestBody;\n }\n\n if (requestBody && !isRef(requestBody) && 'content' in requestBody && Object.keys(requestBody.content)) {\n this.headers.request.push('Content-Type');\n }\n }\n }\n\n // This is a similar approach, but in this case if we check the response content and prioritize\n // the `accept` request header and `content-type` request header.\n if (this.schema.responses) {\n const hasResponseContent = Object.keys(this.schema.responses).some(r => {\n let response = this.schema.responses?.[r];\n if (!response) return false;\n if (isRef(response)) {\n this.schema.responses![r] = dereferenceRef(response, this.api);\n response = this.schema.responses![r];\n if (!response || isRef(response)) {\n return false;\n }\n }\n\n return response.content && Object.keys(response.content).length > 0;\n });\n\n if (hasResponseContent) {\n if (!this.headers.request.includes('Accept')) this.headers.request.push('Accept');\n if (!this.headers.response.includes('Content-Type')) this.headers.response.push('Content-Type');\n }\n }\n\n return this.headers;\n }\n\n /**\n * Determine if this operation has an `operationId` present in its schema. Note that if one is\n * present in the schema but is an empty string then this will return `false`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationid}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-id}\n */\n hasOperationId(): boolean {\n return hasOperationId(this.schema);\n }\n\n /**\n * Determine if an operation has an `operationId` present in its schema. Note that if one is\n * present in the schema but is an empty string then this will return `false`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationid}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-id}\n */\n static hasOperationId(schema: OperationObject): boolean {\n return hasOperationId(schema);\n }\n\n /**\n * Get an `operationId` for this operation. If one is not present (it's not required by the spec!)\n * a hash of the path and method will be returned instead.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationid}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-id}\n */\n getOperationId(opts: OperationIDGeneratorOptions = {}): string {\n return getOperationId(this.path, this.method, this.schema, opts);\n }\n\n /**\n * Get an `operationId` for an operation. If one is not present (it's not required by the spec!)\n * a hash of the path and method will be returned instead.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationid}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-id}\n */\n static getOperationId(\n path: string,\n method: string,\n schema: OperationObject,\n opts: OperationIDGeneratorOptions = {},\n ): string {\n return getOperationId(path, method, schema, opts);\n }\n\n /**\n * Return an array of all tags, and their metadata, that exist on this operation.\n *\n */\n getTags(): TagObject[] {\n if (!('tags' in this.schema)) {\n return [];\n }\n\n const oasTagMap: Map<string, TagObject> = new Map();\n if (Array.isArray(this.api?.tags)) {\n this.api.tags.forEach(tag => {\n oasTagMap.set(tag.name, tag);\n });\n }\n\n const oasTags = Object.fromEntries(oasTagMap);\n\n const tags: TagObject[] = [];\n if (Array.isArray(this.schema.tags)) {\n this.schema.tags.forEach(tag => {\n if (tag in oasTags) {\n tags.push(oasTags[tag]);\n } else {\n tags.push({\n name: tag,\n });\n }\n });\n }\n\n return tags;\n }\n\n /**\n * Return is the operation is flagged as `deprecated` or not.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationdeprecated}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-deprecated}\n */\n isDeprecated(): boolean {\n return Boolean('deprecated' in this.schema ? this.schema.deprecated : false);\n }\n\n /**\n * Determine if the operation has any (non-request body) parameters.\n *\n */\n hasParameters(): boolean {\n return !!this.getParameters().length;\n }\n\n /**\n * Return the parameters (non-request body) on the operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationparameters}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}\n */\n getParameters(): ParameterObject[] {\n let parameters = (this.schema?.parameters || [])\n .map(p => {\n let param = p;\n if (isRef(param)) {\n param = dereferenceRef(param, this.api);\n if (!param || isRef(param)) return;\n }\n\n return param;\n })\n .filter((param): param is ParameterObject => param !== undefined);\n\n const commonParams = (this.getCommonParameterContainer()?.parameters || [])\n .map(p => {\n let param = p;\n if (isRef(param)) {\n param = dereferenceRef(param, this.api);\n if (!param || isRef(param)) return;\n }\n\n return param;\n })\n .filter((param): param is ParameterObject => param !== undefined);\n\n if (commonParams.length) {\n parameters = parameters.concat(dedupeCommonParameters(parameters, commonParams) || []);\n }\n\n return parameters;\n }\n\n /**\n * Path Item that supplies common parameters for this operation. `$ref` pointers are resolved so\n * parameters defined on a referenced Path Item (including `components.pathItems`) remain visible.\n */\n protected getCommonParameterContainer(): PathItemObject | undefined {\n const pathItem = dereferenceRef(this.api?.paths?.[this.path], this.api);\n if (!pathItem || isRef(pathItem)) {\n return undefined;\n }\n\n return pathItem;\n }\n\n /**\n * Determine if this operation has any required parameters.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationparameters}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}\n */\n hasRequiredParameters(): boolean {\n return this.getParameters().some(param => 'required' in param && param.required);\n }\n\n /**\n * Convert the operation into an array of JSON Schema schemas for each available type of\n * parameter available on the operation.\n *\n * Note that this method is not compatible with an operation or OpenAPI definition that has been\n * processed with `.dereference()`. This method can only be called with the _original_ API\n * definition that was used to initialize the `Operation` and `Oas` instance. If a dereferenced\n * schema is present when this is called a `TypeError` will be thrown.\n *\n * @throws {TypeError} If the operation or OpenAPI definition has been run through `.dereference().`\n *\n */\n getParametersAsJSONSchema(opts: getParametersAsJSONSchemaOptions = {}): SchemaWrapper[] | null {\n // Because some downstream tooling that use these JSON Schema objects may need to know original\n // schema names, like in some cases of discriminator mappings in our ReadMe API Explorer, we\n // need to decorate our component schemas with a `x-readme-ref-name` property with that original\n // schema name.\n decorateComponentSchemasWithRefName(this.api);\n\n return getParametersAsJSONSchema(this, this.api, {\n includeDiscriminatorMappingRefs: true,\n ...opts,\n });\n }\n\n /**\n * Get a single response for this status code, formatted as JSON schema.\n *\n * Note that this method is not compatible with an operation or OpenAPI definition that has been\n * processed with `.dereference()`. This method can only be called with the _original_ API\n * definition that was used to initialize the `Operation` and `Oas` instance. If a dereferenced\n * schema is present when this is called a `TypeError` will be thrown.\n *\n * @param statusCode Status code to pull a JSON Schema response for.\n * @param opts Options for schema generation.\n * @param opts.contentType Optional content-type to use. If specified and the response doesn't have\n * this content-type, the function will return null.\n */\n getResponseAsJSONSchema(\n statusCode: number | string,\n opts: {\n /**\n * If you wish to include discriminator mapping `$ref` components alongside your\n * `discriminator` in schemas. Defaults to `true`.\n */\n includeDiscriminatorMappingRefs?: boolean;\n\n /**\n * Optional content-type to use. If specified and the response doesn't have this content-type,\n * the function will return null.\n */\n contentType?: string;\n } = {},\n ): ResponseSchemaObject[] | null {\n // Because some downstream tooling that use these JSON Schema objects may need to know original\n // schema names, like in some cases of discriminator mappings in our ReadMe API Explorer, we\n // need to decorate our component schemas with a `x-readme-ref-name` property with that original\n // schema name.\n decorateComponentSchemasWithRefName(this.api);\n\n return getResponseAsJSONSchema(this, this.api, statusCode, {\n includeDiscriminatorMappingRefs: true,\n ...opts,\n });\n }\n\n /**\n * Get an array of all valid response status codes for this operation.\n *\n */\n getResponseStatusCodes(): string[] {\n if (!this.schema.responses) return [];\n\n if (isRef(this.schema.responses)) {\n this.schema.responses = dereferenceRef(this.schema.responses, this.api);\n if (!this.schema.responses || isRef(this.schema.responses)) {\n return [];\n }\n }\n\n return Object.keys(this.schema.responses).filter(key => {\n // `x-` extensions aren't valid HTTP status codes so we shouldn't return them as one.\n if (key.startsWith('x-')) {\n return false;\n }\n\n const response = this.schema.responses?.[key];\n return response && typeof response === 'object';\n });\n }\n\n /**\n * Retrieve an array of all content types that this operation can return.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#response-object}\n */\n getResponseContentTypes(): string[] {\n if (!this.schema.responses) return [];\n\n const contentTypes = new Set<string>();\n Object.values(this.schema.responses).forEach((response: ReferenceObject | ResponseObject) => {\n let resp = response;\n if (!resp) return;\n if (isRef(resp)) {\n resp = dereferenceRef(resp, this.api);\n\n // If this response still can't be resolved then we shouldn't return anything because it's\n // either an invalid schema or a circular reference.\n if (!resp || isRef(resp)) {\n return;\n }\n }\n\n Object.keys(resp.content || {}).forEach(mimeType => {\n contentTypes.add(mimeType);\n });\n });\n\n return Array.from(contentTypes);\n }\n\n /**\n * Determine if the operation has any request bodies.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationrequestbody}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-request-body}\n */\n hasRequestBody(): boolean {\n return !!this.schema.requestBody;\n }\n\n /**\n * Return the current `requestBody` object, dereferencing it in the process if it's a `$ref`\n * pointer.\n *\n */\n private getResolvedRequestBody(): RequestBodyObject | false {\n let requestBody = this.schema.requestBody;\n if (!requestBody) return false;\n if (isRef(requestBody)) {\n this.schema.requestBody = dereferenceRef(requestBody, this.api);\n requestBody = this.schema.requestBody;\n if (!requestBody || isRef(requestBody)) {\n return false;\n }\n }\n\n return requestBody;\n }\n\n /**\n * Retrieve the list of all available media types that the operations request body can accept.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#media-type-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object}\n */\n getRequestBodyMediaTypes(): string[] {\n if (!this.hasRequestBody()) {\n return [];\n }\n\n const requestBody = this.getResolvedRequestBody();\n if (!requestBody) return [];\n\n return Object.keys(requestBody.content);\n }\n\n /**\n * Determine if this operation has a required request body.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#media-type-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object}\n */\n hasRequiredRequestBody(): boolean {\n if (!this.hasRequestBody()) {\n return false;\n }\n\n const requestBody = this.getResolvedRequestBody();\n if (!requestBody) return false;\n\n if (requestBody.required) {\n return true;\n }\n\n // The OpenAPI spec isn't clear on the differentiation between schema `required` and\n // `requestBody.required` because you can have required top-level schema properties but a\n // non-required requestBody that negates each other.\n //\n // To kind of work ourselves around this and present a better QOL for this accessor, if at this\n // final point where we don't have a required request body, but the underlying Media Type Object\n // schema says that it has required properties then we should ultimately recognize that this\n // request body is required -- even as the request body description says otherwise.\n const parameters = this.getParametersAsJSONSchema();\n if (parameters === null) {\n return false;\n }\n\n return !!parameters\n .filter(js => ['body', 'formData'].includes(js.type))\n .find(js => js.schema && Array.isArray(js.schema.required) && js.schema.required.length);\n }\n\n /**\n * Retrieve a specific request body content schema off this operation.\n *\n * If no media type is supplied this will return either the first available JSON-like request\n * body, or the first available if there are no JSON-like media types present. The return value\n * is an object containing the selected media type, the media type object, and an optional\n * description.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#media-type-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object}\n * @param mediaType Specific request body media type to retrieve if present.\n */\n getRequestBody(\n mediaType?: string,\n ): false | { mediaType: string; mediaTypeObject: MediaTypeObject; description?: string } {\n if (!this.hasRequestBody()) {\n return false;\n }\n\n const requestBody = this.getResolvedRequestBody();\n if (!requestBody) return false;\n\n if (mediaType) {\n if (!(mediaType in requestBody.content)) {\n return false;\n }\n\n return {\n mediaType,\n mediaTypeObject: requestBody.content[mediaType],\n description: requestBody.description,\n };\n }\n\n // Since no media type was supplied we need to find either the first JSON-like media type that\n // we've got, or the first available of anything else if no JSON-like media types are present.\n let availableMediaType: string | undefined;\n const mediaTypes = this.getRequestBodyMediaTypes();\n mediaTypes.forEach((mt: string) => {\n if (!availableMediaType && matchesMimeType.json(mt)) {\n availableMediaType = mt;\n }\n });\n\n if (!availableMediaType) {\n mediaTypes.forEach((mt: string) => {\n if (!availableMediaType) {\n availableMediaType = mt;\n }\n });\n }\n\n if (availableMediaType) {\n return {\n mediaType: availableMediaType,\n mediaTypeObject: requestBody.content[availableMediaType],\n description: requestBody.description,\n };\n }\n\n return false;\n }\n\n /**\n * Retrieve an array of request body examples that this operation has.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#request-body-examples}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#request-body-examples}\n */\n getRequestBodyExamples(): RequestBodyExample[] {\n const isRequestExampleValueDefined = typeof this.requestBodyExamples?.[0]?.examples?.[0].value !== 'undefined';\n\n if (this.requestBodyExamples && isRequestExampleValueDefined) {\n return this.requestBodyExamples;\n }\n\n this.requestBodyExamples = getRequestBodyExamples(this.schema, this.api);\n return this.requestBodyExamples;\n }\n\n /**\n * Return a specific response out of the operation by a given HTTP status code.\n *\n * @param statusCode Status code to pull a response object for.\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#response-object}\n */\n getResponseByStatusCode(statusCode: number | string): ResponseObject | false {\n if (!this.schema.responses) {\n return false;\n }\n\n let response = this.schema.responses[statusCode];\n if (!response) return false;\n if (isRef(response)) {\n this.schema.responses[statusCode] = dereferenceRef(response, this.api);\n response = this.schema.responses[statusCode];\n if (!response || isRef(response)) {\n return false;\n }\n }\n\n return response;\n }\n\n /**\n * Retrieve an array of response examples that this operation has.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object-examples}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#response-object-examples}\n */\n getResponseExamples(): ResponseExample[] {\n if (this.responseExamples) {\n return this.responseExamples;\n }\n\n this.responseExamples = getResponseExamples(this.schema, this.api);\n return this.responseExamples;\n }\n\n /**\n * Determine if the operation has callbacks.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object}\n */\n hasCallbacks(): boolean {\n return Boolean(this.schema.callbacks);\n }\n\n /**\n * Retrieve a specific callback.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object}\n * @param identifier Callback identifier to look for.\n * @param expression Callback expression to look for.\n * @param method HTTP Method on the callback to look for.\n */\n getCallback(identifier: string, expression: string, method: HttpMethods): Callback | false {\n if (!this.schema.callbacks) return false;\n\n let callbackObj = this.schema.callbacks[identifier];\n if (!callbackObj) return false;\n if (isRef(callbackObj)) {\n this.schema.callbacks[identifier] = dereferenceRef(callbackObj, this.api);\n callbackObj = this.schema.callbacks[identifier];\n if (!callbackObj || isRef(callbackObj)) {\n return false;\n }\n }\n\n let callback = callbackObj[expression];\n if (!callback) return false;\n if (isRef(callback)) {\n callbackObj[expression] = dereferenceRef(callback, this.api);\n callback = callbackObj[expression];\n if (!callback || isRef(callback)) {\n return false;\n }\n }\n\n // `PathItemObject` also describes the OpenAPI 3.2 `query` operation.\n const callbackPathItem: PathItemObject = callback;\n if (!callbackPathItem[method]) {\n return false;\n }\n\n const callbackOperation = dereferenceRef(callbackPathItem[method], this.api);\n return new Callback(this.oas, expression, method, callbackOperation, identifier, callback);\n }\n\n /**\n * Retrieve an array of operations created from each callback.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object}\n */\n getCallbacks(): Callback[] {\n if (!this.hasCallbacks()) return [];\n\n const callbacks: Callback[] = [];\n Object.keys(this.schema.callbacks!).forEach(callback => {\n let cb = this.schema.callbacks?.[callback];\n if (!cb) return;\n if (isRef(cb)) {\n this.schema.callbacks![callback] = dereferenceRef(cb, this.api);\n cb = this.schema.callbacks![callback];\n if (!cb || isRef(cb)) {\n return;\n }\n }\n\n Object.keys(cb).forEach(expression => {\n let callbackPath = cb[expression];\n if (!callbackPath) return;\n if (isRef(callbackPath)) {\n cb[expression] = dereferenceRef(callbackPath, this.api);\n callbackPath = cb[expression];\n if (!callbackPath || isRef(callbackPath)) {\n return;\n }\n }\n\n Object.keys(callbackPath).forEach(method => {\n if (!supportedMethods.includes(method as HttpMethods)) return;\n\n const found = this.getCallback(callback, expression, method as HttpMethods);\n if (found) {\n callbacks.push(found);\n }\n });\n });\n });\n\n return callbacks;\n }\n\n /**\n * Retrieve an array of callback examples that this operation has.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object}\n */\n getCallbackExamples(): CallbackExample[] {\n if (this.callbackExamples) {\n return this.callbackExamples;\n }\n\n this.callbackExamples = getCallbackExamples(this.schema, this.api);\n return this.callbackExamples;\n }\n\n /**\n * Determine if a given a custom specification extension exists within the operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}\n * @param extension Specification extension to lookup.\n */\n hasExtension(extension: string): boolean {\n return Boolean(this.schema && extension in this.schema);\n }\n\n /**\n * Retrieve a custom specification extension off of the operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#specification-extensions}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#specification-extensions}\n * @param extension Specification extension to lookup.\n *\n * @deprecated Use `oas.getExtension(extension, operation)` instead.\n */\n getExtension(extension: string | keyof Extensions): any {\n return this.schema?.[extension];\n }\n\n /**\n * Returns an object with groups of all example definitions (body/header/query/path/response/etc.).\n * The examples are grouped by their key when defined via the `examples` map.\n *\n * Any custom code samples defined via the `x-readme.code-samples` extension are returned,\n * regardless of if they have a matching response example.\n *\n * For standard OAS request parameter (e.g., body/header/query/path/etc.) examples,\n * they are only present in the return object if they have a corresponding response example\n * (i.e., a response example with the same key in the `examples` map).\n */\n getExampleGroups(): ExampleGroups {\n if (this.exampleGroups) return this.exampleGroups;\n\n const groups = getExampleGroups(this);\n\n this.exampleGroups = groups;\n\n return groups;\n }\n}\n\nexport class Callback extends Operation {\n /**\n * The identifier that this callback is set to.\n */\n identifier: string;\n\n /**\n * The parent path item object that this Callback exists within.\n */\n parentSchema: PathItemObject;\n\n constructor(\n oas: Oas,\n path: string,\n method: HttpMethods,\n operation: OperationObject,\n identifier: string,\n parentPathItem: PathItemObject,\n ) {\n super(oas, path, method, operation);\n\n this.identifier = identifier;\n this.parentSchema = parentPathItem;\n }\n\n /**\n * Return the primary identifier for this callback.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#callback-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#callback-object}\n */\n getIdentifier(): string {\n return this.identifier;\n }\n\n /**\n * Retrieve the `summary` for this callback.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationsummary}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}\n */\n getSummary(): string | undefined {\n if (this.schema?.summary && typeof this.schema.summary === 'string') {\n return this.schema.summary;\n } else if (this.parentSchema.summary && typeof this.parentSchema.summary === 'string') {\n return this.parentSchema.summary;\n }\n\n return undefined;\n }\n\n /**\n * Retrieve the `description` for this operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationdescription}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}\n */\n getDescription(): string | undefined {\n if (this.schema?.description && typeof this.schema.description === 'string') {\n return this.schema.description;\n } else if (this.parentSchema.description && typeof this.parentSchema.description === 'string') {\n return this.parentSchema.description;\n }\n\n return undefined;\n }\n\n /**\n * Return the parameters (non-request body) on the operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationparameters}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-parameters}\n */\n getParameters(): ParameterObject[] {\n let parameters = (this.schema?.parameters || [])\n .map(p => {\n let param = p;\n if (isRef(param)) {\n param = dereferenceRef(param, this.api);\n if (!param || isRef(param)) return;\n }\n\n return param;\n })\n .filter((param): param is ParameterObject => param !== undefined);\n\n const commonParams = (this.parentSchema.parameters || [])\n .map(p => {\n let param = p;\n if (isRef(param)) {\n param = dereferenceRef(param, this.api);\n if (!param || isRef(param)) return;\n }\n\n return param;\n })\n .filter((param): param is ParameterObject => param !== undefined);\n\n if (commonParams.length) {\n parameters = parameters.concat(dedupeCommonParameters(parameters, commonParams) || []);\n }\n\n return parameters;\n }\n}\n\nexport class Webhook extends Operation {\n /**\n * OpenAPI API Definition that this webhook originated from.\n */\n declare api: OAS31Document;\n\n /**\n * Webhook Path Item that supplies common parameters. `$ref` pointers are resolved so parameters\n * defined on a referenced Path Item remain visible.\n */\n protected getCommonParameterContainer(): PathItemObject | undefined {\n const pathItem = dereferenceRef(this.api?.webhooks?.[this.path], this.api);\n if (!pathItem || isRef(pathItem)) {\n return undefined;\n }\n\n return pathItem;\n }\n\n /**\n * Retrieve the `summary` for this callback.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationsummary}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-summary}\n */\n getSummary(): string | undefined {\n if (this.schema?.summary && typeof this.schema.summary === 'string') {\n return this.schema.summary;\n } else if (!this.api.webhooks) {\n return undefined;\n }\n\n const webhookPath = dereferenceRef(this.api.webhooks[this.path], this.api);\n if (!webhookPath || isRef(webhookPath)) {\n return undefined;\n }\n\n return webhookPath.summary;\n }\n\n /**\n * Retrieve the `description` for this operation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#user-content-operationdescription}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.2.md#user-content-operation-description}\n */\n getDescription(): string | undefined {\n if (this.schema?.description && typeof this.schema.description === 'string') {\n return this.schema.description;\n } else if (!this.api.webhooks) {\n return undefined;\n }\n\n const webhookPath = dereferenceRef(this.api.webhooks[this.path], this.api);\n if (!webhookPath || isRef(webhookPath)) {\n return undefined;\n }\n\n return webhookPath.description;\n }\n}\n","import type { HttpMethods, PathsObject, ServerObject, ServerVariable, ServerVariablesObject, User } from '../types';\nimport type { Match, ParamData } from 'path-to-regexp';\n\nimport { normalizeURL, stripTrailingSlash, substituteServerVariables } from '@readme/openapi-parser/lib/urls';\nimport { match, pathToRegexp } from 'path-to-regexp';\n\nimport getUserVariable from './get-user-variable';\n\nexport interface PathMatch {\n match?: Match<ParamData>;\n operation: PathsObject;\n url: {\n method?: HttpMethods;\n nonNormalizedPath: string;\n origin: string;\n path: string;\n slugs: Record<string, string>;\n };\n}\n\nexport type PathMatches = PathMatch[];\n\nexport type SplitUrlResult = (\n | {\n /**\n * A unique key, where the `value` is concatenated to its index\n */\n key: string;\n type: 'text';\n value: string;\n }\n | {\n /**\n * An optional description for the server variable.\n *\n * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-4}\n */\n description?: string;\n\n /**\n * An enumeration of string values to be used if the substitution options are from a limited set.\n *\n * @see {@link https://spec.openapis.org/oas/v3.1.0#fixed-fields-4}\n */\n enum?: string[];\n\n /**\n * A unique key, where the `value` is concatenated to its index\n */\n key: string;\n type: 'variable';\n value: string;\n }\n)[];\n\n/**\n * Escape a string so it can be interpolated into `RegExp` as a literal.\n *\n * Server URLs and URL origins routinely contain `.`, `?`, `+`, and other regex metacharacters.\n * Using them unescaped treats those characters as operators and can match the wrong host or path.\n */\nexport function escapeRegExp(string: string): string {\n return string.replace(/[.*+?^${}()|[\\]\\\\]/g, '\\\\$&');\n}\n\n/**\n * Normalize an unresolved OpenAPI server URL. Server variable defaults are substituted into a\n * temporary copy of the URL so that a protocol supplied by a variable isn't added a second time.\n *\n * @param servers Server objects to choose from.\n * @param selected The index of the server object that we want to normalize.\n */\nfunction normalizedURLFromServers(servers: ServerObject[] | undefined, selected: number): string {\n const server = servers?.[selected];\n const resolvedUrl = server?.url ? substituteServerVariables(server.url, server.variables) : undefined;\n\n return normalizeURL(server?.url, resolvedUrl);\n}\n\nexport function variablesFromServers(servers: ServerObject[] | undefined, selected = 0): ServerVariablesObject {\n return servers?.[selected]?.variables || {};\n}\n\nexport function defaultVariablesFromServers(\n servers: ServerObject[] | undefined,\n selected = 0,\n user: User = {},\n): ServerVariable {\n const variables = variablesFromServers(servers, selected);\n const defaults: ServerVariable = {};\n\n Object.keys(variables).forEach(key => {\n defaults[key] = getUserVariable(user, key) || variables[key].default || '';\n });\n\n return defaults;\n}\n\nexport function splitUrlFromServers(servers: ServerObject[] | undefined, selected = 0): SplitUrlResult {\n const url = normalizedURLFromServers(servers, selected);\n const variables = variablesFromServers(servers, selected);\n\n return url\n .split(/({.+?})/)\n .filter(Boolean)\n .map((part, i) => {\n const isVariable = part.match(/[{}]/);\n const value = part.replace(/[{}]/g, '');\n const key = `${value}-${i}`;\n\n if (!isVariable) {\n return {\n type: 'text',\n value,\n key,\n } as const;\n }\n\n const variable = variables?.[value];\n return {\n type: 'variable',\n value,\n key,\n description: variable?.description,\n enum: variable?.enum,\n } as const;\n });\n}\n\n/**\n * With a URL that may contain server variables, transform those server variables into regex that\n * we can query against.\n *\n * For example, when given `https://{region}.node.example.com/v14` this will return back:\n *\n * https://([-_a-zA-Z0-9:.[\\\\]]+)\\.node\\.example\\.com/v14\n *\n * Static URL text is regex-escaped so hostname dots (and other metacharacters) stay literal.\n *\n * @param url URL to transform\n */\nexport function transformURLIntoRegex(url: string): string {\n // Split on `{var}` without capturing the name so we only interleave static text and the\n // variable-matching group. `SERVER_VARIABLE_REGEX` is global and capturing, so reusing it here\n // would both leave `lastIndex` dirty and insert the variable names into the result.\n const staticParts = url.split(/\\{[-_a-zA-Z0-9:.[\\]]+\\}/g);\n return stripTrailingSlash(staticParts.map(escapeRegExp).join('([-_a-zA-Z0-9:.[\\\\]]+)'));\n}\n\n/**\n * Decode a URL or OpenAPI pathname so static segments compare equally whether they contain a\n * literal space (or other reserved-safe character) or the equivalent percent-encoding (`%20`).\n *\n * `decodeURI` is used instead of `decodeURIComponent` so `%2F` stays encoded and slash boundaries\n * are not rewritten. Invalid percent-encoding is left unchanged so callers can treat it as a\n * non-match instead of throwing.\n *\n * @param path Pathname to decode.\n */\nfunction decodePathname(path: string): string {\n try {\n return decodeURI(path);\n } catch {\n return path;\n }\n}\n\n/**\n * After `normalizePath()`, only unescaped `:name` tokens are parameters produced from `{param}`.\n * A literal colon (`status:active` → `status\\:active`) must not count as a parameter.\n */\nconst PARAM_TOKEN = /(?<!\\\\):[A-Za-z0-9_]+/;\n\nfunction indexOfParamToken(segment: string): number {\n const found = PARAM_TOKEN.exec(segment);\n return found ? found.index : -1;\n}\n\n/**\n * Escape characters that `path-to-regexp` treats as syntax so a decoded static segment like\n * `{id}` (from `%7Bid%7D`) stays literal text instead of becoming an optional group. Parameter\n * tokens are left intact so prefixed params (`quarterly-:year`) still capture.\n */\nfunction escapeStaticPathToRegexp(segment: string): string {\n const protectedTokens: string[] = [];\n // Keep `:name` and already-escaped `\\:` (from `{a}:{b}` → `:a\\::b`) out of the escaper.\n const withPlaceholders = segment.replace(/\\\\:[A-Za-z0-9_]*|:[A-Za-z0-9_]+/g, token => {\n protectedTokens.push(token);\n return `__OAS_PARAM_${protectedTokens.length - 1}__`;\n });\n\n return withPlaceholders\n .replace(/[:*{}\\\\]/g, '\\\\$&')\n .replace(/__OAS_PARAM_(\\d+)__/g, (_, i) => protectedTokens[Number(i)]);\n}\n\nfunction dropTrailingEmptySegment(segs: string[]): string[] {\n // `/foo/` → ['', 'foo', '']; keep `/` as ['', ''].\n if (segs.length > 2 && segs[segs.length - 1] === '') {\n return segs.slice(0, -1);\n }\n\n return segs;\n}\n\n/**\n * Decode static template text, then escape any colon that decoding introduced so\n * `status%3Aactive` cannot become a `:active` parameter token.\n */\nfunction decodeStatic(text: string): string {\n return decodePathname(text).replace(/(?<![\\\\]):/g, '\\\\:');\n}\n\n/**\n * Return the incoming index at which `incoming` has decoded to exactly `decodedPrefix`, so the\n * remainder (a path-parameter capture) can stay encoded for a single `decodeURIComponent`.\n */\nfunction consumeEncodedPrefix(incoming: string, decodedPrefix: string): number {\n if (decodedPrefix === '') {\n return 0;\n }\n\n for (let i = 0; i <= incoming.length; i += 1) {\n let decoded: string;\n try {\n decoded = decodeURI(incoming.slice(0, i));\n } catch {\n continue;\n }\n\n if (decoded === decodedPrefix) {\n return i;\n }\n\n if (decoded.length > decodedPrefix.length) {\n return -1;\n }\n }\n\n return -1;\n}\n\nfunction alignIncomingSegment(incoming: string, templateSeg: string): string {\n const paramIdx = indexOfParamToken(templateSeg);\n if (paramIdx < 0) {\n return decodePathname(incoming);\n }\n\n if (paramIdx === 0) {\n return incoming;\n }\n\n const staticPrefix = decodePathname(templateSeg.slice(0, paramIdx)).replace(/\\\\:/g, ':');\n const prefixEnd = consumeEncodedPrefix(incoming, staticPrefix);\n if (prefixEnd < 0) {\n return incoming;\n }\n\n return staticPrefix + incoming.slice(prefixEnd);\n}\n\n/**\n * Decode only static text of an incoming pathname, leaving parameter captures encoded so\n * `decodeURIComponent` runs on them exactly once. Segment counts ignore a trailing slash so\n * `/foo%20bar/` still aligns against `/foo bar`, but the path passed to the matcher keeps the\n * authored template's trailing slash — `path-to-regexp` requires `/pets/` when that slash is\n * in the pattern, while a pattern without one still accepts an extra incoming slash.\n */\nfunction alignIncomingPath(pathName: string, normalizedTemplate: string): string {\n const rawPathSegs = pathName.split('/');\n const rawTmplSegs = normalizedTemplate.split('/');\n const pathSegs = dropTrailingEmptySegment(rawPathSegs);\n const tmplSegs = dropTrailingEmptySegment(rawTmplSegs);\n if (pathSegs.length !== tmplSegs.length) {\n return pathName;\n }\n\n const aligned = pathSegs.map((seg, i) => alignIncomingSegment(seg, tmplSegs[i])).join('/');\n return rawTmplSegs.length > tmplSegs.length ? `${aligned}/` : aligned;\n}\n\n/**\n * Normalize a path so that we can use it with `path-to-regexp` to do operation lookups.\n *\n * @param path Path to normalize.\n */\nfunction normalizePath(path: string) {\n const usedNames = new Set<string>();\n\n return (\n path\n // Escape authored colons that are not Express-style `/:param` segment starts, so\n // `/tasks/status:active` stays literal. `{param}` conversion below then introduces the\n // remaining unescaped `:name` tokens (`quarterly-{year}` → `quarterly-:year`).\n .replace(/(?<![/]):/g, '\\\\:')\n // This regex transforms `{pathParam}` into `:pathParam` so we can regex against it. We're\n // also handling quirks here like if there's an optional proceeding or trailing curly bracket\n // (`{{pathParam}` or `{pathParam}}`) as any unescaped curlys, which would be present in\n // `:pathParam}`, will throw a regex exception.\n // oxlint-disable-next-line no-unused-vars\n .replace(/({?){(.*?)}(}?)/g, (str, ...args) => {\n // If a path contains a path parameter with hyphens, like `:dlc-release`, when it's regexd\n // with `path-to-regexp` it match against the `:dlc` portion of the parameter, breaking all\n // matching against the full path.\n //\n // For example on `/games/:game/dlc/:dlc-release` the regex that's actually used to search\n // against a path like `/games/destiny-2/dlc/witch-queen` is the following:\n // /^\\/games(?:\\/([^\\/#\\?]+?))\\/dlc(?:\\/([^\\/#\\?]+?))-release[\\/#\\?]?$/i\n //\n // However if `:dlc-release` is rewritten to `:dlcrelease` we end up with a functional\n // regex: /^\\/games(?:\\/([^\\/#\\?]+?))\\/dlc(?:\\/([^\\/#\\?]+?))[\\/#\\?]?$/i.\n //\n // Stripping every hyphen can collide distinct names in the same path (`{account-holder-id}`\n // and `{accountholderid}`). Disambiguate later collisions so each capture keeps its own\n // slug key and `findTargetPath` still sees the real parameter count.\n const base = args[1].replaceAll('-', '');\n let name = base;\n let suffix = 2;\n while (usedNames.has(name)) {\n name = `${base}_${suffix}`;\n suffix += 1;\n }\n usedNames.add(name);\n return `:${name}`;\n })\n\n // We also need to escape question marks too because they're treated as regex modifiers.\n .split('?')[0]\n );\n}\n\n// Bounds the matcher cache in long-lived multi-tenant processes.\nconst MATCHER_CACHE_MAX_SIZE = 10_000;\ntype PathMatcher = (path: string) => Match<ParamData>;\n\nconst matcherCache = new Map<string, { cleanedPath: string; matcher: PathMatcher | null; normalized: string }>();\n\n/**\n * Compile a path template into its normalized form and `path-to-regexp` matcher. Compiling costs\n * an order of magnitude more than executing and depends only on the template string, so compiled\n * matchers are cached process-wide. A `null` matcher marks a template that can't be compiled.\n *\n * Authored `{param}` syntax is normalized first so percent-encoded braces (`%7Bid%7D`) stay\n * literal. Static segments are then `decodeURI`'d for encoding-insensitive matching; captures\n * are still decoded once by `decodeURIComponent`.\n */\nfunction compilePathMatcher(path: string): {\n cleanedPath: string;\n matcher: PathMatcher | null;\n normalized: string;\n} {\n let compiled = matcherCache.get(path);\n if (compiled === undefined) {\n const normalized = normalizePath(path);\n const normalizedSegs = normalized.split('/');\n const cleanedSegs = normalizedSegs.map(seg => {\n const paramIdx = indexOfParamToken(seg);\n if (paramIdx < 0) {\n return decodeStatic(seg);\n }\n\n if (paramIdx === 0) {\n return seg;\n }\n\n return decodeStatic(seg.slice(0, paramIdx)) + seg.slice(paramIdx);\n });\n const cleanedPath = cleanedSegs.join('/');\n const matcherPath = cleanedSegs.map(seg => escapeStaticPathToRegexp(seg)).join('/');\n let matcher = null;\n try {\n matcher = match(matcherPath, { decode: decodeURIComponent });\n } catch {\n // A template that can't be compiled (maybe it has a malformed path parameter) can never\n // match; record that instead of failing.\n }\n\n if (matcherCache.size >= MATCHER_CACHE_MAX_SIZE) {\n matcherCache.delete(matcherCache.keys().next().value as string);\n }\n\n compiled = { cleanedPath, matcher, normalized };\n matcherCache.set(path, compiled);\n }\n\n return compiled;\n}\n\nfunction safeMatch(matcher: PathMatcher, pathName: string): PathMatch['match'] {\n try {\n return matcher(pathName);\n } catch {\n // Executing a matcher can throw independently of compiling it -- a malformed\n // percent-encoding in the URL will throw in `decodeURIComponent` -- and should count as\n // a non-match, not a failure.\n return false;\n }\n}\n\n/**\n * Generate path matches for a given path and origin on a set of OpenAPI path objects.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#paths-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#paths-object}\n * @param paths The OpenAPI Paths Object to process.\n * @param pathName Path to look for a match.\n * @param origin The origin that we're matching against.\n */\nexport function generatePathMatches(paths: PathsObject, pathName: string, origin: string): PathMatches {\n const rawPathName = pathName.split('?')[0];\n const matches: PathMatches = Object.keys(paths)\n .map(path => {\n const { cleanedPath, matcher, normalized } = compilePathMatcher(path);\n if (!matcher) return false;\n\n // Decode static segments only so `/foo bar/{id}` matches `/foo%20bar/a%2Fb` while the\n // `{id}` capture is still `decodeURIComponent`'d once (`a/b`, not `a%2Fb` or a\n // double-decoded `%252F`).\n const matchResult = safeMatch(matcher, alignIncomingPath(rawPathName, normalized));\n\n const slugs: Record<string, string> = {};\n\n if (matchResult && Object.keys(matchResult.params).length) {\n Object.keys(matchResult.params).forEach(param => {\n slugs[`:${param}`] = (matchResult.params as Record<string, string>)[param];\n });\n }\n\n return {\n url: {\n origin,\n path: cleanedPath.replace(/\\\\:/g, ':'),\n nonNormalizedPath: path,\n slugs,\n },\n operation: paths[path] as PathsObject,\n match: matchResult,\n } satisfies PathMatch;\n })\n .filter(item => item !== false);\n\n return matches.filter(p => p.match);\n}\n\n/**\n * @param pathMatches Array of path matches to filter down.\n * @param targetMethod HTTP method to look for.\n * @returns Filtered down path matches.\n */\nexport function filterPathMethods(pathMatches: PathMatches, targetMethod: HttpMethods): PathMatch[] {\n const regExp = pathToRegexp(targetMethod);\n return pathMatches\n .map(p => {\n const captures = Object.keys(p.operation).filter(r => regExp.regexp.exec(r));\n\n if (captures.length) {\n const method = captures[0];\n p.url.method = method.toUpperCase() as HttpMethods;\n\n return {\n url: p.url,\n operation: p.operation[method],\n };\n }\n\n return false;\n })\n .filter((item): item is PathMatch => Boolean(item));\n}\n\n/**\n * Of the given matches, pick the one with the fewest path parameters, as a literal segment match\n * is more specific than a parameter capture. Ties intentionally go to the **later** match (the\n * `<=`): `Oas.findOperationMatches()` relies on this by appending operation and path-item server\n * matches after root server ones, so that the server defined closest to the operation wins.\n *\n * @param pathMatches URL and PathsObject matches to narrow down to find a target path.\n * @returns An object containing matches that were discovered in the API definition.\n */\nexport function findTargetPath(pathMatches: PathMatch[]): PathMatch | undefined {\n if (!pathMatches.length) {\n return undefined;\n }\n\n let minCount = Object.keys(pathMatches[0].url.slugs).length;\n let found: PathMatch | undefined;\n\n for (let m = 0; m < pathMatches.length; m += 1) {\n const selection = pathMatches[m];\n const paramCount = Object.keys(selection.url.slugs).length;\n if (paramCount <= minCount) {\n minCount = paramCount;\n found = selection;\n }\n }\n\n return found;\n}\n","import type { User } from '../types.js';\n\n/**\n * Retrieve a user variable off of a given user.\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n * @param user The user to get a user variable for.\n * @param property The name of the variable to retrieve.\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport default function getUserVariable(user: User, property: string, selectedApp?: number | string): unknown {\n let key: User | undefined = user;\n\n if ('keys' in user && Array.isArray(user.keys) && user.keys.length) {\n if (selectedApp) {\n key = user.keys.find(k => k.name === selectedApp);\n } else {\n key = user.keys[0];\n }\n }\n\n return key?.[property] || user[property] || null;\n}\n","import type { ParameterObject } from '../../types.js';\n\nimport { isRef } from '../../types.js';\n\n/**\n * With an array of common parameters filter down them to what isn't already present in a list of\n * non-common parameters.\n *\n * @param parameters Array of parameters defined at the operation level.\n * @param commonParameters Array of **common** parameters defined at the path item level.\n */\nexport function dedupeCommonParameters(\n parameters: ParameterObject[],\n commonParameters: ParameterObject[],\n): ParameterObject[] {\n return commonParameters.filter((param: ParameterObject) => {\n return !parameters.find((param2: ParameterObject) => {\n if (param.name && param2.name) {\n return param.name === param2.name && param.in === param2.in;\n } else if (isRef(param) && isRef(param2)) {\n return param.$ref === param2.$ref;\n }\n\n return false;\n });\n });\n}\n","/**\n * This file has been extracted and modified from Swagger UI.\n *\n * @license Apache-2.0\n * @see {@link https://github.com/swagger-api/swagger-ui/blob/master/src/core/plugins/samples/fn.js}\n */\nimport type { OASDocument, SchemaObject } from '../types.js';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\n\nimport { isRef } from '../types.js';\nimport { dereferenceRef, dereferenceRefDeep } from '../utils.js';\n\nimport { isFunc, normalizeArray, objectify, usesPolymorphism } from './utils.js';\n\nconst sampleDefaults = (genericSample: boolean | number | string) => {\n return (schema: SchemaObject): typeof genericSample =>\n typeof schema.default === typeof genericSample ? schema.default : genericSample;\n};\n\nconst primitives: Record<string, (arg: SchemaObject) => boolean | number | string> = {\n string: sampleDefaults('string'),\n string_email: sampleDefaults('user@example.com'),\n 'string_date-time': sampleDefaults(new Date().toISOString()),\n string_date: sampleDefaults(new Date().toISOString().substring(0, 10)),\n 'string_YYYY-MM-DD': sampleDefaults(new Date().toISOString().substring(0, 10)),\n string_uuid: sampleDefaults('3fa85f64-5717-4562-b3fc-2c963f66afa6'),\n string_hostname: sampleDefaults('example.com'),\n string_ipv4: sampleDefaults('198.51.100.42'),\n string_ipv6: sampleDefaults('2001:0db8:5b96:0000:0000:426f:8e17:642a'),\n number: sampleDefaults(0),\n number_float: sampleDefaults(0.0),\n integer: sampleDefaults(0),\n boolean: sampleDefaults(true),\n};\n\nconst primitive = (schema: SchemaObject) => {\n const objectifiedSchema = objectify(schema);\n const { format } = objectifiedSchema;\n let { type } = objectifiedSchema;\n\n if (type === 'null') {\n return null;\n } else if (Array.isArray(type)) {\n if (type.length === 1) {\n type = type[0];\n } else {\n // If one of our types is `null` then we should generate a sample for the non-null value.\n if (type.includes('null')) {\n type = type.filter(t => t !== 'null');\n }\n\n type = type.shift();\n }\n }\n\n // @todo add support for if `type` is an array\n const fn = primitives[`${type}_${format}`] || primitives[type as string];\n if (isFunc(fn)) {\n return fn(objectifiedSchema);\n }\n\n return `Unknown Type: ${objectifiedSchema.type}`;\n};\n\n/**\n * Generate a piece of sample data from a JSON Schema object. If `example` declarations are present\n * they will be utilized, but generally this will generate fake data for the information present in\n * the schema.\n *\n * @param schema JSON Schema to generate a sample for.\n */\nexport default function sampleFromSchema(\n schema: SchemaObject,\n opts: {\n /**\n * An OpenAPI definition to use when resolving `$ref` pointers.\n */\n definition?: OASDocument;\n\n /**\n * If you wish to include data that's flagged as `readOnly`.\n */\n includeReadOnly?: boolean;\n\n /**\n * If you wish to include data that's flatted as `writeOnly`.\n */\n includeWriteOnly?: boolean;\n\n /**\n * Collection of `$ref` pointers to keep track of when dereferencing schemas here in order to\n * prevent infinite loops on circular references\n */\n seenRefs?: Set<string>;\n } = {},\n): Record<string, unknown> | unknown[] | boolean | number | string | null | undefined {\n const seenRefs = opts.seenRefs || new Set<string>();\n let objectifySchema = objectify(schema);\n\n // If this is a `$ref` pointer we should make an attempt to resolve it so we can generate a full\n // sample for this schema.\n let refToRelease: string | undefined;\n if (opts.definition && isRef(objectifySchema)) {\n refToRelease = objectifySchema.$ref;\n if (seenRefs.has(refToRelease)) {\n return undefined;\n }\n\n objectifySchema = dereferenceRef(objectifySchema, opts.definition, seenRefs);\n if (!objectifySchema || isRef(objectifySchema)) {\n return undefined;\n }\n }\n\n try {\n return sampleFromResolvedSchema(objectifySchema, opts, seenRefs);\n } finally {\n // In order to support generating samples from schemas that have circular references we're\n // releasing our `$ref` from the `seenRefs` store here so, it's re-used again in another\n // top-level property we're processing, we can generated another sample for it.\n if (refToRelease) {\n seenRefs.delete(refToRelease);\n }\n }\n}\n\nfunction sampleFromResolvedSchema(\n schema: Record<string, any>,\n opts: {\n definition?: OASDocument;\n includeReadOnly?: boolean;\n includeWriteOnly?: boolean;\n seenRefs?: Set<string>;\n },\n seenRefs: Set<string>,\n) {\n let { type } = schema;\n const { example, additionalProperties, properties, items } = schema;\n const { includeReadOnly, includeWriteOnly } = opts;\n\n if (example !== undefined) {\n // Schema-level examples are explicit authored data, so they should win before we try to merge\n // polymorphic schemas. Merged allOf schemas can retain a `$ref` alongside sibling metadata,\n // which would otherwise be dereferenced as a plain ref and drop this example.\n return dereferenceRefDeep(example, opts.definition, seenRefs);\n }\n\n const hasPolymorphism = usesPolymorphism(schema);\n if (hasPolymorphism === 'allOf') {\n try {\n const definition = opts.definition;\n const resolvedAllOf = schema.allOf.map((subSchema: SchemaObject) => {\n let sub = objectify(subSchema);\n if (definition && isRef(sub)) {\n // We need to dereference `$ref` pointers before mmerging our schemas together because\n // `json-schema-merge-allof` does not support `$ref` resolutions.\n const resolved = dereferenceRef(sub, definition, new Set<string>());\n if (resolved && !isRef(resolved)) {\n sub = resolved as SchemaObject;\n }\n }\n\n return sub;\n });\n\n return sampleFromSchema(\n mergeJSONSchemaAllOf(\n { ...schema, allOf: resolvedAllOf },\n {\n resolvers: {\n // Ignore any unrecognized OAS-specific keywords that might be present on the schema\n // (like `xml`).\n defaultResolver: mergeJSONSchemaAllOf.options.resolvers.title,\n },\n },\n ),\n {\n ...opts,\n seenRefs,\n },\n );\n } catch {\n return;\n }\n } else if (hasPolymorphism) {\n const samples = (schema[hasPolymorphism] as SchemaObject[]).map(s => {\n return sampleFromSchema(s, { ...opts, seenRefs });\n });\n\n if (samples.length === 1) {\n return samples[0];\n } else if (samples.some(s => s === null)) {\n // If one of our samples is null then we should try to surface the first non-null one.\n return samples.find(s => s !== null);\n }\n\n // If we still don't have a sample then we should just return whatever the first sample we've\n // got is. The sample might not be a _full_ example but it should be enough to act as a sample.\n return samples[0];\n }\n\n if (!type) {\n if (properties || additionalProperties) {\n type = 'object';\n } else if (items) {\n type = 'array';\n } else {\n return;\n }\n }\n\n if (type === 'object' || (Array.isArray(type) && type.includes('object'))) {\n const props = objectify(properties);\n const obj: Record<string, any> = {};\n for (const name in props) {\n if (props?.[name].deprecated) {\n continue;\n }\n\n if (props?.[name].readOnly && !includeReadOnly) {\n continue;\n }\n\n if (props?.[name].writeOnly && !includeWriteOnly) {\n continue;\n }\n\n if (props[name].examples?.length) {\n obj[name] = props[name].examples[0];\n continue;\n }\n\n obj[name] = sampleFromSchema(props[name], { ...opts, seenRefs });\n }\n\n if (additionalProperties === true) {\n obj.additionalProp = {};\n } else if (additionalProperties) {\n const additionalProps = objectify(additionalProperties);\n const additionalPropVal = sampleFromSchema(additionalProps, { ...opts, seenRefs });\n\n obj.additionalProp = additionalPropVal;\n }\n\n return obj;\n }\n\n if (type === 'array' || (Array.isArray(type) && type.includes('array'))) {\n // `items` should always be present on arrays, but if it isn't we should at least do our best\n // to support its absence.\n if (typeof items === 'undefined') {\n return [];\n }\n\n if (Array.isArray(items.anyOf)) {\n return items.anyOf.map((i: SchemaObject) =>\n sampleFromSchema(i, {\n ...opts,\n seenRefs,\n }),\n );\n }\n\n if (Array.isArray(items.oneOf)) {\n return items.oneOf.map((i: SchemaObject) =>\n sampleFromSchema(i, {\n ...opts,\n seenRefs,\n }),\n );\n }\n\n return [sampleFromSchema(items, { ...opts, seenRefs })];\n }\n\n if (schema.enum) {\n if (schema.default) {\n return schema.default;\n }\n\n return normalizeArray(schema.enum as string[])[0];\n }\n\n if (type === 'file') {\n return;\n }\n\n return primitive(schema);\n}\n","/**\n * Portions of this file have been extracted and modified from Swagger UI.\n *\n * @license Apache-2.0\n * @see {@link https://github.com/swagger-api/swagger-ui/blob/master/src/core/utils.js}\n */\nimport type { SchemaObject } from '../types.js';\n\nimport { isObject } from '../lib/helpers.js';\n\nexport function usesPolymorphism(schema: SchemaObject): 'allOf' | 'anyOf' | 'oneOf' | false {\n if (schema.oneOf) {\n return 'oneOf';\n } else if (schema.anyOf) {\n return 'anyOf';\n } else if (schema.allOf) {\n return 'allOf';\n }\n\n return false;\n}\n\nexport function objectify(thing: Record<string, unknown> | unknown): Record<string, any> {\n if (!isObject(thing)) {\n return {};\n }\n\n return thing;\n}\n\nexport function normalizeArray(arr: (number | string)[] | number | string): (number | string)[] {\n if (Array.isArray(arr)) {\n return arr;\n }\n\n return [arr];\n}\n\n// oxlint-disable-next-line typescript/no-unsafe-function-type -- This is part of a type guard.\nexport function isFunc(thing: unknown): thing is Function {\n return typeof thing === 'function';\n}\n","import type { MediaTypeObject, OASDocument } from '../../types.js';\n\nimport matchesMimeType from '../../lib/matches-mimetype.js';\nimport { collectRefsInSchema, dereferenceRef, dereferenceRefDeep } from '../../lib/refs.js';\nimport sampleFromSchema from '../../samples/index.js';\nimport { isRef } from '../../types.js';\n\nexport interface MediaTypeExample {\n description?: string;\n summary?: string;\n title?: string;\n value: unknown;\n}\n\n/**\n * Extracts a collection of examples from an OpenAPI Media Type Object. The example will either\n * come from the `example` property, the first item in an `examples` array, or if none of those are\n * present it will generate an example based off its schema.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#media-type-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#media-type-object}\n * @param mediaType The media type that we're looking for examples for.\n * @param mediaTypeObject The media type object that we're looking for examples for.\n */\nexport function getMediaTypeExamples(\n mediaType: string,\n mediaTypeObject: MediaTypeObject,\n definition: OASDocument,\n opts: {\n /**\n * If you wish to include data that's flagged as `readOnly`.\n */\n includeReadOnly?: boolean;\n\n /**\n * If you wish to include data that's flatted as `writeOnly`.\n */\n includeWriteOnly?: boolean;\n } = {},\n): MediaTypeExample[] {\n if (mediaTypeObject.example) {\n mediaTypeObject.example = dereferenceRefDeep(mediaTypeObject.example, definition);\n\n // If there is no example or if it contains any `$ref` pointers that we couldn't resolve then\n // we shouldn't return anything because to the user it'll look like we generated an invalid\n // example.\n if (mediaTypeObject.example === undefined || collectRefsInSchema(mediaTypeObject.example).size > 0) {\n return [];\n }\n\n return [\n {\n value: mediaTypeObject.example,\n },\n ];\n } else if (mediaTypeObject.examples) {\n const { examples } = mediaTypeObject;\n const multipleExamples = Object.keys(examples)\n .map(key => {\n let summary: string | undefined = key;\n let description: string | undefined;\n\n let example = examples[key];\n if (example !== null && typeof example === 'object') {\n if (isRef(example)) {\n example = dereferenceRef(example, definition);\n if (!example || isRef(example)) {\n return false;\n }\n }\n\n if ('summary' in example) {\n summary = example.summary;\n }\n\n if ('description' in example) {\n description = example.description;\n }\n\n if ('value' in example) {\n example.value = dereferenceRefDeep(example.value, definition);\n\n // If there is no example value or if it contains any `$ref` pointers that we couldn't\n // resolve then we shouldn't return anything because to the user it'll look like we\n // generated an invalid example.\n if (example.value === undefined || collectRefsInSchema(example.value).size > 0) {\n return false;\n }\n\n example = example.value;\n }\n }\n\n const ret: MediaTypeExample = { summary, title: key, value: example };\n if (description) {\n ret.description = description;\n }\n\n return ret;\n })\n .filter((item): item is MediaTypeExample => item !== false);\n\n // If we were able to grab examples from the `examples` property return them (`examples` can\n // sometimes be an empty object), otherwise we should try to generate some instead.\n if (multipleExamples.length) {\n return multipleExamples;\n }\n }\n\n if (mediaTypeObject.schema) {\n // We do not fully support XML so we shouldn't generate XML samples for XML schemas.\n if (!matchesMimeType.xml(mediaType)) {\n return [\n {\n value: sampleFromSchema(structuredClone(mediaTypeObject.schema), {\n ...opts,\n definition,\n }),\n },\n ];\n }\n }\n\n return [];\n}\n","import type { OASDocument, OperationObject } from '../../types.js';\nimport type { MediaTypeExample } from './get-mediatype-examples.js';\n\nimport { dereferenceRef } from '../../lib/refs.js';\nimport { isRef } from '../../types.js';\n\nimport { getMediaTypeExamples } from './get-mediatype-examples.js';\n\nexport interface ResponseExample {\n mediaTypes: Record<string, MediaTypeExample[]>;\n onlyHeaders?: boolean;\n status: string;\n}\n\n/**\n * Retrieve a collection of response examples keyed, by their media type.\n *\n * @param operation Operation to retrieve response examples for.\n */\nexport function getResponseExamples(operation: OperationObject, definition: OASDocument): ResponseExample[] {\n return Object.keys(operation.responses || {})\n .map(status => {\n let response = operation.responses?.[status];\n let onlyHeaders = false;\n\n if (!response) return false;\n if (isRef(response)) {\n response = dereferenceRef(response, definition);\n if (!response || isRef(response)) return false;\n }\n\n const mediaTypes: Record<string, MediaTypeExample[]> = {};\n (response?.content ? Object.keys(response.content) : []).forEach(mediaType => {\n if (!mediaType) return;\n\n const mediaTypeObject = response.content?.[mediaType];\n if (!mediaTypeObject) return;\n\n const examples = getMediaTypeExamples(mediaType, mediaTypeObject, definition, {\n includeReadOnly: true,\n includeWriteOnly: false,\n });\n\n if (examples) {\n mediaTypes[mediaType] = examples;\n }\n });\n\n // If the response has no content, but has headers, hardcode an empty example so the headers\n // modal will still display\n if (response.headers && Object.keys(response.headers).length && !Object.keys(mediaTypes).length) {\n mediaTypes['*/*'] = [];\n onlyHeaders = true;\n }\n\n if (!Object.keys(mediaTypes).length) {\n return false;\n }\n\n return {\n status,\n mediaTypes,\n ...(onlyHeaders ? { onlyHeaders } : {}),\n };\n })\n .filter((item): item is ResponseExample => item !== false);\n}\n","import type { OASDocument, OperationObject } from '../../types.js';\nimport type { ResponseExample } from './get-response-examples.js';\n\nimport { dereferenceRef } from '../../lib/refs.js';\nimport { isRef } from '../../types.js';\n\nimport { getResponseExamples } from './get-response-examples.js';\n\nexport interface CallbackExample {\n example: ResponseExample[];\n expression: string;\n identifier: string;\n method: string;\n}\n\n/**\n * With an OpenAPI Operation Object return back a collection of examples for any callbacks that may\n * be present.\n *\n * @param operation Operation to retrieve callback examples from.\n */\nexport function getCallbackExamples(operation: OperationObject, definition: OASDocument): CallbackExample[] {\n if (!operation.callbacks) {\n return [];\n }\n\n const examples = Object.keys(operation.callbacks).map(identifier => {\n let callback = operation.callbacks?.[identifier];\n if (!callback) return [];\n if (isRef(callback)) {\n callback = dereferenceRef(callback, definition);\n if (!callback || isRef(callback)) return [];\n }\n\n const items = Object.keys(callback).map(expression => {\n let callbackPath = callback[expression];\n if (!callbackPath) return [];\n if (isRef(callbackPath)) {\n callbackPath = dereferenceRef(callbackPath, definition);\n if (!callbackPath || isRef(callbackPath)) return [];\n }\n\n return Object.keys(callbackPath).map(method => {\n if (['servers', 'parameters', 'summary', 'description'].includes(method)) {\n return false;\n }\n\n // This is a `PathItemObject` but `PathItemObject` extends `OperationObject` so this is\n // fine to force cast.\n const pathItem = callbackPath as Record<string, OperationObject>;\n const callbackOperation = dereferenceRef(pathItem[method], definition);\n if (!callbackOperation || isRef(callbackOperation)) return false;\n\n const example = getResponseExamples(callbackOperation, definition);\n if (!example.length) return false;\n\n return {\n identifier,\n expression,\n method,\n example,\n };\n });\n });\n\n return items.flat().filter(item => item !== false);\n });\n\n return examples.flat();\n}\n","import type { Extensions } from '../../extensions.js';\nimport type { DataForHAR } from '../../types.js';\nimport type { Operation } from '../index.js';\nimport type { MediaTypeExample } from './get-mediatype-examples.js';\n\nimport { getExtension } from '../../extensions.js';\nimport { dereferenceRef } from '../../lib/refs.js';\nimport { isRef } from '../../types.js';\n\nexport type ExampleGroups = Record<\n string,\n {\n /**\n * Array of custom code samples that contain `correspondingExample` key.\n * Mutually exclusive of `request`. Note that if this object is present,\n * there may or may not be corresponding responses in the `response` object.\n */\n customCodeSamples?: (NonNullable<Extensions['code-samples']>[number] & {\n /**\n * The index in the originally defined `code-samples` array\n */\n originalIndex: number;\n })[];\n\n /**\n * Title of example group. This is derived from the `summary` field of one of\n * the operation's example objects. The precedence is as follows (from highest to lowest):\n * 1. The first custom code sample's `name` field.\n * 2. The first request parameter (e.g., cookie/header/path/query) example object that\n * contains a `summary` field\n * 3. The request body example object's `summary` field\n * 4. The response example object's `summary` field\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#example-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object}\n */\n name: string;\n\n /**\n * Object containing the example request data for the current example key.\n * Mutually exclusive of `customCodeSamples`. If `customCodeSamples` is present,\n * any request example definitions are ignored.\n */\n request?: DataForHAR;\n\n /**\n * Object containing the example response data for the current example key.\n */\n response?: {\n /**\n * The content type of the current example\n *\n * @example \"application/json\"\n * @example \"text/plain\"\n */\n mediaType: string;\n\n /**\n * The entire response example object. The example value itself is contained\n * within `value`.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#example-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#example-object}\n */\n mediaTypeExample: MediaTypeExample;\n\n /**\n * The HTTP status code for the current response example\n *\n * @example \"2xx\"\n * @example \"400\"\n */\n status: string;\n };\n }\n>;\n\n/**\n * Internal key to represent custom code samples that do not have a corresponding response example.\n */\nconst noCorrespondingResponseKey = 'NoCorrespondingResponseForCustomCodeSample';\n\n/**\n * Takes a groups object and an operation and adds any matching response examples\n * to existing groups object\n */\nfunction addMatchingResponseExamples(groups: ExampleGroups, operation: Operation) {\n operation.getResponseExamples().forEach(example => {\n Object.entries(example.mediaTypes || {}).forEach(([mediaType, mediaTypeExamples]) => {\n mediaTypeExamples.forEach(mediaTypeExample => {\n // only add a response example if the `title` field exists\n // and it matches one of the existing example keys\n if (mediaTypeExample.title && Object.keys(groups).includes(mediaTypeExample.title)) {\n groups[mediaTypeExample.title].response = {\n mediaType,\n mediaTypeExample,\n status: example.status,\n };\n\n // if the current group doesn't already have a name set,\n // use the response example object's summary field\n if (!groups[mediaTypeExample.title].name) {\n groups[mediaTypeExample.title].name = mediaTypeExample.summary || mediaTypeExample.title;\n }\n }\n });\n });\n });\n}\n\n/**\n * Returns a name for the given custom code sample. If there isn't already one defined,\n * we construct a fallback value based on where the sample is in the array.\n */\nfunction getDefaultName(\n sample: NonNullable<Extensions['code-samples']>[number],\n count: Record<string, number>,\n): string {\n return sample.name && sample.name.length > 0\n ? sample.name\n : `Default${count[sample.language] > 1 ? ` #${count[sample.language]}` : ''}`;\n}\n\n/**\n * Returns an object with groups of all example definitions (body/header/query/path/response/etc.).\n * The examples are grouped by their key when defined via the `examples` map.\n *\n * Any custom code samples defined via the `x-readme.code-samples` extension are returned,\n * regardless of if they have a matching response example.\n *\n * For standard OAS request parameter (e.g., body/header/query/path/etc.) examples,\n * they are only present in the return object if they have a corresponding response example\n * (i.e., a response example with the same key in the `examples` map).\n */\nexport function getExampleGroups(operation: Operation): ExampleGroups {\n const namelessCodeSampleCounts: Record<string, number> = {};\n const groups: ExampleGroups = {};\n\n // add custom code samples\n const codeSamples = getExtension('code-samples', operation.api, operation) as Extensions['code-samples'];\n codeSamples?.forEach((sample, i) => {\n if (namelessCodeSampleCounts[sample.language]) {\n namelessCodeSampleCounts[sample.language] += 1;\n } else {\n namelessCodeSampleCounts[sample.language] = 1;\n }\n const name = getDefaultName(sample, namelessCodeSampleCounts);\n\n // sample contains `correspondingExample` key\n if (sample.correspondingExample) {\n if (groups[sample.correspondingExample]?.customCodeSamples?.length) {\n groups[sample.correspondingExample].customCodeSamples!.push({ ...sample, name, originalIndex: i });\n } else if (sample.correspondingExample) {\n groups[sample.correspondingExample] = {\n name,\n customCodeSamples: [{ ...sample, name, originalIndex: i }],\n };\n }\n }\n\n // sample does not contain a corresponding response example\n else if (groups[noCorrespondingResponseKey]?.customCodeSamples?.length) {\n groups[noCorrespondingResponseKey].customCodeSamples.push({ ...sample, name, originalIndex: i });\n } else {\n groups[noCorrespondingResponseKey] = {\n name,\n customCodeSamples: [{ ...sample, name, originalIndex: i }],\n };\n }\n });\n\n // if we added any custom code samples, add the corresponding response examples and return\n if (Object.keys(groups).length) {\n addMatchingResponseExamples(groups, operation);\n return groups;\n }\n\n // add request param examples\n operation.getParameters().forEach(param => {\n Object.entries(param.examples || {}).forEach(([exampleKey, paramExample]) => {\n let example = paramExample;\n if (isRef(example)) {\n example = dereferenceRef(example, operation.api);\n if (!example || isRef(example)) return;\n }\n\n groups[exampleKey] = {\n ...groups[exampleKey],\n name: groups[exampleKey]?.name || example.summary || exampleKey,\n request: {\n ...groups[exampleKey]?.request,\n [param.in]: {\n ...groups[exampleKey]?.request?.[param.in],\n [param.name]: example.value,\n },\n },\n };\n });\n });\n\n // add request body examples\n operation.getRequestBodyExamples().forEach(requestExample => {\n requestExample.examples.forEach((mediaTypeExample: MediaTypeExample) => {\n if (mediaTypeExample.title) {\n const mediaType = requestExample.mediaType === 'application/x-www-form-urlencoded' ? 'formData' : 'body';\n groups[mediaTypeExample.title] = {\n ...groups[mediaTypeExample.title],\n name: groups[mediaTypeExample.title]?.name || mediaTypeExample.summary || mediaTypeExample.title,\n request: {\n ...groups[mediaTypeExample.title]?.request,\n [mediaType]: mediaTypeExample.value,\n },\n };\n }\n });\n });\n\n // if we added any request examples, add the corresponding response examples\n if (Object.keys(groups).length) {\n addMatchingResponseExamples(groups, operation);\n }\n\n // prune any objects that don't have both a request and a response\n Object.entries(groups).forEach(([groupId, group]) => {\n if (group.request && !group.response) {\n delete groups[groupId];\n }\n });\n\n return groups;\n}\n","import type { OASDocument, OperationObject } from '../../types.js';\nimport type { MediaTypeExample } from './get-mediatype-examples.js';\n\nimport { dereferenceRef } from '../../lib/refs.js';\nimport { isRef } from '../../types.js';\n\nimport { getMediaTypeExamples } from './get-mediatype-examples.js';\n\nexport interface RequestBodyExample {\n examples: MediaTypeExample[];\n mediaType: string;\n}\n\n/**\n * Retrieve a collection of request body examples, keyed by their media type.\n *\n * @param operation Operation to retrieve requestBody examples for.\n */\nexport function getRequestBodyExamples(operation: OperationObject, definition: OASDocument): RequestBodyExample[] {\n let requestBody = operation.requestBody;\n if (!requestBody) {\n return [];\n } else if (isRef(requestBody)) {\n requestBody = dereferenceRef(requestBody, definition);\n }\n\n // If this request body still can't be resolved then we shouldn't return anything because it's\n // either an invalid schema or a circular reference.\n if (!requestBody || isRef(requestBody) || !requestBody.content) {\n return [];\n }\n\n return Object.keys(requestBody.content || {})\n .map(mediaType => {\n const mediaTypeObject = requestBody.content[mediaType];\n const examples = getMediaTypeExamples(mediaType, mediaTypeObject, definition, {\n includeReadOnly: false,\n includeWriteOnly: true,\n });\n\n if (!examples.length) {\n return false;\n }\n\n return {\n mediaType,\n examples,\n };\n })\n .filter((item): item is RequestBodyExample => item !== false);\n}\n","import type { OperationObject } from '../../types.ts';\n\nexport interface OperationIDGeneratorOptions {\n /**\n * Generate a JS method-friendly operation ID when one isn't present.\n *\n * For backwards compatiblity reasons this option will be indefinitely supported however we\n * recommend using `friendlyCase` instead as it's a heavily improved version of this option.\n *\n * @see {friendlyCase}\n * @deprecated\n */\n camelCase?: boolean;\n\n /**\n * Generate a human-friendly, but still camelCase, operation ID when one isn't present. The\n * difference between this and `camelCase` is that this also ensure that consecutive words are\n * not present in the resulting ID. For example, for the endpoint `/candidate/{candidate}` will\n * return `getCandidateCandidate` for `camelCase` however `friendlyCase` will return\n * `getCandidate`.\n *\n * The reason this friendliness is just not a part of the `camelCase` option is because we have\n * a number of consumers of the old operation ID style and making that change there would a\n * breaking change that we don't have any easy way to resolve.\n */\n friendlyCase?: boolean;\n}\n\n/**\n * Determine if an operation has an `operationId` present in its schema. Note that if one is\n * present in the schema but is an empty string then this will return false.\n *\n */\nexport function hasOperationId(operation: OperationObject): boolean {\n return Boolean('operationId' in operation && operation.operationId?.length);\n}\n\n/**\n * Get an `operationId` for an operation. If one is not present (it's not required by the spec!)\n * a hash of the path and method will be returned instead.\n *\n */\nexport function getOperationId(\n path: string,\n method: string,\n operation: OperationObject,\n opts: OperationIDGeneratorOptions = {},\n): string {\n function sanitize(id: string) {\n // We aren't sanitizing underscores here by default in order to preserve operation IDs that\n // were already generated with this method in the past.\n return id\n .replace(opts?.camelCase || opts?.friendlyCase ? /[^a-zA-Z0-9_]/g : /[^a-zA-Z0-9]/g, '-') // Remove weird characters\n .replace(/--+/g, '-') // Remove double --'s\n .replace(/^-|-$/g, ''); // Don't start or end with -\n }\n\n const operationIdExists = hasOperationId(operation);\n let operationId: string;\n if (operationIdExists) {\n // `operationId` has already been guaranteed to be a truthy string by `hasOperationId()`.\n operationId = operation.operationId as string;\n } else {\n operationId = sanitize(path).toLowerCase();\n }\n\n const currMethod = method.toLowerCase();\n if (opts?.camelCase || opts?.friendlyCase) {\n if (opts?.friendlyCase) {\n // In order to generate friendlier operation IDs we should swap out underscores with spaces\n // so the end result will be _slightly_ more camelCase.\n operationId = operationId.replaceAll('_', ' ');\n\n if (!operationIdExists) {\n // In another effort to generate friendly operation IDs we should prevent words from\n // appearing in consecutive order (eg. `/candidate/{candidate}` should generate\n // `getCandidate` not `getCandidateCandidate`). However we only want to do this if we're\n // generating the operation ID as if they intentionally added a consecutive word into the\n // operation ID then we should respect that.\n operationId = operationId\n .replace(/[^a-zA-Z0-9_]+(.)/g, (_, chr) => ` ${chr}`)\n .split(' ')\n .filter((word, i, arr) => word !== arr[i - 1])\n .join(' ');\n }\n }\n\n operationId = operationId.replace(/[^a-zA-Z0-9_]+(.)/g, (_, chr) => chr.toUpperCase());\n if (operationIdExists) {\n operationId = sanitize(operationId);\n }\n\n // Never start with a number.\n operationId = operationId.replace(/^[0-9]/g, match => `_${match}`);\n\n // Ensure that the first character of an `operationId` is always lowercase.\n operationId = operationId.charAt(0).toLowerCase() + operationId.slice(1);\n\n // If the generated `operationId` already starts with the method (eg. `getPets`) we don't want\n // to double it up into `getGetPets`.\n if (operationId.startsWith(currMethod)) {\n return operationId;\n }\n\n // If this operation already has an `operationId` and we just cleaned it up then we shouldn't\n // prefix it with an HTTP method.\n if (operationIdExists) {\n return operationId;\n }\n\n // Because we're merging the `operationId` into an HTTP method we need to reset the first\n // character of it back to lowercase so we end up with `getBuster`, not `getbuster`.\n operationId = operationId.charAt(0).toUpperCase() + operationId.slice(1);\n return `${currMethod}${operationId}`;\n } else if (operationIdExists) {\n return operationId;\n }\n\n return `${currMethod}_${operationId}`;\n}\n","import type { toJSONSchemaOptions } from '../../lib/openapi-to-json-schema.js';\nimport type { HeaderObject, MediaTypeObject, OASDocument, ResponseObject, SchemaObject } from '../../types.js';\nimport type { Operation } from '../index.js';\n\nimport { applyDiscriminatorOneOfToUsedSchemas } from '../../lib/build-discriminator-one-of.js';\nimport { cloneObject } from '../../lib/clone-object.js';\nimport { isPrimitive } from '../../lib/helpers.js';\nimport matches from '../../lib/matches-mimetype.js';\nimport { getSchemaVersionString, toJSONSchema } from '../../lib/openapi-to-json-schema.js';\nimport {\n collectRefsInSchema,\n dereferenceRef,\n filterRequiredRefsToReferenced,\n mergeReferencedSchemasIntoRoot,\n} from '../../lib/refs.js';\nimport { isRef } from '../../types.js';\n\nexport interface ResponseSchemaObject {\n description?: string;\n label: string;\n schema: SchemaObject;\n type: string[] | string;\n}\n\nconst isJSON = matches.json;\n\n/**\n * Turn a header map from OpenAPI 3.0 (and some earlier versions too) into a schema.\n *\n * Note: This does not support OpenAPI 3.1's header format.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#header-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.3.md#header-object}\n * @param response Response object to build a JSON Schema object for its headers for.\n * @param schemaOptions Optional options to pass to toJSONSchema (e.g. for ref resolution).\n */\nfunction buildHeadersSchema(response: ResponseObject, schemaOptions: toJSONSchemaOptions) {\n const headersSchema: SchemaObject = {\n type: 'object',\n properties: {},\n };\n\n const api = schemaOptions.definition;\n const seenRefs = schemaOptions.seenRefs ?? new Set<string>();\n\n if (response.headers) {\n Object.keys(response.headers).forEach(key => {\n let headerEntry = response.headers?.[key];\n if (!headerEntry) return;\n if (isRef(headerEntry)) {\n headerEntry = dereferenceRef(headerEntry, api, seenRefs);\n if (!headerEntry || isRef(headerEntry)) return;\n }\n\n if (headerEntry.schema) {\n const header: HeaderObject = headerEntry;\n\n let headerSchema = header.schema;\n if (!headerSchema) return;\n if (isRef(headerSchema)) {\n headerSchema = dereferenceRef(headerSchema, api, seenRefs);\n if (!headerSchema || isRef(headerSchema)) return;\n }\n\n // TODO: Response headers are essentially parameters in OAS\n // This means they can have content instead of schema.\n // We should probably support that in the future\n headersSchema.properties![key] = toJSONSchema(cloneObject(headerSchema), {\n addEnumsToDescriptions: true,\n ...schemaOptions,\n });\n\n if (header.description) {\n headersSchema.properties![key].description = header.description;\n }\n }\n });\n }\n\n const headersWrapper: {\n description?: string;\n label: string;\n schema: SchemaObject;\n type: string;\n } = {\n schema: headersSchema,\n type: 'object',\n label: 'Headers',\n };\n\n if (response.description && headersWrapper.schema) {\n headersWrapper.description = response.description;\n }\n\n return headersWrapper;\n}\n\n/**\n * Extract all the response schemas, matching the format of `get-parameters-as-json-schema`.\n *\n * This automatically resolves `$ref` pointers on the fly and attaches used schemas as components\n * within the generated JSON Schema object.\n *\n * @param operation Operation to construct a response JSON Schema for.\n * @param api The OpenAPI definition that this operation originates.\n * @param statusCode The response status code to generate a schema for.\n * @param opts Options for schema generation.\n * @param opts.contentType Optional content-type to use. If specified and the response doesn't have\n * this content-type, the function will return null.\n */\nexport function getResponseAsJSONSchema(\n operation: Operation,\n api: OASDocument,\n statusCode: number | string,\n opts?: {\n includeDiscriminatorMappingRefs?: boolean;\n /**\n * Optional content-type to use. If specified and the response doesn't have this content-type,\n * the function will return null.\n */\n contentType?: string;\n },\n): ResponseSchemaObject[] | null {\n const response = operation.getResponseByStatusCode(statusCode);\n const jsonSchema: ResponseSchemaObject[] = [];\n\n if (!response) {\n return null;\n }\n\n const usedSchemas = new Map<string, SchemaObject>();\n const seenRefs = new Set<string>();\n const refsByGroup = new Map<'body' | 'headers', Set<string>>();\n\n function refLoggerForSchemaGroup(group: 'body' | 'headers'): Set<string> {\n let set = refsByGroup.get(group);\n if (!set) {\n set = new Set();\n refsByGroup.set(group, set);\n }\n return set;\n }\n\n const baseSchemaOptions: toJSONSchemaOptions = {\n addEnumsToDescriptions: true,\n definition: api,\n seenRefs,\n usedSchemas,\n refLogger: ref => refLoggerForSchemaGroup('body').add(ref),\n };\n\n /**\n * @param content An array of `MediaTypeObject`'s to retrieve a preferred schema out of. We\n * prefer JSON media types.\n * @param preferredContentType Optional content-type to use. If specified and not found, returns null.\n */\n function getPreferredSchema(content: Record<string, MediaTypeObject> | undefined, preferredContentType?: string) {\n if (!content) {\n return null;\n }\n\n const contentTypes = Object.keys(content);\n if (!contentTypes.length) {\n return null;\n }\n\n // If a specific content-type is requested, use it if it exists\n if (preferredContentType) {\n if (contentTypes.includes(preferredContentType)) {\n const schema = cloneObject(content[preferredContentType].schema);\n if (!schema) {\n return null;\n }\n\n return toJSONSchema(schema, baseSchemaOptions);\n }\n\n // Requested `content-type` not found, return null\n return null;\n }\n\n // Default behavior: prefer JSON media types\n for (let i = 0; i < contentTypes.length; i++) {\n if (isJSON(contentTypes[i])) {\n const schema = cloneObject(content[contentTypes[i]].schema);\n if (!schema) {\n return {};\n }\n\n return toJSONSchema(schema, baseSchemaOptions);\n }\n }\n\n // We always want to prefer the JSON-compatible content types over everything else but if we\n // haven't found one we should default to the first available.\n const contentType = contentTypes.shift();\n if (!contentType) {\n return {};\n }\n\n const schema = cloneObject(content[contentType].schema);\n if (!schema) {\n return {};\n }\n\n return toJSONSchema(schema, baseSchemaOptions);\n }\n\n const foundSchema = getPreferredSchema(response.content, opts?.contentType);\n\n // If a specific content-type was requested but not found, return null immediately\n if (opts?.contentType && !foundSchema) {\n return null;\n }\n\n if (foundSchema) {\n const schema = structuredClone(foundSchema);\n let schemaType = foundSchema.type;\n\n // If our found schema is a `$ref` pointer then we should try to resolve its type so we can\n // surface that to the root schema as its overall `type`.\n if (schemaType === undefined && isRef(foundSchema) && usedSchemas.size > 0) {\n const resolvedSchema = usedSchemas.get(foundSchema.$ref);\n const resolvedType =\n resolvedSchema && typeof resolvedSchema === 'object' && 'type' in resolvedSchema\n ? resolvedSchema.type\n : undefined;\n\n schemaType = Array.isArray(resolvedType) ? resolvedType[0] : resolvedType;\n }\n\n const schemaWrapper: {\n description?: string;\n label: string;\n schema: SchemaObject;\n type: string[] | string;\n } = {\n // If there's no `type` then the root schema is a circular `$ref` that we likely won't be\n // able to render so instead of generating a JSON Schema with an `undefined` type we should\n // default to `string` so there's at least *something* the end-user can interact with.\n type: schemaType ?? 'string',\n schema: isPrimitive(schema)\n ? schema\n : {\n ...schema,\n $schema: getSchemaVersionString(schema, api),\n },\n label: 'Response body',\n };\n\n if (response.description && schemaWrapper.schema) {\n schemaWrapper.description = response.description;\n }\n\n // Apply discriminator `oneOf` to used schemas.\n applyDiscriminatorOneOfToUsedSchemas(api, usedSchemas, (ref: string) => {\n if (usedSchemas.has(ref)) {\n return usedSchemas.get(ref);\n }\n\n try {\n const resolved = dereferenceRef({ $ref: ref }, api, seenRefs);\n if (isRef(resolved)) return;\n const converted = toJSONSchema(structuredClone(resolved), {\n ...baseSchemaOptions,\n seenRefs,\n });\n\n usedSchemas.set(ref, converted);\n return converted;\n } catch {\n // no-op\n }\n });\n\n // Include only schemas that are still referenced in the output; merge them into the root at their ref paths.\n if (schemaWrapper.schema && usedSchemas.size > 0) {\n // Because the `refLogger` does not see every `$ref` that is present in the generated schema\n // (eg. nested refs inside an `anyOf` branch that was inlined from cache) we need to collect\n // everything else.\n const refsInOutput = collectRefsInSchema(schemaWrapper.schema);\n const refsInGroup = refsByGroup.get('body') ?? new Set<string>();\n const referencedSchemas = filterRequiredRefsToReferenced(new Set([...refsInGroup, ...refsInOutput]), usedSchemas);\n\n if (referencedSchemas.size > 0) {\n mergeReferencedSchemasIntoRoot(schemaWrapper.schema, referencedSchemas);\n }\n }\n\n jsonSchema.push(schemaWrapper);\n }\n\n // 3.0.3 and earlier headers. TODO: New format for 3.1.0\n if (response.headers) {\n const headersWrapper = buildHeadersSchema(response, {\n ...baseSchemaOptions,\n refLogger: ref => refLoggerForSchemaGroup('headers').add(ref),\n });\n\n if (headersWrapper.schema && usedSchemas.size > 0) {\n const refsInGroup = refsByGroup.get('headers') ?? new Set();\n const refsInOutput = collectRefsInSchema(headersWrapper.schema);\n const referencedSchemas = filterRequiredRefsToReferenced(new Set([...refsInGroup, ...refsInOutput]), usedSchemas);\n\n if (referencedSchemas.size > 0) {\n mergeReferencedSchemasIntoRoot(headersWrapper.schema, referencedSchemas);\n }\n }\n\n jsonSchema.push(headersWrapper);\n }\n\n return jsonSchema.length ? jsonSchema : null;\n}\n"]}
@@ -3,7 +3,7 @@
3
3
  var _chunkCOHEPMUPcjs = require('./chunk-COHEPMUP.cjs');
4
4
 
5
5
 
6
- var _chunkQRWBDGLRcjs = require('./chunk-QRWBDGLR.cjs');
6
+ var _chunkACIEB3SBcjs = require('./chunk-ACIEB3SB.cjs');
7
7
 
8
8
 
9
9
 
@@ -534,7 +534,7 @@ var OpenAPITransformer = (_class2 = class {
534
534
  shouldRetainOperation(selection, key, method, operation) {
535
535
  if (this.mode === "reduce") {
536
536
  if (selection.hasSelections && !selection.matches(key, method)) return false;
537
- if (this.hasOperationIdSelection && !this.operationIdSelection.has(_chunkQRWBDGLRcjs.Operation.getOperationId(key, method, operation))) {
537
+ if (this.hasOperationIdSelection && !this.operationIdSelection.has(_chunkACIEB3SBcjs.Operation.getOperationId(key, method, operation))) {
538
538
  return false;
539
539
  }
540
540
  if (this.hasTagSelection && !(operation.tags || []).some((tag) => this.tagSelection.includes(tag.toLowerCase()))) {
@@ -542,7 +542,7 @@ var OpenAPITransformer = (_class2 = class {
542
542
  }
543
543
  } else {
544
544
  if (selection.hasSelections && selection.matches(key, method)) return false;
545
- if (this.hasOperationIdSelection && this.operationIdSelection.has(_chunkQRWBDGLRcjs.Operation.getOperationId(key, method, operation))) {
545
+ if (this.hasOperationIdSelection && this.operationIdSelection.has(_chunkACIEB3SBcjs.Operation.getOperationId(key, method, operation))) {
546
546
  return false;
547
547
  }
548
548
  if (this.hasTagSelection && (operation.tags || []).some((tag) => this.tagSelection.includes(tag.toLowerCase()))) {
@@ -839,4 +839,4 @@ var OpenAPITransformer = (_class2 = class {
839
839
 
840
840
 
841
841
  exports.OpenAPITransformer = OpenAPITransformer;
842
- //# sourceMappingURL=chunk-5ERUEBRH.cjs.map
842
+ //# sourceMappingURL=chunk-KXY7AR7Z.cjs.map