oas 31.1.2 → 32.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (70) hide show
  1. package/README.md +5 -0
  2. package/dist/analyzer/index.cjs +6 -7
  3. package/dist/analyzer/index.cjs.map +1 -1
  4. package/dist/analyzer/index.js +5 -6
  5. package/dist/analyzer/index.js.map +1 -1
  6. package/dist/{chunk-BRYRBTD7.cjs → chunk-4OCSFLJO.cjs} +537 -385
  7. package/dist/chunk-4OCSFLJO.cjs.map +1 -0
  8. package/dist/{chunk-HGVFNEKW.js → chunk-5245ZLBC.js} +476 -324
  9. package/dist/chunk-5245ZLBC.js.map +1 -0
  10. package/dist/{chunk-B5WP4BJM.cjs → chunk-7RDMAMMI.cjs} +511 -240
  11. package/dist/chunk-7RDMAMMI.cjs.map +1 -0
  12. package/dist/{chunk-LSH3X5NA.js → chunk-DVD6RE2D.js} +85 -48
  13. package/dist/chunk-DVD6RE2D.js.map +1 -0
  14. package/dist/{chunk-5EP6HY2E.js → chunk-HYH37HS2.js} +494 -223
  15. package/dist/chunk-HYH37HS2.js.map +1 -0
  16. package/dist/{chunk-7MARUOFZ.js → chunk-MNOEMVCF.js} +2 -2
  17. package/dist/chunk-MNOEMVCF.js.map +1 -0
  18. package/dist/{chunk-SYZDNSG6.cjs → chunk-WXNEGGLJ.cjs} +104 -67
  19. package/dist/chunk-WXNEGGLJ.cjs.map +1 -0
  20. package/dist/chunk-YPR7YTHM.cjs +24 -0
  21. package/dist/chunk-YPR7YTHM.cjs.map +1 -0
  22. package/dist/extensions.d.cts +3 -1
  23. package/dist/extensions.d.ts +3 -1
  24. package/dist/get-parameters-as-json-schema-BH81ZOnw.d.ts +36 -0
  25. package/dist/get-parameters-as-json-schema-DM1vWIEM.d.cts +36 -0
  26. package/dist/index.cjs +5 -6
  27. package/dist/index.cjs.map +1 -1
  28. package/dist/index.d.cts +947 -7
  29. package/dist/index.d.ts +946 -8
  30. package/dist/index.js +4 -5
  31. package/dist/operation/index.cjs +4 -5
  32. package/dist/operation/index.cjs.map +1 -1
  33. package/dist/operation/index.d.cts +3 -1
  34. package/dist/operation/index.d.ts +3 -1
  35. package/dist/operation/index.js +3 -4
  36. package/dist/reducer/index.cjs +16 -18
  37. package/dist/reducer/index.cjs.map +1 -1
  38. package/dist/reducer/index.js +4 -6
  39. package/dist/reducer/index.js.map +1 -1
  40. package/dist/types.cjs +2 -2
  41. package/dist/types.d.cts +9 -1
  42. package/dist/types.d.ts +9 -1
  43. package/dist/types.js +1 -1
  44. package/dist/utils.cjs +4 -4
  45. package/dist/utils.cjs.map +1 -1
  46. package/dist/utils.d.cts +17 -3
  47. package/dist/utils.d.ts +17 -3
  48. package/dist/utils.js +5 -5
  49. package/package.json +3 -6
  50. package/dist/chunk-5EP6HY2E.js.map +0 -1
  51. package/dist/chunk-7MARUOFZ.js.map +0 -1
  52. package/dist/chunk-B5WP4BJM.cjs.map +0 -1
  53. package/dist/chunk-BRYRBTD7.cjs.map +0 -1
  54. package/dist/chunk-HGVFNEKW.js.map +0 -1
  55. package/dist/chunk-LSH3X5NA.js.map +0 -1
  56. package/dist/chunk-O3GIPZLC.cjs +0 -9
  57. package/dist/chunk-O3GIPZLC.cjs.map +0 -1
  58. package/dist/chunk-SYZDNSG6.cjs.map +0 -1
  59. package/dist/chunk-VA3NKXX7.js +0 -9
  60. package/dist/chunk-VA3NKXX7.js.map +0 -1
  61. package/dist/chunk-VQBEI5WI.cjs +0 -24
  62. package/dist/chunk-VQBEI5WI.cjs.map +0 -1
  63. package/dist/extensions-9XckV6aO.d.cts +0 -899
  64. package/dist/extensions-gq53-7Ux.d.ts +0 -899
  65. package/dist/operation/lib/get-parameters-as-json-schema.cjs +0 -11
  66. package/dist/operation/lib/get-parameters-as-json-schema.cjs.map +0 -1
  67. package/dist/operation/lib/get-parameters-as-json-schema.d.cts +0 -4
  68. package/dist/operation/lib/get-parameters-as-json-schema.d.ts +0 -4
  69. package/dist/operation/lib/get-parameters-as-json-schema.js +0 -11
  70. package/dist/operation/lib/get-parameters-as-json-schema.js.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/operation/index.ts","../src/lib/build-discriminator-one-of.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/get-response-as-json-schema.ts","../src/operation/lib/operationId.ts"],"sourcesContent":["import type { Extensions } from '../extensions.js';\nimport type {\n HttpMethods,\n JSONSchema,\n KeyedSecuritySchemeObject,\n MediaTypeObject,\n OAS31Document,\n OASDocument,\n OperationObject,\n ParameterObject,\n PathItemObject,\n ResponseObject,\n SchemaObject,\n SecurityRequirementObject,\n SecuritySchemeObject,\n SecurityType,\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 { getParametersAsJSONSchemaOptions, SchemaWrapper } from './lib/get-parameters-as-json-schema.js';\nimport type { RequestBodyExample } from './lib/get-requestbody-examples.js';\nimport type { ResponseSchemaObject } from './lib/get-response-as-json-schema.js';\nimport type { ResponseExample } from './lib/get-response-examples.js';\nimport type { OperationIDGeneratorOptions } from './lib/operationId.js';\n\nimport { $RefParser } from '@apidevtools/json-schema-ref-parser';\n\nimport { buildDiscriminatorOneOf, findDiscriminatorChildren } from '../lib/build-discriminator-one-of.js';\nimport { isPrimitive } from '../lib/helpers.js';\nimport matchesMimeType from '../lib/matches-mimetype.js';\nimport { dereferenceRef, getDereferencingOptions } from '../lib/refs.js';\nimport { isRef } from '../types.js';\nimport { supportedMethods } from '../utils.js';\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 { getParametersAsJSONSchema } from './lib/get-parameters-as-json-schema.js';\nimport { getRequestBodyExamples } from './lib/get-requestbody-examples.js';\nimport { getResponseAsJSONSchema } from './lib/get-response-as-json-schema.js';\nimport { getResponseExamples } from './lib/get-response-examples.js';\nimport { getOperationId, hasOperationId } from './lib/operationId.js';\n\nexport class Operation {\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 /**\n * Internal storage array that the library utilizes to keep track of the times the\n * {@see Operation.dereference} has been called so that if you initiate multiple promises they'll\n * all end up returning the same data set once the initial dereference call completed.\n */\n protected promises: {\n reject: any;\n resolve: any;\n }[];\n\n /**\n * Internal storage array that the library utilizes to keep track of its `dereferencing` state so\n * it doesn't initiate multiple dereferencing processes.\n */\n protected dereferencing: {\n circularRefs: string[];\n complete: boolean;\n processing: boolean;\n };\n\n constructor(api: OASDocument, path: string, method: HttpMethods, operation: OperationObject) {\n this.schema = operation;\n this.api = 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 this.promises = [];\n this.dereferencing = {\n processing: false,\n complete: false,\n circularRefs: [],\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.api.paths?.[this.path];\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.api.paths?.[this.path];\n if (pathItem?.description && typeof pathItem.description === 'string') {\n return pathItem.description;\n }\n\n return undefined;\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.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 | undefined;\n try {\n if (!this.api.components?.securitySchemes?.[key] || isRef(this.api.components.securitySchemes[key])) {\n /** @todo Add support for `ReferenceObject` */\n return false;\n }\n\n // Remove the reference type, because we know this will be dereferenced\n security = this.api.components.securitySchemes[key];\n } catch {\n return false;\n }\n\n if (!security) return false;\n\n let type: SecurityType | null = null;\n\n if (security.type === 'http') {\n if (security.scheme === 'basic') type = 'Basic';\n else if (security.scheme === '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 if (isRef(p)) {\n /** @todo Add support for `ReferenceObject` */\n return undefined;\n }\n\n if (p.in && p.in === 'header') return p.name;\n return undefined;\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 const response = this.schema.responses?.[r];\n if (!response || isRef(response)) {\n /** @todo Add support for `ReferenceObject` */\n return [];\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 const requestBody = this.schema.requestBody;\n\n /** @todo Add support for `ReferenceObject` */\n if (requestBody && !isRef(requestBody) && 'content' in requestBody && Object.keys(requestBody.content)) {\n this.headers.request.push('Content-Type');\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 if (\n Object.keys(this.schema.responses).some(r => {\n const response = this.schema.responses?.[r];\n if (!response || isRef(response)) {\n /** @todo Add support for `ReferenceObject` */\n return false;\n }\n\n return response?.content && Object.keys(response.content).length > 0;\n })\n ) {\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 * @todo Add support for `ReferenceObject`\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 || []).filter(\n (param): param is ParameterObject => param && !isRef(param),\n );\n\n const commonParams = (this.api?.paths?.[this.path]?.parameters || []).filter(\n (param): param is ParameterObject => param && !isRef(param),\n );\n\n if (commonParams.length) {\n parameters = parameters.concat(dedupeCommonParameters(parameters, commonParams) || []);\n }\n\n return parameters;\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 */\n getParametersAsJSONSchema(opts: getParametersAsJSONSchemaOptions = {}): SchemaWrapper[] | null {\n return getParametersAsJSONSchema(this, this.api, {\n includeDiscriminatorMappingRefs: true,\n transformer: (s: SchemaObject) => s,\n ...opts,\n });\n }\n\n /**\n * Get a single response for this status code, formatted as JSON schema.\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 /**\n * With a transformer you can transform any data within a given schema, like say if you want\n * to rewrite a potentially unsafe `title` that might be eventually used as a JS variable\n * name, just make sure to return your transformed schema.\n */\n transformer?: (schema: SchemaObject) => SchemaObject;\n } = {},\n ): ResponseSchemaObject[] | null {\n return getResponseAsJSONSchema(this, this.api, statusCode, {\n includeDiscriminatorMappingRefs: true,\n transformer: (s: SchemaObject) => s,\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 return this.schema.responses ? Object.keys(this.schema.responses) : [];\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 * 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.schema.requestBody;\n if (!requestBody || isRef(requestBody)) {\n /** @todo Add support for `ReferenceObject` */\n return [];\n }\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.schema.requestBody;\n if (!requestBody || isRef(requestBody)) {\n /** @todo Add support for `ReferenceObject` */\n return false;\n }\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. When this return\n * comes back it's in the form of an array with the first key being the selected media type,\n * followed by the media type object in question.\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(mediaType?: string): MediaTypeObject | false | [string, MediaTypeObject, ...string[]] {\n if (!this.hasRequestBody()) {\n return false;\n }\n\n const requestBody = this.schema.requestBody;\n if (!requestBody || isRef(requestBody)) {\n /** @todo Add support for `ReferenceObject` */\n return false;\n }\n\n if (mediaType) {\n if (!(mediaType in requestBody.content)) {\n return false;\n }\n\n return requestBody.content[mediaType];\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 availableMediaType,\n requestBody.content[availableMediaType],\n ...(requestBody.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);\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 const response = this.schema.responses[statusCode];\n if (!response || isRef(response)) {\n /** @todo Add support for `ReferenceObject` */\n return false;\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);\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 // The usage of `as` in the below is to remove the possibility of a ref type, since we've\n // dereferenced.\n const callbackObj = this.schema.callbacks[identifier];\n if (!callbackObj || isRef(callbackObj)) {\n /** @todo Add support for `ReferenceObject` */\n return false;\n }\n\n const callback = callbackObj[expression];\n if (!callback || isRef(callback) || !callback[method]) {\n /** @todo Add support for `ReferenceObject` */\n return false;\n }\n\n return new Callback(this.api, expression, method, callback[method], 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 const cb = this.schema.callbacks?.[callback];\n if (!cb || isRef(cb)) {\n /** @todo Add support for `ReferenceObject` */\n return;\n }\n\n Object.keys(cb).forEach(expression => {\n const exp = cb[expression];\n if (!exp || isRef(exp)) {\n /** @todo Add support for `ReferenceObject` */\n return;\n }\n\n Object.keys(exp).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);\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 /**\n * Dereference the current operation schema so it can be parsed free of worries of `$ref` schemas\n * and circular structures.\n *\n */\n async dereference(opts?: {\n /**\n * A callback method can be supplied to be called when dereferencing is complete. Used for\n * debugging that the multi-promise handling within this method works.\n *\n * @private\n */\n cb?: () => void;\n }): Promise<(typeof this.promises)[] | boolean> {\n if (this.dereferencing.complete) {\n return Promise.resolve(true);\n }\n\n if (this.dereferencing.processing) {\n return new Promise((resolve, reject) => {\n this.promises.push({ resolve, reject });\n });\n }\n\n this.dereferencing.processing = true;\n\n /**\n * Find `discriminator` schemas and their children before dereferencing (`allOf` `$ref` pointers\n * are resolved during dereferencing). For schemas with a `discriminator` using `allOf`\n * inheritance we build a `oneOf` array from the discovered child schemas so consumers can see\n * the full set of polymorphic options.\n *\n * @see {@link https://spec.openapis.org/oas/v3.0.0.html#fixed-fields-20}\n */\n const { children: discriminatorChildrenMap, inverted: discriminatorChildrenMapInverted } =\n findDiscriminatorChildren(this.api);\n\n const { api, schema, promises } = this;\n\n // Because referencing will eliminate any lineage back to the original `$ref`, information that\n // we might need at some point, we should run through all available component schemas and denote\n // what their name is so that when dereferencing happens below those names will be preserved.\n //\n // Note: this mutates `this.api.components.schemas` in-place. Ideally we'd clone `components`\n // to avoid the side effect but `json-schema-ref-parser` relies on object identity for reference\n // resolution, so cloning breaks $ref handling. The mutation is idempotent (same key/value each\n // time) so it's safe in practice.\n if (api?.components?.schemas && typeof api.components.schemas === 'object') {\n Object.keys(api.components.schemas).forEach(schemaName => {\n // As of OpenAPI 3.1 component schemas can be primitives or arrays. If this happens then we\n // shouldn't try to add `title` or `x-readme-ref-name` properties because we can't. We'll\n // have some data loss on these schemas but as they aren't objects they likely won't be used\n // in ways that would require needing a `title` or `x-readme-ref-name` anyways.\n if (\n isPrimitive(api.components?.schemas?.[schemaName]) ||\n Array.isArray(api.components?.schemas?.[schemaName]) ||\n api.components?.schemas?.[schemaName] === null\n ) {\n return;\n }\n\n (api.components?.schemas?.[schemaName] as SchemaObject)['x-readme-ref-name'] = schemaName;\n });\n }\n\n const circularRefs: Set<string> = new Set();\n const dereferencingOptions = getDereferencingOptions(circularRefs);\n\n const parser = new $RefParser();\n return parser\n .dereference(\n '#/__INTERNAL__',\n {\n // Because `json-schema-ref-parser` will dereference this entire object as we only want\n // to dereference this operation schema we're attaching it to the `__INTERNAL__` key, and\n // later using that to extract our dereferenced schema. If we didn't do this then we run\n // the risk of any keyword in `schema` being overriden by `paths` and `components`.\n //\n // This solution isn't the best and still requires us to send `json-schema-ref-parser`\n // basically the entire API defintiion but because we don't know what `$ref` pointers in\n // `schema` reference, we can't know which parts of full API definition we could safely\n // exclude from this process.\n __INTERNAL__: structuredClone(schema),\n paths: api.paths ?? undefined,\n components: api.components ?? undefined,\n },\n {\n ...dereferencingOptions,\n dereference: {\n ...dereferencingOptions.dereference,\n\n /**\n * Because we only want to dereference our `__INTERNAL__` schema, not the **entire**\n * API definition if the parser attemps to dereference anything but that then we\n * should bail out of that crawler.\n *\n * @fixme this may cause issues where a path references a schema within itself to be ignored.\n */\n excludedPathMatcher: (path: string) => {\n if (path === '#/paths' || path.startsWith('#/paths/')) {\n return true;\n }\n\n // In order to support not dereferencing the entire schema but also maintaining the\n // reconstruction of discriminator `oneOf` arrays we need to ensure that the\n // discriminators `$ref` pointers that we're aware of are fully dereferenced. If we\n // don't do this then because they aren't explicitly used in the schemas they will be\n // fully dereferenced into their containers before we're able to toss them into a\n // `oneOf`.\n if (discriminatorChildrenMap.size > 0 || discriminatorChildrenMapInverted.size > 0) {\n // As we only care about component schemas for this discriminator construction\n // functionality we shouldn't expressly dereference anything else in `#/components`.\n if (\n path.startsWith('#/components/') &&\n path !== '#/components/schemas' &&\n !path.startsWith('#/components/schemas/')\n ) {\n return true;\n }\n\n if (path.startsWith('#/components/schemas/')) {\n const schemaName = path.split('/').pop();\n\n // If this schema we're looking at has a discriminator children mapping, or is the\n // child of one, then we should ensure it's fully dereferenced.\n if (\n schemaName &&\n (discriminatorChildrenMap.has(schemaName) || discriminatorChildrenMapInverted.has(schemaName))\n ) {\n if (\n path === `#/components/schemas/${schemaName}` ||\n path.startsWith(`#/components/schemas/${schemaName}/`)\n ) {\n return false;\n }\n\n // Because this component schema isn't part of a discriminator we will be using\n // later we can exclude it from dereferencing.\n return true;\n }\n }\n\n return false;\n }\n\n // If the path we're looking at isn't part of our discriminator children mappings\n // then we should exclude it from dereferencing.\n return path === '#/components' || path.startsWith('#/components/');\n },\n },\n },\n )\n .then(res => {\n const dereferenced = res as JSONSchema & {\n __INTERNAL__: OperationObject;\n components?: OASDocument['components'];\n };\n\n // Construct `oneOf` arrays for `discriminator` schemas using their dereferenced child\n // schemas. This must be done **after** dereferencing so we have the fully resolved child\n // schemas.\n if (dereferenced?.components?.schemas && discriminatorChildrenMap.size > 0) {\n buildDiscriminatorOneOf({ components: dereferenced.components }, discriminatorChildrenMap);\n }\n\n // Refresh the current schema with the newly dereferenced one.\n this.schema = dereferenced.__INTERNAL__;\n\n this.promises = promises;\n this.dereferencing = {\n processing: false,\n complete: true,\n // We need to convert our `Set` to an array in order to match the typings.\n circularRefs: [...circularRefs],\n };\n\n // Used for debugging that dereferencing promise awaiting works.\n if (opts?.cb) {\n opts.cb();\n }\n })\n .then(() => {\n return this.promises.map(deferred => deferred.resolve());\n })\n .catch(err => {\n this.dereferencing.processing = false;\n this.promises.map(deferred => deferred.reject(err));\n throw err;\n });\n }\n\n /**\n * Retrieve any circular `$ref` pointers that maybe present within operation schema.\n *\n * This method requires that you first dereference the definition.\n *\n * @see Operation.dereference\n */\n getCircularReferences(): string[] {\n if (!this.dereferencing.complete) {\n throw new Error('.dereference() must be called first in order for this method to obtain circular references.');\n }\n\n return this.dereferencing.circularRefs;\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: OASDocument,\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 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 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 getParameters(): ParameterObject[] {\n let parameters = (this.schema?.parameters || []) as ParameterObject[];\n const commonParams = (this.parentSchema.parameters || []) as ParameterObject[];\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 getSummary(): string | undefined {\n if (this.schema?.summary && typeof this.schema.summary === 'string') {\n return this.schema.summary;\n }\n\n const webhookPath = this.api.webhooks?.[this.path];\n if (webhookPath && !isRef(webhookPath)) {\n /** @todo Add support for `ReferenceObject` */\n if (webhookPath?.summary && typeof webhookPath.summary === 'string') {\n return webhookPath.summary;\n }\n }\n\n return undefined;\n }\n\n getDescription(): string | undefined {\n if (this.schema?.description && typeof this.schema.description === 'string') {\n return this.schema.description;\n }\n\n const webhookPath = this.api.webhooks?.[this.path];\n if (webhookPath && !isRef(webhookPath)) {\n /** @todo Add support for `ReferenceObject` */\n if (webhookPath?.description && typeof webhookPath.description === 'string') {\n return webhookPath.description;\n }\n }\n\n return undefined;\n }\n}\n","import type { DiscriminatorChildrenMap, DiscriminatorObject, OASDocument, SchemaObject } from '../types.js';\n\nimport { isRef } from '../types.js';\nimport { cloneObject } from './clone-object.js';\n\n/**\n * Determines if a schema has a discriminator but is missing oneOf/anyOf polymorphism.\n *\n * @param schema Schema to check.\n * @returns If the schema has a discriminator but no oneOf/anyOf.\n */\nfunction hasDiscriminatorWithoutPolymorphism(schema: SchemaObject): boolean {\n if (!schema || typeof schema !== 'object') return false;\n if (!('discriminator' in schema)) return false;\n if ('oneOf' in schema || 'anyOf' in schema) return false;\n return true;\n}\n\n/**\n * Checks if a schema's allOf contains a $ref to a specific schema name.\n *\n * @param schema Schema to check.\n * @param targetSchemaName The schema name to look for (e.g., 'Pet').\n * @returns If the schema's allOf contains a $ref to the target schema.\n */\nfunction allOfReferencesSchema(schema: SchemaObject, targetSchemaName: string): boolean {\n if (!schema || typeof schema !== 'object') return false;\n if (!('allOf' in schema) || !Array.isArray(schema.allOf)) return false;\n\n return schema.allOf.some(item => {\n if (isRef(item)) {\n // Check if the $ref points to the target schema\n // Format: #/components/schemas/SchemaName\n const refParts = item.$ref.split('/');\n const refSchemaName = refParts[refParts.length - 1];\n return refSchemaName === targetSchemaName;\n }\n return false;\n });\n}\n\n/**\n * Phase 1: Before dereferencing, identify discriminator schemas and their children via allOf\n * inheritance. Returns a mapping that can be used after dereferencing.\n *\n * We don't add oneOf here because that would create circular references\n * (Pet → Cat → Pet via allOf) which would break dereferencing.\n *\n * @param api The OpenAPI definition to process (before dereferencing).\n * @returns A map of discriminator schema names to their child schema names.\n */\nexport function findDiscriminatorChildren(api: Pick<OASDocument, 'components'>): {\n children: DiscriminatorChildrenMap;\n inverted: DiscriminatorChildrenMap;\n} {\n const childrenMap: DiscriminatorChildrenMap = new Map();\n const invertedChildrenMap: DiscriminatorChildrenMap = new Map();\n\n if (!api?.components?.schemas || typeof api.components.schemas !== 'object') {\n return { children: childrenMap, inverted: invertedChildrenMap };\n }\n\n const schemas = api.components.schemas as Record<string, SchemaObject>;\n const schemaNames = Object.keys(schemas);\n\n // Find all schemas with discriminator but no oneOf/anyOf\n const discriminatorSchemas: string[] = schemaNames.filter(name => {\n return hasDiscriminatorWithoutPolymorphism(schemas[name]);\n });\n\n // For each discriminator schema, record child schema names\n for (const baseName of discriminatorSchemas) {\n const baseSchema = schemas[baseName] as SchemaObject & { discriminator: DiscriminatorObject };\n const discriminator = baseSchema.discriminator;\n\n let childSchemaNames: string[] | undefined;\n\n // If there's already a mapping defined, use that\n if (discriminator.mapping && typeof discriminator.mapping === 'object') {\n const mappingRefs = Object.values(discriminator.mapping);\n if (mappingRefs.length > 0) {\n // Extract schema names from refs like \"#/components/schemas/Cat\"\n childSchemaNames = mappingRefs.map(ref => {\n const parts = ref.split('/');\n return parts[parts.length - 1];\n });\n }\n }\n\n // Otherwise, scan for schemas that extend this base via allOf\n if (!childSchemaNames || childSchemaNames.length === 0) {\n childSchemaNames = schemaNames.filter(name => {\n if (name === baseName) return false;\n return allOfReferencesSchema(schemas[name], baseName);\n });\n }\n\n // Store child schema names in the map\n if (childSchemaNames.length > 0) {\n childrenMap.set(baseName, childSchemaNames);\n }\n }\n\n // Invert our map so we can do reverse lookups.\n for (const [key, values] of childrenMap) {\n for (const value of values) {\n if (invertedChildrenMap.has(value)) {\n invertedChildrenMap.get(value)?.push(key);\n } else {\n invertedChildrenMap.set(value, [key]);\n }\n }\n }\n\n return { children: childrenMap, inverted: invertedChildrenMap };\n}\n\n/**\n * Phase 2: After dereferencing, build oneOf arrays for discriminator schemas using the\n * dereferenced child schemas.\n *\n * @param api The OpenAPI definition to process (after dereferencing).\n * @param childrenMap The mapping of discriminator schemas to their children (from findDiscriminatorChildren).\n */\nexport function buildDiscriminatorOneOf(\n api: Pick<OASDocument, 'components'>,\n childrenMap: DiscriminatorChildrenMap,\n): void {\n // Early exit if there are no component schemas or no mappings\n if (!api?.components?.schemas || typeof api.components.schemas !== 'object') {\n return;\n } else if (childrenMap.size === 0) {\n return;\n }\n\n // Build oneOf for each discriminator schema\n for (const [schemaName, childNames] of childrenMap) {\n const schema = api.components.schemas[schemaName];\n if (!schema) continue;\n\n // Build oneOf from dereferenced child schemas\n const oneOf: SchemaObject[] = [];\n for (const childName of childNames) {\n if (api.components.schemas[childName]) {\n // Clone the schema to avoid circular reference issues\n oneOf.push(cloneObject(api.components.schemas[childName]));\n }\n }\n\n if (oneOf.length > 0) {\n (schema as Record<string, unknown>).oneOf = oneOf;\n }\n }\n\n // Post-process: Strip oneOf from discriminator schemas embedded in child allOf structures.\n // When Cat extends Pet via allOf, and Pet has a discriminator with oneOf, the embedded Pet\n // inside Cat's allOf should NOT have oneOf (would create circular Cat.allOf[0].oneOf[0] ≈ Cat).\n // We only strip from allOf entries to preserve oneOf in direct references (e.g., items: $ref Pet).\n for (const [parentSchemaName, childNames] of childrenMap) {\n for (const childName of childNames) {\n const childSchema = api.components.schemas[childName];\n if (!childSchema || !('allOf' in childSchema) || !Array.isArray(childSchema.allOf)) {\n continue;\n }\n\n for (let i = 0; i < childSchema.allOf.length; i++) {\n const item = childSchema.allOf[i];\n if (\n item &&\n typeof item === 'object' &&\n 'x-readme-ref-name' in item &&\n (item as SchemaObject)['x-readme-ref-name'] === parentSchemaName &&\n 'oneOf' in item\n ) {\n // Clone the allOf entry and strip oneOf from the clone to avoid mutating the shared reference.\n // This ensures Pet in components.schemas keeps its oneOf while embedded Pet in Cat's allOf doesn't.\n const clonedItem = cloneObject(item);\n delete (clonedItem as Record<string, unknown>).oneOf;\n childSchema.allOf[i] = clonedItem;\n }\n }\n }\n }\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 { SchemaObject } from '../types.js';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\nimport memoize from 'memoizee';\n\nimport { deeplyStripKey, 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 */\nfunction sampleFromSchema(\n schema: SchemaObject,\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): Record<string, unknown> | unknown[] | boolean | number | string | null | undefined {\n const objectifySchema = objectify(schema);\n let { type } = objectifySchema;\n\n const hasPolymorphism = usesPolymorphism(objectifySchema);\n if (hasPolymorphism === 'allOf') {\n try {\n return sampleFromSchema(\n mergeJSONSchemaAllOf(objectifySchema, {\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 opts,\n );\n } catch {\n return undefined;\n }\n } else if (hasPolymorphism) {\n const samples = (objectifySchema[hasPolymorphism] as SchemaObject[]).map(s => {\n return sampleFromSchema(s, opts);\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 const { example, additionalProperties, properties, items } = objectifySchema;\n const { includeReadOnly, includeWriteOnly } = opts;\n\n if (example !== undefined) {\n return deeplyStripKey(example, '$$ref', (val: unknown): val is string => {\n // do a couple of quick sanity tests to ensure the value\n // looks like a $$ref that swagger-client generates.\n return typeof val === 'string' && val.indexOf('#') > -1;\n });\n }\n\n if (!type) {\n if (properties || additionalProperties) {\n type = 'object';\n } else if (items) {\n type = 'array';\n } else {\n return undefined;\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);\n }\n\n if (additionalProperties === true) {\n obj.additionalProp = {};\n } else if (additionalProperties) {\n const additionalProps = objectify(additionalProperties);\n const additionalPropVal = sampleFromSchema(additionalProps, opts);\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) => sampleFromSchema(i, opts));\n }\n\n if (Array.isArray(items.oneOf)) {\n return items.oneOf.map((i: SchemaObject) => sampleFromSchema(i, opts));\n }\n\n return [sampleFromSchema(items, opts)];\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 undefined;\n }\n\n return primitive(schema);\n}\n\nconst memo: typeof sampleFromSchema = memoize(sampleFromSchema);\n\n// biome-ignore lint/style/noDefaultExport: This is safe for now.\nexport default memo;\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// biome-ignore lint/complexity/noBannedTypes: This is part of a type guard.\nexport function isFunc(thing: unknown): thing is Function {\n return typeof thing === 'function';\n}\n\n// Deeply strips a specific key from an object.\n//\n// `predicate` can be used to discriminate the stripping further,\n// by preserving the key's place in the object based on its value.\n// @todo make this have a better type than `any`\nexport function deeplyStripKey(\n input: unknown,\n keyToStrip: string,\n predicate = (obj: unknown, key?: string): boolean => true,\n): SchemaObject | any {\n if (typeof input !== 'object' || Array.isArray(input) || input === null || !keyToStrip) {\n return input;\n }\n\n const obj = { ...input } as Record<string, SchemaObject>;\n\n Object.keys(obj).forEach(k => {\n if (k === keyToStrip && predicate(obj[k], k)) {\n delete obj[k];\n return;\n }\n\n obj[k] = deeplyStripKey(obj[k], keyToStrip, predicate);\n });\n\n return obj;\n}\n","import type { MediaTypeObject } from '../../types.js';\n\nimport matchesMimeType from '../../lib/matches-mimetype.js';\nimport sampleFromSchema from '../../samples/index.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 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 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 ('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 // If we have a $ref here then it's a circular reference and we should ignore it.\n if (example.value !== null && typeof example.value === 'object' && '$ref' in example.value) {\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(JSON.parse(JSON.stringify(mediaTypeObject.schema)), opts),\n },\n ];\n }\n }\n\n return [];\n}\n","import type { OperationObject } from '../../types.js';\nimport type { MediaTypeExample } from './get-mediatype-examples.js';\n\nimport { isRef } from '../../types.js';\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): ResponseExample[] {\n return Object.keys(operation.responses || {})\n .map(status => {\n const response = operation.responses?.[status];\n let onlyHeaders = false;\n\n // If we have a $ref here that means that this was a circular ref so we should ignore it.\n if (!response || isRef(response)) {\n /** @todo add support for `ReferenceObject` */\n 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, {\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 { OperationObject } from '../../types.js';\nimport type { ResponseExample } from './get-response-examples.js';\n\nimport { isRef } from '../../types.js';\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): CallbackExample[] {\n if (!operation.callbacks) {\n return [];\n }\n\n const examples = Object.keys(operation.callbacks).map(identifier => {\n const callback = operation.callbacks?.[identifier];\n if (!callback || isRef(callback)) {\n /** @todo add support for `ReferenceObject */\n return [];\n }\n\n const items = Object.keys(callback).map(expression => {\n return Object.keys(callback[expression]).map(method => {\n const pathItem = callback[expression] as Record<string, OperationObject>;\n const example = getResponseExamples(pathItem[method]);\n if (example.length === 0) 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 { 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 // biome-ignore lint/style/noNonNullAssertion: `customCodeSamples` is guaranteed to be an array here.\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 if (isRef(paramExample)) {\n /** @todo add support for `ReferenceObject` */\n return;\n }\n\n groups[exampleKey] = {\n ...groups[exampleKey],\n name: groups[exampleKey]?.name || paramExample.summary || exampleKey,\n request: {\n ...groups[exampleKey]?.request,\n [param.in]: {\n ...groups[exampleKey]?.request?.[param.in],\n [param.name]: paramExample.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 { OperationObject } from '../../types.js';\nimport type { MediaTypeExample } from './get-mediatype-examples.js';\n\nimport { isRef } from '../../types.js';\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): RequestBodyExample[] {\n const requestBody = operation.requestBody;\n if (!requestBody || isRef(requestBody) || !requestBody.content) {\n /** @todo add support for `ReferenceObject` */\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, {\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 {\n ComponentsObject,\n HeaderObject,\n MediaTypeObject,\n OASDocument,\n ResponseObject,\n SchemaObject,\n} from '../../types.js';\nimport type { Operation } from '../index.js';\n\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 { 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 */\nfunction buildHeadersSchema(\n response: ResponseObject,\n opts?: {\n /**\n * With a transformer you can transform any data within a given schema, like say if you want to\n * rewrite a potentially unsafe `title` that might be eventually used as a JS variable name,\n * just make sure to return your transformed schema.\n */\n transformer?: (schema: SchemaObject) => SchemaObject;\n },\n) {\n const headersSchema: SchemaObject = {\n type: 'object',\n properties: {},\n };\n\n if (response.headers) {\n Object.keys(response.headers).forEach(key => {\n if (!response.headers?.[key] || isRef(response.headers?.[key])) {\n /** @todo add support for `ReferenceObject` */\n return;\n }\n\n if (response.headers[key].schema) {\n const header: HeaderObject = response.headers[key];\n if (!header.schema || isRef(header.schema)) {\n /** @todo add support for `ReferenceObject` */\n 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 // biome-ignore lint/style/noNonNullAssertion: This is guaranteed.\n headersSchema.properties![key] = toJSONSchema(header.schema, {\n addEnumsToDescriptions: true,\n transformer: opts?.transformer,\n });\n\n if (header.description) {\n // biome-ignore lint/style/noNonNullAssertion: This is guaranteed.\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 * Note: This expects a dereferenced schema.\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 * With a transformer you can transform any data within a given schema, like say if you want\n * to rewrite a potentially unsafe `title` that might be eventually used as a JS variable\n * name, just make sure to return your transformed schema.\n */\n transformer?: (schema: SchemaObject) => SchemaObject;\n },\n): ResponseSchemaObject[] | null {\n const response = operation.getResponseByStatusCode(statusCode);\n const jsonSchema: ResponseSchemaObject[] = [];\n\n if (!response) {\n return null;\n }\n\n let hasCircularRefs = false;\n let hasDiscriminatorMappingRefs = false;\n\n function refLogger(ref: string, type: 'discriminator' | 'ref') {\n if (type === 'ref') {\n hasCircularRefs = true;\n } else {\n hasDiscriminatorMappingRefs = true;\n }\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 /** @todo add support for `ReferenceObject` */\n return toJSONSchema(schema, {\n addEnumsToDescriptions: true,\n refLogger,\n transformer: opts?.transformer,\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 /** @todo add support for `ReferenceObject` */\n return toJSONSchema(schema, {\n addEnumsToDescriptions: true,\n refLogger,\n transformer: opts?.transformer,\n });\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 /** @todo add support for `ReferenceObject` */\n return toJSONSchema(schema, {\n addEnumsToDescriptions: true,\n refLogger,\n transformer: opts?.transformer,\n });\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 = cloneObject(foundSchema);\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: foundSchema.type || '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 as ResponseObject).description && schemaWrapper.schema) {\n schemaWrapper.description = (response as ResponseObject).description;\n }\n\n /**\n * Since this library assumes that the schema has already been dereferenced, adding every\n * component here that **isn't** circular adds a ton of bloat so it'd be cool if `components`\n * was just the remaining `$ref` pointers that are still being referenced.\n *\n * @todo\n */\n if (api.components && schemaWrapper.schema) {\n // We should only include components if we've got circular refs or we have discriminator\n // mapping refs (we want to include them).\n if (hasCircularRefs || (hasDiscriminatorMappingRefs && opts?.includeDiscriminatorMappingRefs)) {\n ((schemaWrapper.schema as SchemaObject).components as ComponentsObject) = cloneObject(\n api.components,\n ) as ComponentsObject;\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 as ResponseObject).headers) {\n jsonSchema.push(buildHeadersSchema(response as ResponseObject, opts));\n }\n\n return jsonSchema.length ? jsonSchema : null;\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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;AA0BA,SAAS,kBAAkB;;;ACf3B,SAAS,oCAAoC,QAA+B;AAC1E,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,MAAI,EAAE,mBAAmB,QAAS,QAAO;AACzC,MAAI,WAAW,UAAU,WAAW,OAAQ,QAAO;AACnD,SAAO;AACT;AASA,SAAS,sBAAsB,QAAsB,kBAAmC;AACtF,MAAI,CAAC,UAAU,OAAO,WAAW,SAAU,QAAO;AAClD,MAAI,EAAE,WAAW,WAAW,CAAC,MAAM,QAAQ,OAAO,KAAK,EAAG,QAAO;AAEjE,SAAO,OAAO,MAAM,KAAK,UAAQ;AAC/B,QAAI,MAAM,IAAI,GAAG;AAGf,YAAM,WAAW,KAAK,KAAK,MAAM,GAAG;AACpC,YAAM,gBAAgB,SAAS,SAAS,SAAS,CAAC;AAClD,aAAO,kBAAkB;AAAA,IAC3B;AACA,WAAO;AAAA,EACT,CAAC;AACH;AAYO,SAAS,0BAA0B,KAGxC;AACA,QAAM,cAAwC,oBAAI,IAAI;AACtD,QAAM,sBAAgD,oBAAI,IAAI;AAE9D,MAAI,CAAC,KAAK,YAAY,WAAW,OAAO,IAA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AAA,MACrB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AAAA,EAEA,iBAAqC;AACnC,QAAI,KAAK,QAAQ,eAAe,OAAO,KAAK,OAAO,gBAAgB,UAAU;AAC3E,aAAO,KAAK,OAAO;AAAA,IACrB;AAEA,UAAM,cAAc,KAAK,IAAI,WAAW,KAAK,IAAI;AACjD,QAAI,eAAe,CAAC,MAAM,WAAW,GAAG;AAEtC,UAAI,aAAa,eAAe,OAAO,YAAY,gBAAgB,UAAU;AAC3E,eAAO,YAAY;AAAA,MACrB;AAAA,IACF;AAEA,WAAO;AAAA,EACT;AACF;","names":["schema"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/get-auth.ts","../src/lib/get-user-variable.ts","../src/lib/urls.ts"],"sourcesContent":["import type { OpenAPIV3_1 } from 'openapi-types';\nimport type { Extensions } from './extensions.js';\nimport type { PathMatch, PathMatches } from './lib/urls.js';\nimport type {\n AuthForHAR,\n HttpMethods,\n OASDocument,\n OperationObject,\n SchemaObject,\n ServerObject,\n Servers,\n ServerVariable,\n ServerVariablesObject,\n User,\n} from './types.js';\n\nimport { dereference } from '@readme/openapi-parser';\n\nimport {\n CODE_SAMPLES,\n extensionDefaults,\n getExtension,\n HEADERS,\n hasRootExtension,\n OAUTH_OPTIONS,\n PARAMETER_ORDERING,\n SAMPLES_LANGUAGES,\n validateParameterOrdering,\n} from './extensions.js';\nimport { buildDiscriminatorOneOf, findDiscriminatorChildren } from './lib/build-discriminator-one-of.js';\nimport { getAuth } from './lib/get-auth.js';\nimport getUserVariable from './lib/get-user-variable.js';\nimport { isPrimitive } from './lib/helpers.js';\nimport { dereferenceRef, getDereferencingOptions } from './lib/refs.js';\nimport {\n filterPathMethods,\n findTargetPath,\n generatePathMatches,\n normalizedURL,\n stripTrailingSlash,\n transformURLIntoRegex,\n} from './lib/urls.js';\nimport { Operation, Webhook } from './operation/index.js';\nimport { isOpenAPI31, isRef } from './types.js';\nimport { SERVER_VARIABLE_REGEX, supportedMethods } from './utils.js';\n\n// biome-ignore lint/style/noDefaultExport: This file doesn't have any other exports so this is fine.\nexport default class Oas {\n /**\n * An OpenAPI API Definition.\n */\n api: OASDocument;\n\n /**\n * The current user that we should use when pulling auth tokens from security schemes.\n */\n user: User;\n\n /**\n * Internal storage array that the library utilizes to keep track of the times the\n * {@see Oas.dereference} has been called so that if you initiate multiple promises they'll all\n * end up returning the same data set once the initial dereference call completed.\n */\n protected promises: {\n reject: any;\n resolve: any;\n }[];\n\n /**\n * Internal storage array that the library utilizes to keep track of its `dereferencing` state so\n * it doesn't initiate multiple dereferencing processes.\n */\n protected dereferencing: {\n circularRefs: string[];\n complete: boolean;\n processing: boolean;\n };\n\n /**\n * @param oas An OpenAPI definition.\n * @param user The information about a user that we should use when pulling auth tokens from\n * security schemes.\n */\n constructor(oas: OASDocument | string, user?: User) {\n if (typeof oas === 'string') {\n this.api = (JSON.parse(oas) || {}) as OASDocument;\n } else {\n this.api = oas || ({} as OASDocument);\n }\n\n this.user = user || {};\n\n this.promises = [];\n this.dereferencing = {\n processing: false,\n complete: false,\n circularRefs: [],\n };\n }\n\n /**\n * This will initialize a new instance of the `Oas` class. This method is useful if you're using\n * Typescript and are attempting to supply an untyped JSON object into `Oas` as it will force-type\n * that object to an `OASDocument` for you.\n *\n * @param oas An OpenAPI definition.\n * @param user The information about a user that we should use when pulling auth tokens from\n * security schemes.\n */\n static init(oas: OASDocument | Record<string, unknown>, user?: User): Oas {\n return new Oas(oas as OASDocument, user);\n }\n\n /**\n * Retrieve the OpenAPI version that this API definition is targeted for.\n */\n getVersion(): string {\n if (this.api.openapi) {\n return this.api.openapi;\n }\n\n throw new Error('Unable to recognize what specification version this API definition conforms to.');\n }\n\n /**\n * Retrieve the current OpenAPI API Definition.\n *\n */\n getDefinition(): OASDocument {\n return this.api;\n }\n\n url(selected = 0, variables?: ServerVariable): string {\n const url = normalizedURL(this.api, selected);\n return this.replaceUrl(url, variables || this.defaultVariables(selected)).trim();\n }\n\n variables(selected = 0): ServerVariablesObject {\n return this.api.servers?.[selected]?.variables || {};\n }\n\n defaultVariables(selected = 0): ServerVariable {\n const variables = this.variables(selected);\n const defaults: ServerVariable = {};\n\n Object.keys(variables).forEach(key => {\n defaults[key] = getUserVariable(this.user, key) || variables[key].default || '';\n });\n\n return defaults;\n }\n\n splitUrl(selected = 0): (\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 const url = normalizedURL(this.api, selected);\n const variables = this.variables(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 // To ensure unique keys, we're going to create a key\n // with the value concatenated to its index.\n const key = `${value}-${i}`;\n\n if (!isVariable) {\n return {\n type: 'text',\n value,\n key,\n };\n }\n\n const variable = variables?.[value];\n\n return {\n type: 'variable',\n value,\n key,\n description: variable?.description,\n enum: variable?.enum,\n };\n });\n }\n\n /**\n * With a fully composed server URL, run through our list of known OAS servers and return back\n * which server URL was selected along with any contained server variables split out.\n *\n * For example, if you have an OAS server URL of `https://{name}.example.com:{port}/{basePath}`,\n * and pass in `https://buster.example.com:3000/pet` to this function, you'll get back the\n * following:\n *\n * { selected: 0, variables: { name: 'buster', port: 3000, basePath: 'pet' } }\n *\n * Re-supplying this data to `oas.url()` should return the same URL you passed into this method.\n *\n * @param baseUrl A given URL to extract server variables out of.\n */\n splitVariables(baseUrl: string): Servers | false {\n const matchedServer = (this.api.servers || [])\n .map((server, i) => {\n const rgx = transformURLIntoRegex(server.url);\n const found = new RegExp(rgx).exec(baseUrl);\n if (!found) {\n return false;\n }\n\n // While it'd be nice to use named regex groups to extract path parameters from the URL and\n // match them up with the variables that we have present in it, JS unfortunately doesn't\n // support having the groups duplicated. So instead of doing that we need to re-regex the\n // server URL, this time splitting on the path parameters -- this way we'll be able to\n // extract the parameter names and match them up with the matched server that we obtained\n // above.\n const variables: Record<string, number | string> = {};\n Array.from(server.url.matchAll(SERVER_VARIABLE_REGEX)).forEach((variable, y) => {\n variables[variable[1]] = found[y + 1];\n });\n\n return {\n selected: i,\n variables,\n };\n })\n .filter(item => item !== false);\n\n return matchedServer.length ? matchedServer[0] : false;\n }\n\n /**\n * Replace templated variables with supplied data in a given URL.\n *\n * There are a couple ways that this will utilize variable data:\n *\n * - Supplying a `variables` object. If this is supplied, this data will always take priority.\n * This incoming `variables` object can be two formats:\n * `{ variableName: { default: 'value' } }` and `{ variableName: 'value' }`. If the former is\n * present, that will take precedence over the latter.\n * - If the supplied `variables` object is empty or does not match the current template name,\n * we fallback to the data stored in `this.user` and attempt to match against that.\n * See `getUserVariable` for some more information on how this data is pulled from `this.user`.\n *\n * If no variables supplied match up with the template name, the template name will instead be\n * used as the variable data.\n *\n * @param url A URL to swap variables into.\n * @param variables An object containing variables to swap into the URL.\n */\n replaceUrl(url: string, variables: ServerVariable = {}): string {\n // When we're constructing URLs, server URLs with trailing slashes cause problems with doing\n // lookups, so if we have one here on, slice it off.\n return stripTrailingSlash(\n url.replace(SERVER_VARIABLE_REGEX, (original: string, key: string) => {\n if (key in variables) {\n const data = variables[key];\n if (typeof data === 'object') {\n if (!Array.isArray(data) && data !== null && 'default' in data) {\n return String(data.default);\n }\n } else {\n return String(data);\n }\n }\n\n const userVariable = getUserVariable(this.user, key);\n if (userVariable) {\n return String(userVariable);\n }\n\n return original;\n }),\n );\n }\n\n /**\n * Retrieve an Operation of Webhook class instance for a given path and method.\n *\n * @param path Path to lookup and retrieve.\n * @param method HTTP Method to retrieve on the path.\n */\n operation(\n path: string,\n method: HttpMethods,\n opts: {\n /**\n * If you prefer to first look for a webhook with this path and method.\n */\n isWebhook?: boolean;\n } = {},\n ): Operation {\n // If we're unable to locate an operation for this path+method combination within the API\n // definition, we should still set an empty schema on the operation in the `Operation` class\n // because if we don't trying to use any of the accessors on that class are going to fail as\n // `schema` will be `undefined`.\n let operation: OperationObject = {\n parameters: [],\n };\n\n if (opts.isWebhook) {\n if (isOpenAPI31(this.api)) {\n const webhookPath = dereferenceRef(this.api?.webhooks?.[path], this.api);\n if (webhookPath && !isRef(webhookPath)) {\n if (webhookPath?.[method]) {\n operation = webhookPath[method];\n return new Webhook(this.api, path, method, operation);\n }\n }\n }\n }\n\n if (this?.api?.paths?.[path]) {\n const pathItem = dereferenceRef(this.api.paths[path], this.api);\n if (pathItem?.[method]) {\n operation = dereferenceRef(pathItem[method], this.api);\n }\n }\n\n return new Operation(this.api, path, method, operation);\n }\n\n findOperationMatches(url: string): PathMatches | undefined {\n const { origin, hostname } = new URL(url);\n const originRegExp = new RegExp(origin, 'i');\n const { servers, paths } = this.api;\n\n let pathName: string | undefined;\n let targetServer: ServerObject | undefined;\n let matchedServer: ServerObject | undefined;\n\n if (!servers || !servers.length) {\n // If this API definition doesn't have any servers set up let's treat it as if it were\n // https://example.com because that's the default origin we add in `normalizedUrl` under the\n // same circumstances. Without this we won't be able to match paths within what is otherwise\n // a valid OpenAPI definition.\n matchedServer = {\n url: 'https://example.com',\n };\n } else {\n matchedServer = servers.find(s => originRegExp.exec(this.replaceUrl(s.url, s.variables || {})));\n if (!matchedServer) {\n const hostnameRegExp = new RegExp(hostname);\n matchedServer = servers.find(s => hostnameRegExp.exec(this.replaceUrl(s.url, s.variables || {})));\n }\n }\n\n if (matchedServer) {\n // Instead of setting `url` directly against `matchedServer` we need to set it to an\n // intermediary object as directly modifying `matchedServer.url` will in turn update\n // `this.servers[idx].url` which we absolutely do not want to happen.\n targetServer = {\n ...matchedServer,\n url: this.replaceUrl(matchedServer.url, matchedServer.variables || {}),\n };\n\n [, pathName] = url.split(new RegExp(targetServer.url, 'i'));\n }\n\n // If we **still** haven't found a matching server, then the OAS server URL might have server\n // variables and we should loosen it up with regex to try to discover a matching path.\n //\n // For example if an OAS has `https://{region}.node.example.com/v14` set as its server URL, and\n // the `this.user` object has a `region` value of `us`, if we're trying to locate an operation\n // for https://eu.node.example.com/v14/api/esm we won't be able to because normally the users\n // `region` of `us` will be transposed in and we'll be trying to locate `eu.node.example.com`\n // in `us.node.example.com` -- which won't work.\n //\n // So what this does is transform `https://{region}.node.example.com/v14` into\n // `https://([-_a-zA-Z0-9[\\\\]]+).node.example.com/v14`, and from there we'll be able to match\n // https://eu.node.example.com/v14/api/esm and ultimately find the operation matches for\n // `/api/esm`.\n if (!matchedServer || !pathName) {\n const matchedServerAndPath = (servers || [])\n .map(server => {\n const rgx = transformURLIntoRegex(server.url);\n const found = new RegExp(rgx).exec(url);\n if (!found) {\n return undefined;\n }\n\n return {\n matchedServer: server,\n pathName: url.split(new RegExp(rgx)).slice(-1).pop(),\n };\n })\n .filter((item): item is { matchedServer: ServerObject; pathName: string | undefined } => item !== undefined);\n\n if (!matchedServerAndPath.length) {\n return undefined;\n }\n\n pathName = matchedServerAndPath[0].pathName;\n targetServer = {\n ...matchedServerAndPath[0].matchedServer,\n };\n }\n\n if (pathName === undefined) return undefined;\n if (pathName === '') pathName = '/';\n if (!paths || !targetServer) return undefined;\n const annotatedPaths = generatePathMatches(paths, pathName, targetServer.url);\n if (!annotatedPaths.length) return undefined;\n\n return annotatedPaths;\n }\n\n /**\n * Discover an operation in an OAS from a fully-formed URL and HTTP method. Will return an object\n * containing a `url` object and another one for `operation`. This differs from `getOperation()`\n * in that it does not return an instance of the `Operation` class.\n *\n * @param url A full URL to look up.\n * @param method The cooresponding HTTP method to look up.\n */\n findOperation(url: string, method: HttpMethods): PathMatch | undefined {\n const annotatedPaths = this.findOperationMatches(url);\n if (!annotatedPaths) {\n return undefined;\n }\n\n const matches = filterPathMethods(annotatedPaths, method);\n if (!matches.length) return undefined;\n return findTargetPath(matches);\n }\n\n /**\n * Discover an operation in an OAS from a fully-formed URL without an HTTP method. Will return an\n * object containing a `url` object and another one for `operation`.\n *\n * @param url A full URL to look up.\n */\n findOperationWithoutMethod(url: string): PathMatch | undefined {\n const annotatedPaths = this.findOperationMatches(url);\n if (!annotatedPaths) {\n return undefined;\n }\n\n return findTargetPath(annotatedPaths);\n }\n\n /**\n * Retrieve an operation in an OAS from a fully-formed URL and HTTP method. Differs from\n * `findOperation` in that while this method will return an `Operation` instance,\n * `findOperation()` does not.\n *\n * @param url A full URL to look up.\n * @param method The cooresponding HTTP method to look up.\n */\n getOperation(url: string, method: HttpMethods): Operation | undefined {\n const op = this.findOperation(url, method);\n if (op === undefined) {\n return undefined;\n }\n\n return this.operation(op.url.nonNormalizedPath, method);\n }\n\n /**\n * Retrieve an operation in an OAS by an `operationId`.\n *\n * If an operation does not have an `operationId` one will be generated in place, using the\n * default behavior of `Operation.getOperationId()`, and then asserted against your query.\n *\n * Note that because `operationId`s are unique that uniqueness does include casing so the ID\n * you are looking for will be asserted as an exact match.\n *\n * @see {Operation.getOperationId()}\n * @param id The `operationId` to look up.\n */\n getOperationById(id: string): Operation | Webhook | undefined {\n let found: Operation | Webhook | undefined;\n\n Object.values(this.getPaths()).forEach(operations => {\n if (found) return;\n found = Object.values(operations).find(operation => operation.getOperationId() === id);\n });\n\n if (found) {\n return found;\n }\n\n Object.entries(this.getWebhooks()).forEach(([, webhooks]) => {\n if (found) return;\n found = Object.values(webhooks).find(webhook => webhook.getOperationId() === id);\n });\n\n return found;\n }\n\n /**\n * With an object of user information, retrieve the appropriate API auth keys from the current\n * OAS definition.\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n * @param user User\n * @param selectedApp The user app to retrieve an auth key for.\n */\n getAuth(user: User, selectedApp?: number | string): AuthForHAR {\n if (!this.api?.components?.securitySchemes) {\n return {};\n }\n\n return getAuth(this.api, user, selectedApp);\n }\n\n /**\n * Returns the `paths` object that exists in this API definition but with every `method` mapped\n * to an instance of the `Operation` class.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n */\n getPaths(): Record<string, Record<HttpMethods, Operation | Webhook>> {\n const paths: Record<string, Record<HttpMethods, Operation | Webhook>> = {};\n if (!this.api.paths) {\n return paths;\n }\n\n Object.keys(this.api.paths).forEach(path => {\n // If this is a specification extension then we should ignore it.\n if (path.startsWith('x-')) {\n return;\n }\n\n paths[path] = {} as Record<HttpMethods, Operation | Webhook>;\n\n // biome-ignore-start lint/style/noNonNullAssertion: We're guaranteed to have `api.paths[path]` from the `.keys()` loop.\n const pathItem = this.api.paths![path];\n if (!pathItem) {\n return;\n } else if (isRef(pathItem)) {\n // Though this library is generally unaware of `$ref` pointers we're making a singular\n // exception with this accessor out of convenience.\n this.api.paths![path] = dereferenceRef(pathItem, this.api);\n }\n\n Object.keys(pathItem).forEach(method => {\n /**\n * Because a path doesn't need to contain a keyed-object of HTTP methods, we should exclude\n * anything from within the paths object that isn't a known HTTP method.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#fixed-fields-7}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#fixed-fields-7}\n */\n if (!supportedMethods.includes(method as HttpMethods)) {\n return;\n }\n\n paths[path][method as HttpMethods] = this.operation(path, method as HttpMethods);\n });\n // biome-ignore-end lint/style/noNonNullAssertion: --end--\n });\n\n return paths;\n }\n\n /**\n * Returns the `webhooks` object that exists in this API definition but with every `method`\n * mapped to an instance of the `Webhook` class.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n */\n getWebhooks(): Record<string, Record<HttpMethods, Webhook>> {\n const webhooks: Record<string, Record<HttpMethods, Webhook>> = {};\n if (!isOpenAPI31(this.api) || !this.api.webhooks) {\n return webhooks;\n }\n\n Object.keys(this.api.webhooks).forEach(id => {\n webhooks[id] = {} as Record<HttpMethods, Webhook>;\n\n const webhookPath = dereferenceRef((this.api as OpenAPIV3_1.Document).webhooks?.[id], this.api);\n if (webhookPath) {\n Object.keys(webhookPath).forEach(method => {\n if (!supportedMethods.includes(method as HttpMethods)) {\n return;\n }\n\n webhooks[id][method as HttpMethods] = this.operation(id, method as HttpMethods, {\n isWebhook: true,\n }) as Webhook;\n });\n }\n });\n\n return webhooks;\n }\n\n /**\n * Return an array of all tag names that exist on this API definition.\n *\n * If the API definition uses the `x-disable-tag-sorting` extension then tags will be returned in\n * the order they're defined.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.0.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n * @param setIfMissing If a tag is not present on an operation that operations path will be added\n * into the list of tags returned.\n */\n getTags(setIfMissing = false): string[] {\n const allTags = new Set<string>();\n\n const oasTags = this.api.tags?.map(tag => tag.name) || [];\n\n const disableTagSorting = getExtension('disable-tag-sorting', this.api);\n\n Object.entries(this.getPaths()).forEach(([path, operations]) => {\n Object.values(operations).forEach(operation => {\n const tags = operation.getTags();\n if (setIfMissing && !tags.length) {\n allTags.add(path);\n return;\n }\n\n tags.forEach(tag => {\n allTags.add(tag.name);\n });\n });\n });\n\n Object.entries(this.getWebhooks()).forEach(([path, webhooks]) => {\n Object.values(webhooks).forEach(webhook => {\n const tags = webhook.getTags();\n if (setIfMissing && !tags.length) {\n allTags.add(path);\n return;\n }\n\n tags.forEach(tag => {\n allTags.add(tag.name);\n });\n });\n });\n\n // Tags that exist only on the endpoint\n const endpointTags: string[] = [];\n // Tags that the user has defined in the `tags` array\n const tagsArray: string[] = [];\n\n // Distinguish between which tags exist in the `tags` array and which tags\n // exist only at the endpoint level. For tags that exist only at the\n // endpoint level, we'll just tack that on to the end of the sorted tags.\n if (disableTagSorting) {\n return Array.from(allTags);\n }\n\n Array.from(allTags).forEach(tag => {\n if (oasTags.includes(tag)) {\n tagsArray.push(tag);\n } else {\n endpointTags.push(tag);\n }\n });\n\n let sortedTags = tagsArray.sort((a, b) => {\n return oasTags.indexOf(a) - oasTags.indexOf(b);\n });\n\n sortedTags = sortedTags.concat(endpointTags);\n\n return sortedTags;\n }\n\n /**\n * Determine if a given a custom specification extension exists within the API definition.\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 hasRootExtension(extension, this.api);\n }\n\n /**\n * Retrieve a custom specification extension off of the API definition.\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 getExtension(extension: string | keyof Extensions, operation?: Operation): any {\n return getExtension(extension, this.api, operation);\n }\n\n /**\n * Determine if a given OpenAPI custom extension is valid or not.\n *\n * @see {@link https://docs.readme.com/docs/openapi-extensions}\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 validate.\n * @throws\n */\n validateExtension(extension: keyof Extensions): void {\n if (this.hasExtension('x-readme')) {\n const data = this.getExtension('x-readme') satisfies Extensions;\n if (typeof data !== 'object' || Array.isArray(data) || data === null) {\n throw new TypeError('\"x-readme\" must be of type \"Object\"');\n }\n\n if (extension in data) {\n if ([CODE_SAMPLES, HEADERS, PARAMETER_ORDERING, SAMPLES_LANGUAGES].includes(extension)) {\n if (data[extension] !== undefined) {\n if (!Array.isArray(data[extension])) {\n throw new TypeError(`\"x-readme.${extension}\" must be of type \"Array\"`);\n }\n\n if (extension === PARAMETER_ORDERING) {\n validateParameterOrdering(data[extension], `x-readme.${extension}`);\n }\n }\n } else if (extension === OAUTH_OPTIONS) {\n if (typeof data[extension] !== 'object') {\n throw new TypeError(`\"x-readme.${extension}\" must be of type \"Object\"`);\n }\n } else if (typeof data[extension] !== 'boolean') {\n throw new TypeError(`\"x-readme.${extension}\" must be of type \"Boolean\"`);\n }\n }\n }\n\n // If the extension isn't grouped under `x-readme`, we need to look for them with `x-` prefixes.\n if (this.hasExtension(`x-${extension}`)) {\n const data = this.getExtension(`x-${extension}`);\n if ([CODE_SAMPLES, HEADERS, PARAMETER_ORDERING, SAMPLES_LANGUAGES].includes(extension)) {\n if (!Array.isArray(data)) {\n throw new TypeError(`\"x-${extension}\" must be of type \"Array\"`);\n }\n\n if (extension === PARAMETER_ORDERING) {\n validateParameterOrdering(data, `x-${extension}`);\n }\n } else if (extension === OAUTH_OPTIONS) {\n if (typeof data !== 'object') {\n throw new TypeError(`\"x-${extension}\" must be of type \"Object\"`);\n }\n } else if (typeof data !== 'boolean') {\n throw new TypeError(`\"x-${extension}\" must be of type \"Boolean\"`);\n }\n }\n }\n\n /**\n * Validate all of our custom or known OpenAPI extensions, throwing exceptions when necessary.\n *\n * @see {@link https://docs.readme.com/docs/openapi-extensions}\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 */\n validateExtensions(): void {\n Object.keys(extensionDefaults).forEach(extension => {\n this.validateExtension(extension as keyof Extensions);\n });\n }\n\n /**\n * Retrieve any circular `$ref` pointers that maybe present within the API definition.\n *\n * This method requires that you first dereference the definition.\n *\n * @see Oas.dereference\n */\n getCircularReferences(): string[] {\n if (!this.dereferencing.complete) {\n throw new Error('.dereference() must be called first in order for this method to obtain circular references.');\n }\n\n return this.dereferencing.circularRefs;\n }\n\n /**\n * Dereference the current OAS definition so it can be parsed free of worries of `$ref` schemas\n * and circular structures.\n *\n */\n async dereference(\n opts: {\n /**\n * A callback method can be supplied to be called when dereferencing is complete. Used for\n * debugging that the multi-promise handling within this method works.\n *\n * @private\n */\n cb?: () => void;\n\n /**\n * Preserve component schema names within themselves as a `title`.\n */\n preserveRefAsJSONSchemaTitle?: boolean;\n } = { preserveRefAsJSONSchemaTitle: false },\n ): Promise<(typeof this.promises)[] | boolean> {\n if (this.dereferencing.complete) {\n return new Promise(resolve => {\n resolve(true);\n });\n }\n\n if (this.dereferencing.processing) {\n return new Promise((resolve, reject) => {\n this.promises.push({ resolve, reject });\n });\n }\n\n this.dereferencing.processing = true;\n\n /**\n * Find `discriminator` schemas and their children before dereferencing (`allOf` `$ref` pointers\n * are resolved during dereferencing). For schemas with a `discriminator` using `allOf`\n * inheritance we build a `oneOf` array from the discovered child schemas so consumers can see\n * the full set of polymorphic options.\n *\n * @see {@link https://spec.openapis.org/oas/v3.0.0.html#fixed-fields-20}\n */\n const { children: discriminatorChildrenMap } = findDiscriminatorChildren(this.api);\n\n const { api, promises } = this;\n\n // Because referencing will eliminate any lineage back to the original `$ref`, information that\n // we might need at some point, we should run through all available component schemas and denote\n // what their name is so that when dereferencing happens below those names will be preserved.\n if (api?.components?.schemas && typeof api.components.schemas === 'object') {\n Object.keys(api.components.schemas).forEach(schemaName => {\n // As of OpenAPI 3.1 component schemas can be primitives or arrays. If this happens then we\n // shouldn't try to add `title` or `x-readme-ref-name` properties because we can't. We'll\n // have some data loss on these schemas but as they aren't objects they likely won't be used\n // in ways that would require needing a `title` or `x-readme-ref-name` anyways.\n if (\n isPrimitive(api.components?.schemas?.[schemaName]) ||\n Array.isArray(api.components?.schemas?.[schemaName]) ||\n api.components?.schemas?.[schemaName] === null\n ) {\n return;\n }\n\n if (opts.preserveRefAsJSONSchemaTitle) {\n // This may result in some data loss if there's already a `title` present, but in the case\n // where we want to generate code for the API definition (see http://npm.im/api), we'd\n // prefer to retain original reference name as a title for any generated types.\n (api.components?.schemas?.[schemaName] as SchemaObject).title = schemaName;\n }\n\n (api.components?.schemas?.[schemaName] as SchemaObject)['x-readme-ref-name'] = schemaName;\n });\n }\n\n const circularRefs: Set<string> = new Set();\n const dereferencingOptions = getDereferencingOptions(circularRefs);\n\n return dereference<OASDocument>(api, dereferencingOptions)\n .then((dereferenced: OASDocument) => {\n this.api = dereferenced;\n\n // Construct `oneOf` arrays for `discriminator` schemas using their dereferenced child\n // schemas. This must be done **after** dereferencing so we have the fully resolved child\n // schemas.\n if (this.api?.components?.schemas && discriminatorChildrenMap.size > 0) {\n buildDiscriminatorOneOf(this.api, discriminatorChildrenMap);\n }\n\n this.promises = promises;\n this.dereferencing = {\n processing: false,\n complete: true,\n // We need to convert our `Set` to an array in order to match the typings.\n circularRefs: [...circularRefs],\n };\n\n // Used for debugging that dereferencing promise awaiting works.\n if (opts.cb) {\n opts.cb();\n }\n })\n .then(() => {\n return this.promises.map(deferred => deferred.resolve());\n })\n .catch(err => {\n this.dereferencing.processing = false;\n this.promises.map(deferred => deferred.reject(err));\n throw err;\n });\n }\n}\n","import type { AuthForHAR, KeyedSecuritySchemeObject, OASDocument, User } from '../types.js';\n\nimport { isRef } from '../types.js';\nimport { dereferenceRef } from './refs.js';\n\ntype authKey = unknown | { password: number | string; user: number | string } | null;\n\n/**\n * @param user User to retrieve retrieve an auth key for.\n * @param scheme The type of security scheme that we want a key for.\n */\nfunction getKey(user: User, scheme: KeyedSecuritySchemeObject): authKey {\n switch (scheme.type) {\n case 'oauth2':\n case 'apiKey':\n return user[scheme._key] || user.apiKey || scheme['x-default'] || null;\n\n case 'http':\n if (scheme.scheme === 'basic') {\n return user[scheme._key] || { user: user.user || null, pass: user.pass || null };\n }\n\n if (scheme.scheme === 'bearer') {\n return user[scheme._key] || user.apiKey || scheme['x-default'] || null;\n }\n return null;\n\n default:\n return null;\n }\n}\n\n/**\n * Retrieve auth keys for a specific security scheme for a given user for a specific \"app\" that\n * they have configured.\n *\n * For `scheme` we're typing it to a union of `SecurityScheme` and `any` because we have handling\n * and tests for an unknown or unrecognized `type` and though it's not possible with the\n * `SecurityScheme.type` to be unrecognized it may still be possible to get an unrecognized scheme\n * with this method in the wild as we have API definitions in our database that were ingested\n * before we had good validation in place.\n *\n * @param user User\n * @param scheme Security scheme to get auth keys for.\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport function getByScheme(\n user: User,\n scheme = {} as KeyedSecuritySchemeObject,\n selectedApp?: number | string,\n): authKey {\n if (user?.keys?.length) {\n if (selectedApp) {\n const userKey = user.keys.find(k => k.name === selectedApp);\n if (!userKey) {\n return null;\n }\n\n return getKey(userKey, scheme);\n }\n\n return getKey(user.keys[0], scheme);\n }\n\n return getKey(user, scheme);\n}\n\n/**\n * Retrieve auth keys for an API definition from a given user for a specific \"app\" that they have\n * configured.\n *\n * @param api API definition\n * @param user User\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport function getAuth(api: OASDocument, user: User, selectedApp?: number | string): AuthForHAR {\n return Object.keys(api?.components?.securitySchemes || {})\n .map(scheme => {\n const securityScheme = dereferenceRef(api.components?.securitySchemes?.[scheme], api);\n if (!securityScheme || isRef(securityScheme)) {\n // If this security scheme is invalid or an unresolvable `$ref` pointer then we should skip\n // it.\n return false;\n }\n\n return {\n [scheme]: getByScheme(\n user,\n {\n ...securityScheme,\n _key: scheme,\n },\n selectedApp,\n ),\n };\n })\n .filter((item): item is AuthForHAR => item !== undefined)\n .reduce((prev, next) => Object.assign(prev, next), {});\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 */\n// biome-ignore lint/style/noDefaultExport: This is safe for now.\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 { Match, ParamData } from 'path-to-regexp';\nimport type { HttpMethods, OASDocument, PathsObject } from '../types';\n\nimport { match, pathToRegexp } from 'path-to-regexp';\n\nimport { SERVER_VARIABLE_REGEX } from '../utils';\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 function stripTrailingSlash(url: string): string {\n if (url[url.length - 1] === '/') {\n return url.slice(0, -1);\n }\n\n return url;\n}\n\nfunction ensureProtocol(url: string) {\n // Add protocol to urls starting with // e.g. //example.com\n // This is because httpsnippet throws a HARError when it doesnt have a protocol\n if (url.match(/^\\/\\//)) {\n return `https:${url}`;\n }\n\n // Add protocol to urls with no // within them\n // This is because httpsnippet throws a HARError when it doesnt have a protocol\n if (!url.match(/\\/\\//)) {\n return `https://${url}`;\n }\n\n return url;\n}\n\n/**\n * Normalize a OpenAPI server URL by ensuring that it has a proper HTTP protocol and doesn't have a\n * trailing slash.\n *\n * @param api The API definition that we're processing.\n * @param selected The index of the `servers` array in the API definition that we want to normalize.\n */\nexport function normalizedURL(api: OASDocument, selected: number): string {\n const exampleDotCom = 'https://example.com';\n let url: string | undefined;\n try {\n url = api.servers?.[selected].url;\n // This is to catch the case where servers = [{}]\n if (!url) throw new Error('no url');\n\n // Stripping the '/' off the end\n url = stripTrailingSlash(url);\n\n // Check if the URL is just a path a missing an origin, for example `/api/v3`. If so, then make\n // `example.com` the origin to avoid it becoming something invalid like `https:///api/v3`.\n // RM-1044\n if (url.startsWith('/') && !url.startsWith('//')) {\n const urlWithOrigin = new URL(exampleDotCom);\n urlWithOrigin.pathname = url;\n url = urlWithOrigin.href;\n }\n } catch {\n url = exampleDotCom;\n }\n\n return ensureProtocol(url);\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 * @param url URL to transform\n */\nexport function transformURLIntoRegex(url: string): string {\n return stripTrailingSlash(url.replace(SERVER_VARIABLE_REGEX, '([-_a-zA-Z0-9:.[\\\\]]+)'));\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 return (\n path\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 .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 return `:${args[1].replace('-', '')}`;\n })\n\n // In addition to transforming `{pathParam}` into `:pathParam` we also need to escape cases\n // where a non-variabled colon is next to a variabled-colon because if we don't then\n // `path-to-regexp` won't be able to correct identify where the variable starts.\n //\n // For example if the URL is `/post/:param1::param2` we'll be escaping it to\n // `/post/:param1\\::param2`.\n .replace(/::/, '\\\\::')\n\n // We also need to escape question marks too because they're treated as regex modifiers.\n .split('?')[0]\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 prunedPathName = pathName.split('?')[0];\n const matches: PathMatches = Object.keys(paths)\n .map(path => {\n const cleanedPath = normalizePath(path);\n\n let matchResult: PathMatch['match'];\n try {\n const matchStatement = match(cleanedPath, { decode: decodeURIComponent });\n matchResult = matchStatement(prunedPathName);\n } catch {\n // If path matching fails for whatever reason (maybe they have a malformed path parameter)\n // then we shouldn't also fail.\n return false;\n }\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(/\\\\::/, '::'),\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 * @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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAgBA,SAAS,mBAAmB;;;ACL5B,SAAS,OAAO,MAAY,QAA4C;AACtE,UAAQ,OAAO,MAAM;AAAA,IACnB,KAAK;AAAA,IACL,KAAK;AACH,aAAO,KAAK,OAAO,IAAI,KAAK,KAAK,UAAU,OAAO,WAAW,KAAK;AAAA,IAEpE,KAAK;AACH,UAAI,OAAO,WAAW,SAAS;AAC7B,eAAO,KAAK,OAAO,IAAI,KAAK,EAAE,MAAM,KAAK,QAAQ,MAAM,MAAM,KAAK,QAAQ,KAAK;AAAA,MACjF;AAEA,UAAI,OAAO,WAAW,UAAU;AAC9B,eAAO,KAAK,OAAO,IAAI,KAAK,KAAK,UAAU,OAAO,WAAW,KAAK;AAAA,MACpE;AACA,aAAO;AAAA,IAET;AACE,aAAO;AAAA,EACX;AACF;AAgBO,SAAS,YACd,MACA,SAAS,CAAC,GACV,aACS;AACT,MAAI,MAAM,MAAM,QAAQ;AACtB,QAAI,aAAa;AACf,YAAM,UAAU,KAAK,KAAK,KAAK,OAAK,EAAE,SAAS,WAAW;AAC1D,UAAI,CAAC,SAAS;AACZ,eAAO;AAAA,MACT;AAEA,aAAO,OAAO,SAAS,MAAM;AAAA,IAC/B;AAEA,WAAO,OAAO,KAAK,KAAK,CAAC,GAAG,MAAM;AAAA,EACpC;AAEA,SAAO,OAAO,M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supportedMethods = ["get", "put", "post", "delete", "options", "head", "patch", "trace"];
3
- var SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\]]+)}/g;
4
-
5
-
6
-
7
-
8
- exports.supportedMethods = supportedMethods; exports.SERVER_VARIABLE_REGEX = SERVER_VARIABLE_REGEX;
9
- //# sourceMappingURL=chunk-O3GIPZLC.cjs.map
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-O3GIPZLC.cjs","../src/utils.ts"],"names":[],"mappings":"AAAA;ACIO,IAAM,iBAAA,EAAmB,CAAC,KAAA,EAAO,KAAA,EAAO,MAAA,EAAQ,QAAA,EAAU,SAAA,EAAW,MAAA,EAAQ,OAAA,EAAS,OAAO,CAAA;AAE7F,IAAM,sBAAA,EAAgC,0BAAA;ADH7C;AACA;AACE;AACA;AACF,mGAAC","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-O3GIPZLC.cjs","sourcesContent":[null,"import { getParameterContentType } from './lib/get-parameter-content-type.js';\nimport matchesMimeType from './lib/matches-mimetype.js';\nimport { types as jsonSchemaTypes } from './operation/lib/get-parameters-as-json-schema.js';\n\nexport const supportedMethods = ['get', 'put', 'post', 'delete', 'options', 'head', 'patch', 'trace'] as const;\n\nexport const SERVER_VARIABLE_REGEX: RegExp = /{([-_a-zA-Z0-9:.[\\]]+)}/g;\n\nexport { getParameterContentType, jsonSchemaTypes, matchesMimeType };\n"]}