oas 27.0.1 → 27.2.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 (38) hide show
  1. package/README.md +3 -1
  2. package/dist/analyzer/index.cjs +71 -7
  3. package/dist/analyzer/index.cjs.map +1 -1
  4. package/dist/analyzer/index.d.cts +0 -1
  5. package/dist/analyzer/index.d.ts +0 -1
  6. package/dist/analyzer/index.js +70 -6
  7. package/dist/analyzer/index.js.map +1 -1
  8. package/dist/analyzer/types.d.cts +8 -0
  9. package/dist/analyzer/types.d.ts +8 -0
  10. package/dist/{chunk-36L32E7W.js → chunk-3TRWJPXH.js} +3 -3
  11. package/dist/chunk-3TRWJPXH.js.map +1 -0
  12. package/dist/{chunk-HGHW4JSM.js → chunk-5XZQA26T.js} +2 -2
  13. package/dist/chunk-5XZQA26T.js.map +1 -0
  14. package/dist/{chunk-7XLR2GY5.cjs → chunk-BLQKFBR2.cjs} +6 -6
  15. package/dist/chunk-BLQKFBR2.cjs.map +1 -0
  16. package/dist/{chunk-Q2TBKI3O.cjs → chunk-OJBEY3IB.cjs} +1 -1
  17. package/dist/chunk-OJBEY3IB.cjs.map +1 -0
  18. package/dist/{chunk-4EWSCVWC.cjs → chunk-URXLIMMM.cjs} +18 -18
  19. package/dist/chunk-URXLIMMM.cjs.map +1 -0
  20. package/dist/{chunk-5KFARTQ3.js → chunk-V24D22KO.js} +1 -1
  21. package/dist/chunk-V24D22KO.js.map +1 -0
  22. package/dist/index.cjs +4 -4
  23. package/dist/index.d.cts +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +3 -3
  26. package/dist/operation/index.cjs +3 -3
  27. package/dist/operation/index.js +2 -2
  28. package/dist/operation/lib/get-parameters-as-json-schema.cjs +2 -2
  29. package/dist/operation/lib/get-parameters-as-json-schema.js +1 -1
  30. package/dist/utils.cjs +2 -2
  31. package/dist/utils.js +1 -1
  32. package/package.json +5 -5
  33. package/dist/chunk-36L32E7W.js.map +0 -1
  34. package/dist/chunk-4EWSCVWC.cjs.map +0 -1
  35. package/dist/chunk-5KFARTQ3.js.map +0 -1
  36. package/dist/chunk-7XLR2GY5.cjs.map +0 -1
  37. package/dist/chunk-HGHW4JSM.js.map +0 -1
  38. package/dist/chunk-Q2TBKI3O.cjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/index.ts","../src/lib/get-auth.ts","../src/lib/get-user-variable.ts"],"sourcesContent":["import type { Extensions } from './extensions.js';\nimport type * as RMOAS from './types.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { Match, ParamData } from 'path-to-regexp';\n\nimport { dereference } from '@readme/openapi-parser';\nimport { pathToRegexp, match } from 'path-to-regexp';\n\nimport {\n CODE_SAMPLES,\n HEADERS,\n OAUTH_OPTIONS,\n PARAMETER_ORDERING,\n SAMPLES_LANGUAGES,\n extensionDefaults,\n getExtension,\n hasRootExtension,\n validateParameterOrdering,\n} from './extensions.js';\nimport { getAuth } from './lib/get-auth.js';\nimport getUserVariable from './lib/get-user-variable.js';\nimport { isPrimitive } from './lib/helpers.js';\nimport { Operation, Webhook } from './operation/index.js';\nimport { findSchemaDefinition, supportedMethods } from './utils.js';\n\ninterface PathMatch {\n match?: Match<ParamData>;\n operation: RMOAS.PathsObject;\n url: {\n method?: RMOAS.HttpMethods;\n nonNormalizedPath: string;\n origin: string;\n path: string;\n slugs: Record<string, string>;\n };\n}\ntype PathMatches = PathMatch[];\n\nconst SERVER_VARIABLE_REGEX = /{([-_a-zA-Z0-9:.[\\]]+)}/g;\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\nfunction stripTrailingSlash(url: string) {\n if (url[url.length - 1] === '/') {\n return url.slice(0, -1);\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 */\nfunction normalizedUrl(api: RMOAS.OASDocument, selected: number) {\n const exampleDotCom = 'https://example.com';\n let url;\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 (e) {\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 */\nfunction transformUrlIntoRegex(url: 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 */\nfunction generatePathMatches(paths: RMOAS.PathsObject, pathName: string, origin: string) {\n const prunedPathName = pathName.split('?')[0];\n return 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 (err) {\n // If path matching fails for whatever reason (maybe they have a malformed path parameter)\n // then we shouldn't also fail.\n return;\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 // eslint-disable-next-line consistent-return\n return {\n url: {\n origin,\n path: cleanedPath.replace(/\\\\::/, '::'),\n nonNormalizedPath: path,\n slugs,\n },\n operation: paths[path],\n match: matchResult,\n };\n })\n .filter(Boolean)\n .filter(p => p.match) as PathMatches;\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 */\nfunction filterPathMethods(pathMatches: PathMatches, targetMethod: RMOAS.HttpMethods) {\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 RMOAS.HttpMethods;\n\n return {\n url: p.url,\n operation: p.operation[method],\n };\n }\n\n return false;\n })\n .filter(Boolean) as { operation: RMOAS.OperationObject; url: PathMatch['url'] }[];\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 */\nfunction findTargetPath(pathMatches: { operation: RMOAS.PathsObject; url: PathMatch['url'] }[]) {\n let minCount = Object.keys(pathMatches[0].url.slugs).length;\n let operation;\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 operation = selection;\n }\n }\n\n return operation;\n}\n\nexport default class Oas {\n /**\n * An OpenAPI API Definition.\n */\n api: RMOAS.OASDocument;\n\n /**\n * The current user that we should use when pulling auth tokens from security schemes.\n */\n user: RMOAS.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: RMOAS.OASDocument | string, user?: RMOAS.User) {\n if (typeof oas === 'string') {\n // eslint-disable-next-line try-catch-failsafe/json-parse\n oas = JSON.parse(oas) as RMOAS.OASDocument;\n }\n\n this.api = oas || ({} as RMOAS.OASDocument);\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: Record<string, unknown> | RMOAS.OASDocument, user?: RMOAS.User): Oas {\n return new Oas(oas as RMOAS.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(): RMOAS.OASDocument {\n return this.api;\n }\n\n url(selected = 0, variables?: RMOAS.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): RMOAS.ServerVariablesObject {\n let variables: RMOAS.ServerVariablesObject;\n try {\n variables = this.api.servers[selected].variables;\n if (!variables) throw new Error('no variables');\n } catch (e) {\n variables = {};\n }\n\n return variables;\n }\n\n defaultVariables(selected = 0): RMOAS.ServerVariable {\n const variables = this.variables(selected);\n const defaults: RMOAS.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): RMOAS.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(Boolean);\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: RMOAS.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 data.default as string;\n }\n } else {\n return data as string;\n }\n }\n\n const userVariable = getUserVariable(this.user, key);\n if (userVariable) {\n return userVariable as string;\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: RMOAS.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: RMOAS.OperationObject = {\n parameters: [],\n };\n\n if (opts.isWebhook) {\n const api = this.api as OpenAPIV3_1.Document;\n // Typecasting this to a `PathsObject` because we don't have `$ref` pointers here.\n if ((api?.webhooks[path] as RMOAS.PathsObject)?.[method]) {\n operation = (api.webhooks[path] as RMOAS.PathsObject)[method] as RMOAS.OperationObject;\n return new Webhook(api, path, method, operation);\n }\n }\n\n if (this?.api?.paths?.[path]?.[method]) {\n operation = this.api.paths[path][method];\n }\n\n return new Operation(this.api, path, method, operation);\n }\n\n findOperationMatches(url: string): PathMatches {\n const { origin, hostname } = new URL(url);\n const originRegExp = new RegExp(origin, 'i');\n const { servers, paths } = this.api;\n\n let pathName;\n let targetServer;\n let matchedServer;\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 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) {\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(Boolean);\n\n if (!matchedServerAndPath.length) {\n return undefined;\n }\n\n pathName = matchedServerAndPath[0].pathName;\n targetServer = {\n ...matchedServerAndPath[0].matchedServer,\n };\n } else {\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 (pathName === undefined) return undefined;\n if (pathName === '') pathName = '/';\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: RMOAS.HttpMethods): PathMatch {\n const annotatedPaths = this.findOperationMatches(url);\n if (!annotatedPaths) {\n return undefined;\n }\n\n const matches = filterPathMethods(annotatedPaths, method) as {\n operation: RMOAS.PathsObject;\n url: PathMatch['url']; // @fixme this should actually be an `OperationObject`.\n }[];\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 {\n const annotatedPaths = this.findOperationMatches(url);\n if (!annotatedPaths) {\n return undefined;\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: RMOAS.HttpMethods): Operation {\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 {\n let found: Operation | Webhook;\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: RMOAS.User, selectedApp?: number | string): RMOAS.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<RMOAS.HttpMethods, Operation | Webhook>> {\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 const paths: Record<string, Record<RMOAS.HttpMethods, Operation | Webhook>> = {};\n\n Object.keys(this.api.paths ? 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<RMOAS.HttpMethods, Operation | Webhook>;\n\n // Though this library is generally unaware of `$ref` pointers we're making a singular\n // exception with this accessor out of convenience.\n if ('$ref' in this.api.paths[path]) {\n this.api.paths[path] = findSchemaDefinition(this.api.paths[path].$ref, this.api);\n }\n\n Object.keys(this.api.paths[path]).forEach((method: RMOAS.HttpMethods) => {\n if (!supportedMethods.includes(method)) return;\n\n paths[path][method] = this.operation(path, method);\n });\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<RMOAS.HttpMethods, Webhook>> {\n const webhooks: Record<string, Record<RMOAS.HttpMethods, Webhook>> = {};\n const api = this.api as OpenAPIV3_1.Document;\n\n Object.keys(api.webhooks ? api.webhooks : []).forEach(id => {\n webhooks[id] = {} as Record<RMOAS.HttpMethods, Webhook>;\n Object.keys(api.webhooks[id]).forEach((method: RMOAS.HttpMethods) => {\n webhooks[id][method] = this.operation(id, method, { isWebhook: true }) as Webhook;\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 * @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 =\n this.api.tags?.map(tag => {\n return tag.name;\n }) || [];\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') as 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 (!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 } 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: keyof Extensions) => {\n this.validateExtension(extension);\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 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 && 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 RMOAS.SchemaObject).title = schemaName;\n }\n\n (api.components.schemas[schemaName] as RMOAS.SchemaObject)['x-readme-ref-name'] = schemaName;\n });\n }\n\n const circularRefs: Set<string> = new Set();\n\n return dereference<RMOAS.OASDocument>(api, {\n resolve: {\n // We shouldn't be resolving external pointers at this point so just ignore them.\n external: false,\n },\n dereference: {\n // If circular `$refs` are ignored they'll remain in the OAS as `$ref: String`, otherwise\n // `$ref‘ just won't exist. This allows us to do easy circular reference detection.\n circular: 'ignore',\n\n onCircular: (path: string) => {\n // The circular references that are coming out of `json-schema-ref-parser` are prefixed\n // with the schema path (file path, URL, whatever) that the schema exists in. Because\n // we don't care about this information for this reporting mechanism, and only the\n // `$ref` pointer, we're removing it.\n circularRefs.add(`#${path.split('#')[1]}`);\n },\n },\n })\n .then((dereferenced: RMOAS.OASDocument) => {\n this.api = dereferenced;\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 }\n}\n","import type * as RMOAS from '../types.js';\nimport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\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: RMOAS.User, scheme: RMOAS.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: RMOAS.User,\n scheme = <RMOAS.KeyedSecuritySchemeObject>{},\n selectedApp?: number | string,\n): authKey {\n if (user?.keys && user.keys.length) {\n if (selectedApp) {\n return getKey(\n user.keys.find(key => key.name === selectedApp),\n scheme,\n );\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(\n api: OpenAPIV3_1.Document | OpenAPIV3.Document,\n user: RMOAS.User,\n selectedApp?: number | string,\n): RMOAS.AuthForHAR {\n return Object.keys(api?.components?.securitySchemes || {})\n .map(scheme => {\n return {\n [scheme]: getByScheme(\n user,\n {\n // This sucks but since we dereference we'll never have a `$ref` pointer here with a\n // `ReferenceObject` type.\n ...(api.components.securitySchemes[scheme] as RMOAS.SecuritySchemeObject),\n _key: scheme,\n },\n selectedApp,\n ),\n };\n })\n .reduce((prev, next) => Object.assign(prev, next), {});\n}\n","import type * as RMOAS from '../types.js';\n\n/**\n * Retrieve a user variable off of a given user.\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n * @param user The user to get a user variable for.\n * @param property The name of the variable to retrieve.\n * @param selectedApp The user app to retrieve an auth key for.\n */\nexport default function getUserVariable(user: RMOAS.User, property: string, selectedApp?: number | string): unknown {\n let key = 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"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAKA,SAAS,mBAAmB;AAC5B,SAAS,cAAc,aAAa;;;ACGpC,SAAS,OAAO,MAAkB,QAAkD;AAClF,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,SAA0C,CAAC,GAC3C,aACS;AACT,MAAI,MAAM,QAAQ,KAAK,KAAK,QAAQ;AAClC,QAAI,a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IAAI,IAAI,KAAK,MAAM,GAAG,EAAE,CAAC,CAAC,EAAE;AAAA,QAC3C;AAAA,MACF;AAAA,IACF,CAAC,EACE,KAAK,CAAC,iBAAoC;AACzC,WAAK,MAAM;AAEX,WAAK,WAAW;AAChB,WAAK,gBAAgB;AAAA,QACnB,YAAY;AAAA,QACZ,UAAU;AAAA;AAAA,QAEV,cAAc,CAAC,GAAG,YAAY;AAAA,MAChC;AAGA,UAAI,KAAK,IAAI;AACX,aAAK,GAAG;AAAA,MACV;AAAA,IACF,CAAC,EACA,KAAK,MAAM;AACV,aAAO,KAAK,SAAS,IAAI,cAAY,SAAS,QAAQ,CAAC;AAAA,IACzD,CAAC;AAAA,EACL;AACF;","names":[]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-4EWSCVWC.cjs","../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/index.ts"],"names":[],"mappings":"AAAA;AACE;AACA;AACF,wDAA6B;AAC7B;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACE;AACF,wDAA6B;AAC7B;AACA;ACXO,SAAS,sBAAA,CACd,UAAA,EACA,gBAAA,EACyB;AACzB,EAAA,OAAO,gBAAA,CAAiB,MAAA,CAAO,CAAC,KAAA,EAAA,GAAiC;AAC/D,IAAA,OAAO,CAAC,UAAA,CAAW,IAAA,CAAK,CAAC,MAAA,EAAA,GAAkC;AACzD,MAAA,GAAA,CAAI,KAAA,CAAM,KAAA,GAAQ,MAAA,CAAO,IAAA,EAAM;AAC7B,QAAA,OAAO,KAAA,CAAM,KAAA,IAAS,MAAA,CAAO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d,EAAA;AAEqB,EAAA;AACF,IAAA;AACI,MAAA;AACL,IAAA;AACF,MAAA;AACd,IAAA;AAEO,IAAA;AACT,EAAA;AAEyB,EAAA;AACN,IAAA;AACI,MAAA;AACL,IAAA;AACF,MAAA;AACd,IAAA;AAEO,IAAA;AACT,EAAA;AAEyC,EAAA;AACrB,IAAA;AACI,IAAA;AACL,IAAA;AACF,MAAA;AACf,IAAA;AAEO,IAAA;AACT,EAAA;AACF;AAEO;AAMgB,EAAA;AACF,IAAA;AACI,MAAA;AACD,IAAA;AACF,MAAA;AAClB,IAAA;AAEO,IAAA;AACT,EAAA;AAEyB,EAAA;AACN,IAAA;AACI,MAAA;AAEV,IAAA;AAGO,MAAA;AAClB,IAAA;AAEO,IAAA;AACT,EAAA;AACF;AVuQyB;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-4EWSCVWC.cjs","sourcesContent":[null,"import * as RMOAS 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: RMOAS.ParameterObject[],\n commonParameters: RMOAS.ParameterObject[],\n): RMOAS.ParameterObject[] {\n return commonParameters.filter((param: RMOAS.ParameterObject) => {\n return !parameters.find((param2: RMOAS.ParameterObject) => {\n if (param.name && param2.name) {\n return param.name === param2.name && param.in === param2.in;\n } else if (RMOAS.isRef(param) && RMOAS.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 * as RMOAS from '../types.js';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\nimport memoize from 'memoizee';\n\nimport { objectify, usesPolymorphism, isFunc, normalizeArray, deeplyStripKey } from './utils.js';\n\nconst sampleDefaults = (genericSample: boolean | number | string) => {\n return (schema: RMOAS.SchemaObject): typeof genericSample =>\n typeof schema.default === typeof genericSample ? schema.default : genericSample;\n};\n\nconst primitives: Record<string, (arg: RMOAS.SchemaObject | void) => 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: RMOAS.SchemaObject) => {\n schema = objectify(schema);\n const { format } = schema;\n let { type } = schema;\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(schema);\n }\n\n return `Unknown Type: ${schema.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: RMOAS.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 (error) {\n return undefined;\n }\n } else if (hasPolymorphism) {\n const samples = (objectifySchema[hasPolymorphism] as RMOAS.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: 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 // eslint-disable-next-line no-restricted-syntax\n for (const name in props) {\n if (props[name] && props[name].deprecated) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (props[name] && props[name].readOnly && !includeReadOnly) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (props[name] && props[name].writeOnly && !includeWriteOnly) {\n // eslint-disable-next-line no-continue\n continue;\n }\n\n if (props[name].examples?.length) {\n obj[name] = props[name].examples[0];\n // eslint-disable-next-line no-continue\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: RMOAS.SchemaObject) => sampleFromSchema(i, opts));\n }\n\n if (Array.isArray(items.oneOf)) {\n return items.oneOf.map((i: RMOAS.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\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 * as RMOAS from '../types.js';\n\nimport { isObject } from '../lib/helpers.js';\n\nexport function usesPolymorphism(schema: RMOAS.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// eslint-disable-next-line @typescript-eslint/no-unsafe-function-type\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, // eslint-disable-line @typescript-eslint/no-unused-vars\n): RMOAS.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, RMOAS.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 * as RMOAS 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: RMOAS.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 = key;\n let description;\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(Boolean) as MediaTypeExample[];\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 // eslint-disable-next-line try-catch-failsafe/json-parse\n value: sampleFromSchema(JSON.parse(JSON.stringify(mediaTypeObject.schema)), opts),\n },\n ];\n }\n }\n\n return [];\n}\n","import type { MediaTypeExample } from './get-mediatype-examples.js';\nimport type * as RMOAS from '../../types.js';\n\nimport { isRef } from '../../types.js';\n\nimport { getMediaTypeExamples } from './get-mediatype-examples.js';\n\nexport type ResponseExamples = {\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: RMOAS.OperationObject) {\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 (isRef(response)) {\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 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(Boolean) as ResponseExamples;\n}\n","import type { ResponseExamples } from './get-response-examples.js';\nimport type * as RMOAS from '../../types.js';\n\nimport { getResponseExamples } from './get-response-examples.js';\n\nexport type CallbackExamples = {\n example: ResponseExamples;\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: RMOAS.OperationObject): CallbackExamples {\n const ret: CallbackExamples = [];\n\n // spreads the contents of the map for each callback so there's not nested arrays returned\n return ret.concat(\n ...Object.keys(operation.callbacks || {}).map(identifier => {\n const callback = operation.callbacks[identifier] as RMOAS.CallbackObject;\n\n // spreads the contents again so there's not nested arrays returned\n return []\n .concat(\n ...Object.keys(callback).map(expression => {\n return Object.keys(callback[expression]).map(method => {\n const pathItem = callback[expression] as Record<string, RMOAS.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 .filter(Boolean);\n }),\n );\n}\n","import type { MediaTypeExample } from './get-mediatype-examples.js';\nimport type * as RMOAS from '../../types.js';\nimport type { Operation } from '../index.js';\nimport type { OpenAPIV3 } from 'openapi-types';\n\nimport { getExtension, type Extensions } from '../../extensions.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?: (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?: RMOAS.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;\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(sample: Extensions['code-samples'][number], count: Record<string, number>): 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 (groups[sample.correspondingExample]?.customCodeSamples?.length) {\n groups[sample.correspondingExample].customCodeSamples.push({ ...sample, name, originalIndex: i });\n } else if (sample.correspondingExample) {\n groups[sample.correspondingExample] = {\n name,\n customCodeSamples: [{ ...sample, name, originalIndex: i }],\n };\n }\n\n // 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]: [string, OpenAPIV3.ExampleObject]) => {\n groups[exampleKey] = {\n ...groups[exampleKey],\n name: groups[exampleKey]?.name || paramExample.summary,\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,\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 { MediaTypeExample } from './get-mediatype-examples.js';\nimport type * as RMOAS from '../../types.js';\n\nimport { getMediaTypeExamples } from './get-mediatype-examples.js';\n\nexport type RequestBodyExamples = {\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: RMOAS.OperationObject): RequestBodyExamples {\n // `requestBody` will never have `$ref` pointers here so we need to work around the type that we\n // have from `RMOAS.OperationObject`.\n const requestBody = operation.requestBody as RMOAS.RequestBodyObject;\n if (!requestBody || !requestBody.content) {\n return [];\n }\n\n return Object.keys(requestBody.content || {})\n .map(mediaType => {\n const mediaTypeObject = requestBody.content[mediaType];\n const examples = getMediaTypeExamples(mediaType, mediaTypeObject, {\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(x => x !== false);\n}\n","import type {\n ComponentsObject,\n MediaTypeObject,\n OASDocument,\n ResponseObject,\n SchemaObject,\n HeaderObject,\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 { toJSONSchema, getSchemaVersionString } from '../../lib/openapi-to-json-schema.js';\n\ninterface 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 headers = response.headers;\n\n const headersSchema: SchemaObject = {\n type: 'object',\n properties: {},\n };\n\n Object.keys(headers).forEach(key => {\n if (headers[key] && (headers[key] as HeaderObject).schema) {\n const header: HeaderObject = headers[key] as HeaderObject;\n\n // TODO: Response headers are essentially parameters in OAS\n // This means they can have content instead of schema.\n // We should probably support that in the future\n headersSchema.properties[key] = toJSONSchema(header.schema, {\n addEnumsToDescriptions: true,\n transformer: opts.transformer,\n });\n\n if (header.description) {\n (headersSchema.properties[key] as HeaderObject).description = header.description;\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 */\nexport function getResponseAsJSONSchema(\n operation: Operation,\n api: OASDocument,\n statusCode: number | string,\n opts?: {\n includeDiscriminatorMappingRefs?: boolean;\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 */\n function getPreferredSchema(content: Record<string, MediaTypeObject>) {\n if (!content) {\n return null;\n }\n\n const contentTypes = Object.keys(content);\n if (!contentTypes.length) {\n return null;\n }\n\n // eslint-disable-next-line no-plusplus\n for (let i = 0; i < contentTypes.length; i++) {\n if (isJSON(contentTypes[i])) {\n return toJSONSchema(cloneObject(content[contentTypes[i]].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 return toJSONSchema(cloneObject(content[contentType].schema), {\n addEnumsToDescriptions: true,\n refLogger,\n transformer: opts.transformer,\n });\n }\n\n const foundSchema = getPreferredSchema((response as ResponseObject).content);\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) = api.components 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 { Extensions } from '../extensions.js';\nimport type { SecurityType } from '../types.js';\nimport type { CallbackExamples } from './lib/get-callback-examples.js';\nimport type { getParametersAsJSONSchemaOptions, SchemaWrapper } from './lib/get-parameters-as-json-schema.js';\nimport type { RequestBodyExamples } from './lib/get-requestbody-examples.js';\nimport type { ResponseExamples } from './lib/get-response-examples.js';\nimport type { OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\nimport findSchemaDefinition from '../lib/find-schema-definition.js';\nimport matchesMimeType from '../lib/matches-mimetype.js';\nimport * as RMOAS from '../types.js';\nimport { supportedMethods } from '../utils.js';\n\nimport { dedupeCommonParameters } from './lib/dedupe-common-parameters.js';\nimport { getCallbackExamples } from './lib/get-callback-examples.js';\nimport { getExampleGroups, type ExampleGroups } 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';\n\nexport class Operation {\n /**\n * Schema of the operation from the API Definition.\n */\n schema: RMOAS.OperationObject;\n\n /**\n * OpenAPI API Definition that this operation originated from.\n */\n api: RMOAS.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: RMOAS.HttpMethods;\n\n /**\n * The primary Content Type that this operation accepts.\n */\n contentType: string;\n\n /**\n * An object with groups of all example definitions (body/header/query/path/response/etc.)\n */\n exampleGroups: ExampleGroups;\n\n /**\n * Request body examples for this operation.\n */\n requestBodyExamples: RequestBodyExamples;\n\n /**\n * Response examples for this operation.\n */\n responseExamples: ResponseExamples;\n\n /**\n * Callback examples for this operation (if it has callbacks).\n */\n callbackExamples: CallbackExamples;\n\n /**\n * Flattened out arrays of both request and response headers that are utilized on this operation.\n */\n headers: {\n request: string[];\n response: string[];\n };\n\n constructor(api: RMOAS.OASDocument, path: string, method: RMOAS.HttpMethods, operation: RMOAS.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\n getSummary(): string {\n if (this.schema?.summary && typeof this.schema.summary === 'string') {\n return this.schema.summary;\n } else if (this.api.paths[this.path].summary && typeof this.api.paths[this.path].summary === 'string') {\n return this.api.paths[this.path].summary;\n }\n\n return undefined;\n }\n\n getDescription(): string {\n if (this.schema?.description && typeof this.schema.description === 'string') {\n return this.schema.description;\n } else if (this.api.paths[this.path].description && typeof this.api.paths[this.path].description === 'string') {\n return this.api.paths[this.path].description;\n }\n\n return undefined;\n }\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 ('$ref' in this.schema.requestBody) {\n this.schema.requestBody = findSchemaDefinition(this.schema.requestBody.$ref, this.api);\n }\n\n if ('content' in this.schema.requestBody) {\n types = Object.keys(this.schema.requestBody.content);\n }\n }\n\n this.contentType = 'application/json';\n if (types && 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 isFormUrlEncoded(): boolean {\n return matchesMimeType.formUrlEncoded(this.getContentType());\n }\n\n isMultipart(): boolean {\n return matchesMimeType.multipart(this.getContentType());\n }\n\n isJson(): boolean {\n return matchesMimeType.json(this.getContentType());\n }\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 */\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 */\n getSecurity(): RMOAS.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: RMOAS.KeyedSecuritySchemeObject; type: SecurityType })[] | false)[] {\n const securityRequirements = this.getSecurity();\n\n return securityRequirements.map(requirement => {\n let keys;\n try {\n keys = Object.keys(requirement);\n } catch (e) {\n return false;\n }\n\n const keysWithTypes = keys.map(key => {\n let security;\n try {\n // Remove the reference type, because we know this will be dereferenced\n security = this.api.components.securitySchemes[key] as RMOAS.KeyedSecuritySchemeObject;\n } catch (e) {\n return false;\n }\n\n if (!security) return false;\n\n let type: SecurityType = 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, RMOAS.KeyedSecuritySchemeObject[]> {\n const securitiesWithTypes = this.getSecurityWithTypes();\n\n return securitiesWithTypes.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 different scope requirements),\n // including the `_requirements` in this object would be misleading since we dedupe the security schemes.\n // eslint-disable-next-line no-underscore-dangle\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, RMOAS.KeyedSecuritySchemeObject[]>,\n );\n }\n\n getHeaders(): Operation['headers'] {\n const security = this.prepareSecurity();\n if (security.Header) {\n this.headers.request = (security.Header as OpenAPIV3_1.ApiKeySecurityScheme[]).map(h => {\n return h.name;\n });\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 // Remove the reference object because we will have already dereferenced.\n (this.schema.parameters as OpenAPIV3_1.ParameterObject[] | OpenAPIV3.ParameterObject[])\n .map(p => {\n if (p.in && p.in === 'header') return p.name;\n return undefined;\n })\n .filter(p => p),\n );\n }\n\n if (this.schema.responses) {\n this.headers.response = Object.keys(this.schema.responses)\n // Remove the reference object because we will have already dereferenced.\n .filter(r => (this.schema.responses[r] as RMOAS.ResponseObject).headers)\n .map(r =>\n // Remove the reference object because we will have already dereferenced.\n Object.keys((this.schema.responses[r] as RMOAS.ResponseObject).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 if (\n (this.schema.requestBody as RMOAS.RequestBodyObject).content &&\n Object.keys((this.schema.requestBody as RMOAS.RequestBodyObject).content)\n ) {\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(\n response => !!(this.schema.responses[response] as RMOAS.ResponseObject).content,\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 the operation has an operation present in its schema. Note that if one is present\n * in the schema but is an empty string then this will return false.\n *\n */\n hasOperationId(): boolean {\n return Boolean('operationId' in this.schema && this.schema.operationId.length);\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 */\n getOperationId(\n opts: {\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 {opts.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 ): 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 let operationId;\n if (this.hasOperationId()) {\n operationId = this.schema.operationId;\n } else {\n operationId = sanitize(this.path).toLowerCase();\n }\n\n const method = this.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 (!this.hasOperationId()) {\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 (this.hasOperationId()) {\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(method)) {\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 (this.hasOperationId()) {\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 `${method}${operationId}`;\n } else if (this.hasOperationId()) {\n return operationId;\n }\n\n return `${method}_${operationId}`;\n }\n\n /**\n * Return an array of all tags, and their metadata, that exist on this operation.\n *\n */\n getTags(): RMOAS.TagObject[] {\n if (!('tags' in this.schema)) {\n return [];\n }\n\n const oasTagMap: Map<string, RMOAS.TagObject> = new Map();\n if ('tags' in this.api) {\n this.api.tags.forEach((tag: RMOAS.TagObject) => {\n oasTagMap.set(tag.name, tag);\n });\n }\n\n const oasTags = Object.fromEntries(oasTagMap);\n\n const tags: RMOAS.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 */\n isDeprecated(): boolean {\n return '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 */\n getParameters(): RMOAS.ParameterObject[] {\n let parameters = (this.schema?.parameters || []) as RMOAS.ParameterObject[];\n const commonParams = (this.api?.paths?.[this.path]?.parameters || []) as RMOAS.ParameterObject[];\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 */\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[] {\n return getParametersAsJSONSchema(this, this.api, {\n includeDiscriminatorMappingRefs: true,\n transformer: (s: RMOAS.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 */\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 * 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: RMOAS.SchemaObject) => RMOAS.SchemaObject;\n } = {},\n ): RMOAS.SchemaObject {\n return getResponseAsJSONSchema(this, this.api, statusCode, {\n includeDiscriminatorMappingRefs: true,\n transformer: (s: RMOAS.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 */\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 (RMOAS.isRef(requestBody)) {\n // If the request body is still a `$ref` pointer we should return false because this library\n // assumes that you've run dereferencing beforehand.\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 */\n hasRequiredRequestBody(): boolean {\n if (!this.hasRequestBody()) {\n return false;\n }\n\n const requestBody = this.schema.requestBody;\n if (RMOAS.isRef(requestBody)) {\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 return !!this.getParametersAsJSONSchema()\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): RMOAS.MediaTypeObject | false | [string, RMOAS.MediaTypeObject, ...string[]] {\n if (!this.hasRequestBody()) {\n return false;\n }\n\n const requestBody = this.schema.requestBody;\n if (RMOAS.isRef(requestBody)) {\n // If the request body is still a `$ref` pointer we should return false because this library\n // assumes that you've run dereferencing beforehand.\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;\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 */\n getRequestBodyExamples(): RequestBodyExamples {\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 */\n getResponseByStatusCode(statusCode: number | string): RMOAS.ResponseObject | boolean {\n if (!this.schema.responses) {\n return false;\n }\n\n if (typeof this.schema.responses[statusCode] === 'undefined') {\n return false;\n }\n\n const response = this.schema.responses[statusCode];\n\n if (RMOAS.isRef(response)) {\n return false;\n }\n\n // Remove the reference from the type, because it will already be dereferenced.\n return response;\n }\n\n /**\n * Retrieve an array of response examples that this operation has.\n *\n */\n getResponseExamples(): ResponseExamples {\n if (this.responseExamples) {\n return this.responseExamples;\n }\n\n // @todo Remove this `as` once we convert getResponseExamples\n this.responseExamples = getResponseExamples(this.schema) as ResponseExamples;\n return this.responseExamples;\n }\n\n /**\n * Determine if the operation has callbacks.\n *\n */\n hasCallbacks(): boolean {\n return !!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: RMOAS.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 callback = this.schema.callbacks[identifier]\n ? (((this.schema.callbacks as Record<string, RMOAS.CallbackObject>)[identifier] as RMOAS.CallbackObject)[\n expression\n ] as RMOAS.PathItemObject)\n : false;\n\n if (!callback || !callback[method]) return false;\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 */\n getCallbacks(): (Callback | false)[] | false {\n const callbackOperations: (Callback | false)[] = [];\n if (!this.hasCallbacks()) return false;\n\n Object.keys(this.schema.callbacks).forEach(callback => {\n Object.keys(this.schema.callbacks[callback]).forEach(expression => {\n const cb = this.schema.callbacks[callback];\n\n if (!RMOAS.isRef(cb)) {\n const exp = cb[expression];\n\n if (!RMOAS.isRef(exp)) {\n Object.keys(exp).forEach((method: RMOAS.HttpMethods) => {\n if (!supportedMethods.includes(method)) return;\n\n callbackOperations.push(this.getCallback(callback, expression, method));\n });\n }\n }\n });\n });\n\n return callbackOperations;\n }\n\n /**\n * Retrieve an array of callback examples that this operation has.\n *\n */\n getCallbackExamples(): CallbackExamples {\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\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: RMOAS.PathItemObject;\n\n constructor(\n oas: RMOAS.OASDocument,\n path: string,\n method: RMOAS.HttpMethods,\n operation: RMOAS.OperationObject,\n identifier: string,\n parentPathItem: RMOAS.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 {\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 {\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(): RMOAS.ParameterObject[] {\n let parameters = (this.schema?.parameters || []) as RMOAS.ParameterObject[];\n const commonParams = (this.parentSchema.parameters || []) as RMOAS.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: RMOAS.OAS31Document;\n\n getSummary(): string {\n if (this.schema?.summary && typeof this.schema.summary === 'string') {\n return this.schema.summary;\n } else if (this.api.webhooks[this.path].summary && typeof this.api.webhooks[this.path].summary === 'string') {\n return this.api.webhooks[this.path].summary;\n }\n\n return undefined;\n }\n\n getDescription(): string {\n if (this.schema?.description && typeof this.schema.description === 'string') {\n return this.schema.description;\n } else if (\n this.api.webhooks[this.path].description &&\n typeof this.api.webhooks[this.path].description === 'string'\n ) {\n return this.api.webhooks[this.path].description;\n }\n\n return undefined;\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/lib/clone-object.ts","../src/lib/helpers.ts","../src/lib/matches-mimetype.ts","../src/lib/openapi-to-json-schema.ts","../src/operation/lib/get-parameters-as-json-schema.ts"],"sourcesContent":["export default function cloneObject<T>(obj: T): T {\n if (typeof obj === 'undefined') {\n return undefined;\n }\n\n // eslint-disable-next-line try-catch-failsafe/json-parse\n return JSON.parse(JSON.stringify(obj));\n}\n","import type { SchemaObject } from '../types.js';\n\nexport function hasSchemaType(schema: SchemaObject, discriminator: 'array' | 'object'): boolean {\n if (Array.isArray(schema.type)) {\n return schema.type.includes(discriminator);\n }\n\n return schema.type === discriminator;\n}\n\nexport function isObject(val: unknown): val is Record<string, unknown> {\n return typeof val === 'object' && val !== null && !Array.isArray(val);\n}\n\nexport function isPrimitive(val: unknown): val is boolean | number | string {\n return typeof val === 'string' || typeof val === 'number' || typeof val === 'boolean';\n}\n","function matchesMediaType(types: string[], mediaType: string): boolean {\n return types.some(type => {\n return mediaType.indexOf(type) > -1;\n });\n}\n\nexport default {\n formUrlEncoded: (mimeType: string): boolean => {\n return matchesMediaType(['application/x-www-form-urlencoded'], mimeType);\n },\n\n json: (contentType: string): boolean => {\n return matchesMediaType(\n ['application/json', 'application/x-json', 'text/json', 'text/x-json', '+json'],\n contentType,\n );\n },\n\n multipart: (contentType: string): boolean => {\n return matchesMediaType(\n ['multipart/mixed', 'multipart/related', 'multipart/form-data', 'multipart/alternative'],\n contentType,\n );\n },\n\n wildcard: (contentType: string): boolean => {\n return contentType === '*/*';\n },\n\n xml: (contentType: string): boolean => {\n return matchesMediaType(\n [\n 'application/xml',\n 'application/xml-external-parsed-entity',\n 'application/xml-dtd',\n 'text/xml',\n 'text/xml-external-parsed-entity',\n '+xml',\n ],\n contentType,\n );\n },\n};\n","/* eslint-disable no-continue */\nimport type { SchemaObject } from '../types.js';\nimport type { JSONSchema7TypeName } from 'json-schema';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\nimport jsonpointer from 'jsonpointer';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport * as RMOAS from '../types.js';\n\nimport { hasSchemaType, isObject, isPrimitive } from './helpers.js';\n\n/**\n * This list has been pulled from `openapi-schema-to-json-schema` but been slightly modified to fit\n * within the constraints in which ReadMe uses the output from this library in schema form\n * rendering as while properties like `readOnly` aren't represented within JSON Schema, we support\n * it within that library's handling of OpenAPI-friendly JSON Schema.\n *\n * @see {@link https://github.com/openapi-contrib/openapi-schema-to-json-schema/blob/main/src/consts.ts}\n */\nconst UNSUPPORTED_SCHEMA_PROPS = [\n 'example', // OpenAPI supports `example` but we're mapping it to `examples` in this library.\n 'externalDocs',\n 'xml',\n] as const;\n\nexport interface toJSONSchemaOptions {\n /**\n * Whether or not to extend descriptions with a list of any present enums.\n */\n addEnumsToDescriptions?: boolean;\n\n /**\n * Current location within the schema -- this is a JSON pointer.\n */\n currentLocation?: string;\n\n /**\n * Object containing a global set of defaults that we should apply to schemas that match it.\n */\n globalDefaults?: Record<string, unknown>;\n\n /**\n * If you wish to hide properties that are marked as being `readOnly`.\n */\n hideReadOnlyProperties?: boolean;\n\n /**\n * If you wish to hide properties that are marked as being `writeOnly`.\n */\n hideWriteOnlyProperties?: boolean;\n\n /**\n * Is this schema the child of a polymorphic `allOf` schema?\n */\n isPolymorphicAllOfChild?: boolean;\n\n /**\n * Array of parent `default` schemas to utilize when attempting to path together schema defaults.\n */\n prevDefaultSchemas?: RMOAS.SchemaObject[];\n\n /**\n * Array of parent `example` schemas to utilize when attempting to path together schema examples.\n */\n prevExampleSchemas?: RMOAS.SchemaObject[];\n\n /**\n * A function that's called anytime a (circular) `$ref` is found.\n */\n refLogger?: (ref: string, type: 'discriminator' | 'ref') => void;\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: RMOAS.SchemaObject) => RMOAS.SchemaObject;\n}\n\n/**\n * Encode a string to be used as a JSON pointer.\n *\n * @see {@link https://tools.ietf.org/html/rfc6901}\n * @param str String to encode into string that can be used as a JSON pointer.\n */\nfunction encodePointer(str: string) {\n return str.replace('~', '~0').replace('/', '~1');\n}\n\nexport function getSchemaVersionString(schema: RMOAS.SchemaObject, api: RMOAS.OASDocument): string {\n // If we're not on version 3.1.0, we always fall back to the default schema version for pre-3.1.0.\n if (!RMOAS.isOAS31(api)) {\n // This should remain as an HTTP url, not HTTPS.\n return 'http://json-schema.org/draft-04/schema#';\n }\n\n /**\n * If the schema indicates the version, prefer that.\n *\n * We use `as` here because the schema *should* be an OAS 3.1 schema due to the `isOAS31` check\n * above.\n */\n if ((schema as OpenAPIV3_1.SchemaObject).$schema) {\n return (schema as OpenAPIV3_1.SchemaObject).$schema;\n }\n\n // If the user defined a global schema version on their OAS document, prefer that.\n if (api.jsonSchemaDialect) {\n return api.jsonSchemaDialect;\n }\n\n return 'https://json-schema.org/draft/2020-12/schema#';\n}\n\nfunction isPolymorphicSchema(schema: RMOAS.SchemaObject): boolean {\n return 'allOf' in schema || 'anyOf' in schema || 'oneOf' in schema;\n}\n\nfunction isRequestBodySchema(schema: unknown): schema is RMOAS.RequestBodyObject {\n return 'content' in (schema as RMOAS.RequestBodyObject);\n}\n\n/**\n * Given a JSON pointer, a type of property to look for, and an array of schemas do a reverse\n * search through them until we find the JSON pointer, or part of it, within the array.\n *\n * This function will allow you to take a pointer like `/tags/name` and return back `buster` from\n * the following array:\n *\n * ```\n * [\n * {\n * example: {id: 20}\n * },\n * {\n * examples: {\n * distinctName: {\n * tags: {name: 'buster'}\n * }\n * }\n * }\n * ]\n * ```\n *\n * As with most things however, this is not without its quirks! If a deeply nested property shares\n * the same name as an example that's further up the stack (like `tags.id` and an example for `id`),\n * there's a chance that it'll be misidentified as having an example and receive the wrong value.\n *\n * That said, any example is usually better than no example though, so while it's quirky behavior\n * it shouldn't raise immediate cause for alarm.\n *\n * @see {@link https://tools.ietf.org/html/rfc6901}\n * @param property Specific type of schema property to look for a value for.\n * @param pointer JSON pointer to search for an example for.\n * @param schemas Array of previous schemas we've found relating to this pointer.\n */\nfunction searchForValueByPropAndPointer(\n property: 'default' | 'example',\n pointer: string,\n schemas: toJSONSchemaOptions['prevDefaultSchemas'] | toJSONSchemaOptions['prevExampleSchemas'] = [],\n) {\n if (!schemas.length || !pointer.length) {\n return undefined;\n }\n\n const locSplit = pointer.split('/').filter(Boolean).reverse();\n const pointers = [];\n\n let point = '';\n for (let i = 0; i < locSplit.length; i += 1) {\n point = `/${locSplit[i]}${point}`;\n pointers.push(point);\n }\n\n let foundValue;\n const rev = [...schemas].reverse();\n\n for (let i = 0; i < pointers.length; i += 1) {\n for (let ii = 0; ii < rev.length; ii += 1) {\n let schema = rev[ii];\n\n if (property === 'example') {\n if ('example' in schema) {\n schema = schema.example;\n } else {\n if (!Array.isArray(schema.examples) || !schema.examples.length) {\n continue;\n }\n\n // Prevent us from crashing if `examples` is a completely empty object.\n schema = [...schema.examples].shift();\n }\n } else {\n schema = schema.default;\n }\n\n try {\n foundValue = jsonpointer.get(schema, pointers[i]);\n } catch (err) {\n // If the schema we're looking at is `{obj: null}` and our pointer is `/obj/propertyName`\n // `jsonpointer` will throw an error. If that happens, we should silently catch and toss it\n // and return no example.\n }\n\n if (foundValue !== undefined) {\n break;\n }\n }\n\n if (foundValue !== undefined) {\n break;\n }\n }\n\n return foundValue;\n}\n\n/**\n * Given an OpenAPI-flavored JSON Schema, make an effort to modify it so it's shaped more towards\n * stock JSON Schema.\n *\n * Why do this?\n *\n * 1. OpenAPI 3.0.x supports its own flavor of JSON Schema that isn't fully compatible with most\n * JSON Schema tooling (like `@readme/oas-form` or `@rjsf/core`).\n * 2. While validating an OpenAPI definition will prevent corrupted or improper schemas from\n * occuring, we have a lot of legacy schemas in ReadMe that were ingested before we had proper\n * validation in place, and as a result have some API definitions that will not pass validation\n * right now. In addition to reshaping OAS-JSON Schema into JSON Schema this library will also\n * fix these improper schemas: things like `type: object` having `items` instead of `properties`,\n * or `type: array` missing `items`.\n * 3. To ease the burden of polymorphic handling on our form rendering engine we make an attempt\n * to merge `allOf` schemas here.\n * 4. Additionally due to OpenAPI 3.0.x not supporting JSON Schema, in order to support the\n * `example` keyword that OAS supports, we need to do some work in here to remap it into\n * `examples`. However, since all we care about in respect to examples for usage within\n * `@readme/oas-form`, we're only retaining primitives. This *slightly* deviates from JSON\n * Schema in that JSON Schema allows for any schema to be an example, but since\n * `@readme/oas-form` can only actually **render** primitives, that's what we're retaining.\n * 5. Though OpenAPI 3.1 does support full JSON Schema, this library should be able to handle it\n * without any problems.\n *\n * And why use this over `@openapi-contrib/openapi-schema-to-json-schema`? Fortunately and\n * unfortunately we've got a lot of API definitions in our database that aren't currently valid so\n * we need to have a lot of bespoke handling for odd quirks, typos, and missing declarations that\n * might be present.\n *\n * @todo add support for `schema: false` and `not` cases.\n * @see {@link https://json-schema.org/draft/2019-09/json-schema-validation.html}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#schema-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#schema-object}\n * @param data OpenAPI Schema Object to convert to pure JSON Schema.\n */\nexport function toJSONSchema(data: RMOAS.SchemaObject | boolean, opts: toJSONSchemaOptions = {}): RMOAS.SchemaObject {\n let schema = data === true ? {} : { ...data };\n const schemaAdditionalProperties = RMOAS.isSchema(schema) ? schema.additionalProperties : null;\n\n const {\n addEnumsToDescriptions,\n currentLocation,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n isPolymorphicAllOfChild,\n prevDefaultSchemas,\n prevExampleSchemas,\n refLogger,\n transformer,\n } = {\n addEnumsToDescriptions: false,\n currentLocation: '',\n globalDefaults: {},\n hideReadOnlyProperties: false,\n hideWriteOnlyProperties: false,\n isPolymorphicAllOfChild: false,\n prevDefaultSchemas: [] as toJSONSchemaOptions['prevDefaultSchemas'],\n prevExampleSchemas: [] as toJSONSchemaOptions['prevExampleSchemas'],\n refLogger: () => true,\n transformer: (s: RMOAS.SchemaObject) => s,\n ...opts,\n };\n\n // If this schema contains a `$ref`, it's circular and we shouldn't try to resolve it. Just\n // return and move along.\n if (RMOAS.isRef(schema)) {\n refLogger(schema.$ref, 'ref');\n\n return transformer({\n $ref: schema.$ref,\n });\n }\n\n // If we don't have a set type, but are dealing with an `anyOf`, `oneOf`, or `allOf`\n // representation let's run through them and make sure they're good.\n if (RMOAS.isSchema(schema, isPolymorphicAllOfChild)) {\n // If this is an `allOf` schema we should make an attempt to merge so as to ease the burden on\n // the tooling that ingests these schemas.\n if ('allOf' in schema && Array.isArray(schema.allOf)) {\n try {\n schema = mergeJSONSchemaAllOf(schema as RMOAS.JSONSchema, {\n ignoreAdditionalProperties: true,\n resolvers: {\n // `merge-json-schema-allof` by default takes the first `description` when you're\n // merging an `allOf` but because generally when you're merging two schemas together\n // with an `allOf` you want data in the subsequent schemas to be applied to the first\n // and `description` should be a part of that.\n description: (obj: string[]) => {\n return obj.slice(-1)[0];\n },\n\n // `merge-json-schema-allof` doesn't support merging enum arrays but since that's a\n // safe and simple operation as enums always contain primitives we can handle it\n // ourselves with a custom resolver.\n enum: (obj: unknown[]) => {\n let arr: unknown[] = [];\n obj.forEach(e => {\n arr = arr.concat(e);\n });\n\n return arr;\n },\n\n // for any unknown keywords (e.g., `example`, `format`, `x-readme-ref-name`),\n // we fallback to using the title resolver (which uses the first value found).\n // https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/src/index.js#L292\n // https://github.com/mokkabonna/json-schema-merge-allof/blob/ea2e48ee34415022de5a50c236eb4793a943ad11/README.md?plain=1#L147\n defaultResolver: mergeJSONSchemaAllOf.options.resolvers.title,\n } as unknown,\n }) as RMOAS.SchemaObject;\n } catch (e) {\n // If we can't merge the `allOf` for whatever reason (like if one item is a `string` and\n // the other is a `object`) then we should completely remove it from the schema and continue\n // with whatever we've got. Why? If we don't, any tooling that's ingesting this will need\n // to account for the incompatible `allOf` and it may be subject to more breakages than\n // just not having it present would be.\n const { ...schemaWithoutAllOf } = schema;\n schema = schemaWithoutAllOf as RMOAS.SchemaObject;\n delete schema.allOf;\n }\n\n // If after merging the `allOf` this schema still contains a `$ref` then it's circular and\n // we shouldn't do anything else.\n if (RMOAS.isRef(schema)) {\n refLogger(schema.$ref, 'ref');\n\n return transformer({\n $ref: schema.$ref,\n });\n }\n }\n\n ['anyOf', 'oneOf'].forEach((polyType: 'anyOf' | 'oneOf') => {\n if (polyType in schema && Array.isArray(schema[polyType])) {\n schema[polyType].forEach((item, idx) => {\n const polyOptions: toJSONSchemaOptions = {\n addEnumsToDescriptions,\n currentLocation: `${currentLocation}/${idx}`,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n isPolymorphicAllOfChild: false,\n prevDefaultSchemas,\n prevExampleSchemas,\n refLogger,\n transformer,\n };\n\n // When `properties` or `items` are present alongside a polymorphic schema instead of\n // letting whatever JSON Schema interpreter is handling these constructed schemas we can\n // guide its hand a bit by manually transforming it into an inferred `allOf` of the\n // `properties` + the polymorph schema.\n //\n // This `allOf` schema will be merged together when fed through `toJSONSchema`.\n if ('properties' in schema) {\n schema[polyType][idx] = toJSONSchema(\n { required: schema.required, allOf: [item, { properties: schema.properties }] } as RMOAS.SchemaObject,\n polyOptions,\n );\n } else if ('items' in schema) {\n schema[polyType][idx] = toJSONSchema(\n { allOf: [item, { items: schema.items }] } as RMOAS.SchemaObject,\n polyOptions,\n );\n } else {\n schema[polyType][idx] = toJSONSchema(item as RMOAS.SchemaObject, polyOptions);\n }\n\n // Ensure that we don't have any invalid `required` booleans lying around.\n if (\n isObject(schema[polyType][idx]) &&\n 'required' in (schema[polyType][idx] as SchemaObject) &&\n typeof (schema[polyType][idx] as SchemaObject).required === 'boolean'\n ) {\n delete (schema[polyType][idx] as SchemaObject).required;\n }\n });\n }\n });\n\n if ('discriminator' in schema) {\n if ('mapping' in schema.discriminator && typeof schema.discriminator.mapping === 'object') {\n // Discriminator mappings aren't written as traditional `$ref` pointers so in order to log\n // them to the supplied `refLogger`.\n const mapping = schema.discriminator.mapping;\n Object.keys(mapping).forEach(k => {\n refLogger(mapping[k], 'discriminator');\n });\n }\n }\n }\n\n // If this schema is malformed for some reason, let's do our best to repair it.\n if (!('type' in schema) && !isPolymorphicSchema(schema) && !isRequestBodySchema(schema)) {\n if ('properties' in schema) {\n schema.type = 'object';\n } else if ('items' in schema) {\n schema.type = 'array';\n } else {\n // If there's still no `type` on the schema we should leave it alone because we don't have a\n // great way to know if it's part of a nested schema that should, and couldn't be merged,\n // into another, or it's just purely malformed.\n //\n // Whatever tooling that ingests the generated schema should handle it however it needs to.\n }\n }\n\n if ('type' in schema) {\n // `nullable` isn't a thing in JSON Schema but it was in OpenAPI 3.0 so we should retain and\n // translate it into something that's compatible with JSON Schema.\n if ('nullable' in schema) {\n if (schema.nullable) {\n if (Array.isArray(schema.type)) {\n schema.type.push('null');\n } else if (schema.type !== null && schema.type !== 'null') {\n schema.type = [schema.type, 'null'];\n }\n }\n\n delete schema.nullable;\n }\n\n if (schema.type === null) {\n // `type: null` is possible in JSON Schema but we're translating it to a string version\n // so we don't need to worry about asserting nullish types in our implementations of this\n // generated schema.\n schema.type = 'null';\n } else if (Array.isArray(schema.type)) {\n if (schema.type.includes(null)) {\n schema.type[schema.type.indexOf(null)] = 'null';\n }\n\n schema.type = Array.from(new Set(schema.type));\n\n // We don't need `type: [<type>]` when we can just as easily make it `type: <type>`.\n if (schema.type.length === 1) {\n schema.type = schema.type.shift();\n } else if (schema.type.includes('array') || schema.type.includes('boolean') || schema.type.includes('object')) {\n // If we have a `null` type but there's only two types present then we can remove `null`\n // as an option and flag the whole schema as `nullable`.\n const isNullable = schema.type.includes('null');\n\n if (schema.type.length === 2 && isNullable) {\n // If this is `array | null` or `object | null` then we don't need to do anything.\n } else {\n // If this mixed type has non-primitives then we for convenience of our implementation\n // we're moving them into a `oneOf`.\n const nonPrimitives: any[] = [];\n\n // Because arrays, booleans, and objects are not compatible with any other schem type\n // other than null we're moving them into an isolated `oneOf`, and as such want to take\n // with it its specific properties that may be present on our current schema.\n Object.entries({\n // https://json-schema.org/understanding-json-schema/reference/array.html\n array: [\n 'additionalItems',\n 'contains',\n 'items',\n 'maxContains',\n 'maxItems',\n 'minContains',\n 'minItems',\n 'prefixItems',\n 'uniqueItems',\n ],\n\n // https://json-schema.org/understanding-json-schema/reference/boolean.html\n boolean: [\n // Booleans don't have any boolean-specific properties.\n ],\n\n // https://json-schema.org/understanding-json-schema/reference/object.html\n object: [\n 'additionalProperties',\n 'maxProperties',\n 'minProperties',\n 'nullable',\n 'patternProperties',\n 'properties',\n 'propertyNames',\n 'required',\n ],\n }).forEach(([typeKey, keywords]) => {\n if (!schema.type.includes(typeKey as JSONSchema7TypeName)) {\n return;\n }\n\n const reducedSchema: any = removeUndefinedObjects({\n type: isNullable ? [typeKey, 'null'] : typeKey,\n\n allowEmptyValue: (schema as any).allowEmptyValue ?? undefined,\n deprecated: schema.deprecated ?? undefined,\n description: schema.description ?? undefined,\n readOnly: schema.readOnly ?? undefined,\n title: schema.title ?? undefined,\n writeOnly: schema.writeOnly ?? undefined,\n });\n\n keywords.forEach((t: keyof SchemaObject) => {\n if (t in schema) {\n reducedSchema[t] = schema[t];\n delete schema[t];\n }\n });\n\n nonPrimitives.push(reducedSchema);\n });\n\n schema.type = schema.type.filter(t => t !== 'array' && t !== 'boolean' && t !== 'object');\n if (schema.type.length === 1) {\n schema.type = schema.type.shift();\n }\n\n // Because we may have encountered a fully mixed non-primitive type like `array | object`\n // we only want to retain the existing schema object if we still have types remaining\n // in it.\n if (schema.type.length > 1) {\n schema = { oneOf: [schema, ...nonPrimitives] };\n } else {\n schema = { oneOf: nonPrimitives };\n }\n }\n }\n }\n }\n\n if (RMOAS.isSchema(schema, isPolymorphicAllOfChild)) {\n if ('default' in schema && isObject(schema.default)) {\n prevDefaultSchemas.push({ default: schema.default });\n }\n\n // JSON Schema doesn't support OpenAPI-style examples so we need to reshape them a bit.\n if ('example' in schema) {\n // Only bother adding primitive examples.\n if (isPrimitive(schema.example)) {\n schema.examples = [schema.example];\n } else if (Array.isArray(schema.example)) {\n schema.examples = schema.example.filter(example => isPrimitive(example));\n if (!schema.examples.length) {\n delete schema.examples;\n }\n } else {\n prevExampleSchemas.push({ example: schema.example });\n }\n\n delete schema.example;\n } else if ('examples' in schema) {\n let reshapedExamples = false;\n if (typeof schema.examples === 'object' && !Array.isArray(schema.examples)) {\n const examples: unknown[] = [];\n Object.keys(schema.examples).forEach(name => {\n const example = schema.examples[name as unknown as number];\n if ('$ref' in example) {\n // no-op because any `$ref` example here after dereferencing is circular so we should\n // ignore it\n refLogger(example.$ref, 'ref');\n } else if ('value' in example) {\n if (isPrimitive(example.value)) {\n examples.push(example.value);\n reshapedExamples = true;\n } else if (Array.isArray(example.value) && isPrimitive(example.value[0])) {\n examples.push(example.value[0]);\n reshapedExamples = true;\n } else {\n // If this example is neither a primitive or an array we should dump it into the\n // `prevExampleSchemas` array because we might be able to extract an example from it\n // further downstream.\n prevExampleSchemas.push({\n example: example.value,\n });\n }\n }\n });\n\n if (examples.length) {\n reshapedExamples = true;\n schema.examples = examples;\n }\n } else if (Array.isArray(schema.examples) && isPrimitive(schema.examples[0])) {\n // We haven't reshaped `examples` here, but since it's in a state that's preferrable to us\n // let's keep it around.\n reshapedExamples = true;\n }\n\n if (!reshapedExamples) {\n delete schema.examples;\n }\n }\n\n // If we didn't have any immediately defined examples, let's search backwards and see if we can\n // find one. But as we're only looking for primitive example, only try to search for one if\n // we're dealing with a primitive schema.\n if (!hasSchemaType(schema, 'array') && !hasSchemaType(schema, 'object') && !schema.examples) {\n const foundExample = searchForValueByPropAndPointer('example', currentLocation, prevExampleSchemas);\n if (foundExample) {\n // We can only really deal with primitives, so only promote those as the found example if\n // it is.\n if (isPrimitive(foundExample) || (Array.isArray(foundExample) && isPrimitive(foundExample[0]))) {\n schema.examples = [foundExample];\n }\n }\n }\n\n if (hasSchemaType(schema, 'array')) {\n if ('items' in schema) {\n if (!Array.isArray(schema.items) && Object.keys(schema.items).length === 1 && RMOAS.isRef(schema.items)) {\n // `items` contains a `$ref`, so since it's circular we should do a no-op here and log\n // and ignore it.\n refLogger(schema.items.$ref, 'ref');\n } else if (schema.items !== true) {\n // Run through the arrays contents and clean them up.\n schema.items = toJSONSchema(schema.items as RMOAS.SchemaObject, {\n addEnumsToDescriptions,\n currentLocation: `${currentLocation}/0`,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n prevExampleSchemas,\n refLogger,\n transformer,\n });\n\n // If we have a non-array `required` entry in our `items` schema then it's invalid and we\n // should remove it. We only support non-array boolean `required` properties inside object\n // properties.\n if (isObject(schema.items) && 'required' in schema.items && !Array.isArray(schema.items.required)) {\n delete schema.items.required;\n }\n }\n } else if ('properties' in schema || 'additionalProperties' in schema) {\n // This is a fix to handle cases where someone may have typod `items` as `properties` on an\n // array. Since throwing a complete failure isn't ideal, we can see that they meant for the\n // type to be `object`, so we can do our best to shape the data into what they were\n // intending it to be.\n schema.type = 'object';\n } else {\n // This is a fix to handle cases where we have a malformed array with no `items` property\n // present.\n (schema as any).items = {};\n }\n } else if (hasSchemaType(schema, 'object')) {\n if ('properties' in schema) {\n Object.keys(schema.properties).forEach(prop => {\n if (\n Array.isArray(schema.properties[prop]) ||\n (typeof schema.properties[prop] === 'object' && schema.properties[prop] !== null)\n ) {\n const newPropSchema = toJSONSchema(schema.properties[prop] as RMOAS.SchemaObject, {\n addEnumsToDescriptions,\n currentLocation: `${currentLocation}/${encodePointer(prop)}`,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n prevDefaultSchemas,\n prevExampleSchemas,\n refLogger,\n transformer,\n });\n\n // If this property is read or write only then we should fully hide it from its parent schema.\n let propShouldBeUpdated = true;\n if ((hideReadOnlyProperties || hideWriteOnlyProperties) && !Object.keys(newPropSchema).length) {\n // We should only delete this schema if it wasn't already empty though. We do this\n // because we (un)fortunately have handling in our API Explorer form system for\n // schemas that are devoid of any `type` declaration.\n if (Object.keys(schema.properties[prop]).length > 0) {\n delete schema.properties[prop];\n propShouldBeUpdated = false;\n }\n }\n\n if (propShouldBeUpdated) {\n schema.properties[prop] = newPropSchema;\n\n /**\n * JSON Schema does not have any support for `required: <boolean>` but because some\n * of our users do this, and it does not throw OpenAPI validation errors thanks to\n * some extremely loose typings around `schema` in the official JSON Schema\n * definitions that the OAI offers, we're opting to support these users and upgrade\n * their invalid `required` definitions into ones that our tooling can interpret.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/schemas/v3.1/schema.json#L1114-L1121}\n */\n if (\n isObject(newPropSchema) &&\n 'required' in newPropSchema &&\n typeof newPropSchema.required === 'boolean' &&\n newPropSchema.required === true\n ) {\n if ('required' in schema && Array.isArray(schema.required)) {\n schema.required.push(prop);\n } else {\n schema.required = [prop];\n }\n\n delete (schema.properties[prop] as SchemaObject).required;\n }\n }\n }\n });\n\n // If we want to hide all readOnly or writeOnly properites and it happens to be that this\n // object was comprised of only those then we shouldn't render this object.\n if (hideReadOnlyProperties || hideWriteOnlyProperties) {\n if (!Object.keys(schema.properties).length) {\n return transformer({});\n }\n }\n }\n\n if (typeof schemaAdditionalProperties === 'object' && schemaAdditionalProperties !== null) {\n // If this `additionalProperties` is completely empty and devoid of any sort of schema,\n // treat it as such. Otherwise let's recurse into it and see if we can sort it out.\n if (\n !('type' in schemaAdditionalProperties) &&\n !('$ref' in schemaAdditionalProperties) &&\n // We know it will be a schema object because it's dereferenced\n !isPolymorphicSchema(schemaAdditionalProperties as RMOAS.SchemaObject)\n ) {\n schema.additionalProperties = true;\n } else {\n // We know it will be a schema object because it's dereferenced\n schema.additionalProperties = toJSONSchema(schemaAdditionalProperties as RMOAS.SchemaObject, {\n addEnumsToDescriptions,\n currentLocation,\n globalDefaults,\n hideReadOnlyProperties,\n hideWriteOnlyProperties,\n prevDefaultSchemas,\n prevExampleSchemas,\n refLogger,\n transformer,\n });\n }\n }\n\n // Since neither `properties` and `additionalProperties` are actually required to be present\n // on an object, since we construct this schema work to build up a form we still need\n // *something* for the user to enter in for this object so we'll add back in\n // `additionalProperties` for that.\n if (!isPolymorphicSchema(schema) && !('properties' in schema) && !('additionalProperties' in schema)) {\n schema.additionalProperties = true;\n }\n }\n }\n\n /**\n * Users can pass in parameter defaults via JWT User Data. We're checking to see if the defaults\n * being passed in exist on endpoints via jsonpointer\n *\n * @see {@link https://docs.readme.com/docs/passing-data-to-jwt}\n */\n if (\n RMOAS.isSchema(schema, isPolymorphicAllOfChild) &&\n globalDefaults &&\n Object.keys(globalDefaults).length > 0 &&\n currentLocation\n ) {\n try {\n const userJwtDefault = jsonpointer.get(globalDefaults, currentLocation);\n if (userJwtDefault) {\n schema.default = userJwtDefault;\n }\n } catch (err) {\n // If jsonpointer returns an error, we won't show any defaults for that path.\n }\n }\n\n // Only add a default value if we actually have one.\n if ('default' in schema && typeof schema.default !== 'undefined') {\n if (hasSchemaType(schema, 'object')) {\n // Defaults for `object` and types have been dereferenced into their children schemas already\n // above so we don't need to preserve this default anymore.\n delete schema.default;\n } else if (\n ('allowEmptyValue' in schema && schema.allowEmptyValue && schema.default === '') ||\n schema.default !== ''\n ) {\n // If we have `allowEmptyValue` present, and the default is actually an empty string, let it\n // through as it's allowed.\n } else {\n // If the default is empty and we don't want to allowEmptyValue, we need to remove the\n // default.\n delete schema.default;\n }\n } else if (prevDefaultSchemas.length) {\n const foundDefault = searchForValueByPropAndPointer('default', currentLocation, prevDefaultSchemas);\n\n // We shouldn't ever set an object default out of the parent lineage tree defaults because\n // the contents of that object will be set on the schema that they're a part of. Setting\n // that object as well would result us in duplicating the defaults for that schema in two\n // places.\n if (\n isPrimitive(foundDefault) ||\n foundDefault === null ||\n (Array.isArray(foundDefault) && hasSchemaType(schema, 'array'))\n ) {\n schema.default = foundDefault;\n }\n }\n\n if (RMOAS.isSchema(schema, isPolymorphicAllOfChild) && 'enum' in schema && Array.isArray(schema.enum)) {\n // Enums should not have duplicated items as those will break AJV validation.\n // If we ever target ES6 for typescript we can drop this array.from.\n // https://stackoverflow.com/questions/33464504/using-spread-syntax-and-new-set-with-typescript/56870548\n schema.enum = Array.from(new Set(schema.enum));\n\n // If we want to add enums to descriptions (like in the case of response JSON Schema)\n // generation we need to convert them into a list of Markdown tilda'd strings. We're also\n // filtering away empty and falsy strings here because adding empty `` blocks to the description\n // will serve nobody any good.\n if (addEnumsToDescriptions) {\n const enums = schema.enum\n .filter(Boolean)\n .map(str => `\\`${str}\\``)\n .join(' ');\n\n if (enums.length) {\n if ('description' in schema) {\n schema.description += `\\n\\n${enums}`;\n } else {\n schema.description = enums;\n }\n }\n }\n }\n\n // Clean up any remaining `items` or `properties` schema fragments lying around if there's also\n // polymorphism present.\n if ('anyOf' in schema || 'oneOf' in schema) {\n if ('properties' in schema) {\n delete schema.properties;\n }\n\n if ('items' in schema) {\n delete schema.items;\n }\n }\n\n // Remove unsupported JSON Schema props.\n for (let i = 0; i < UNSUPPORTED_SCHEMA_PROPS.length; i += 1) {\n // Using the as here because the purpose is to delete keys we don't expect, so of course the\n // typing won't work\n delete (schema as Record<string, unknown>)[UNSUPPORTED_SCHEMA_PROPS[i]];\n }\n\n // If we want to hide any `readOnly` or `writeOnly` schemas, and this one is that, then we\n // shouldn't return anything.\n if (hideReadOnlyProperties && 'readOnly' in schema && schema.readOnly === true) {\n return {};\n } else if (hideWriteOnlyProperties && 'writeOnly' in schema && schema.writeOnly === true) {\n return {};\n }\n\n return transformer(schema);\n}\n","import type { toJSONSchemaOptions } from '../../lib/openapi-to-json-schema.js';\nimport type { ComponentsObject, ExampleObject, OASDocument, ParameterObject, SchemaObject } from '../../types.js';\nimport type { Operation } from '../index.js';\nimport type { OpenAPIV3_1 } from 'openapi-types';\n\nimport { PARAMETER_ORDERING, getExtension } from '../../extensions.js';\nimport cloneObject from '../../lib/clone-object.js';\nimport { isPrimitive } from '../../lib/helpers.js';\nimport matchesMimetype from '../../lib/matches-mimetype.js';\nimport { toJSONSchema, getSchemaVersionString } from '../../lib/openapi-to-json-schema.js';\n\nexport interface SchemaWrapper {\n $schema?: string;\n deprecatedProps?: SchemaWrapper;\n description?: string;\n label?: string;\n schema: SchemaObject;\n type: string;\n}\n\n/**\n * The order of this object determines how they will be sorted in the compiled JSON Schema\n * representation.\n *\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#parameter-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#parameter-object}\n */\nexport const types: Record<keyof OASDocument, string> = {\n path: 'Path Params',\n query: 'Query Params',\n body: 'Body Params',\n cookie: 'Cookie Params',\n formData: 'Form Data',\n header: 'Headers',\n metadata: 'Metadata', // This a special type reserved for https://npm.im/api\n};\n\nexport interface getParametersAsJSONSchemaOptions {\n /**\n * Contains an object of user defined schema defaults.\n */\n globalDefaults?: Record<string, unknown>;\n\n /**\n * If you wish to hide properties that are marked as being `readOnly`.\n */\n hideReadOnlyProperties?: boolean;\n\n /**\n * If you wish to hide properties that are marked as being `writeOnly`.\n */\n hideWriteOnlyProperties?: boolean;\n\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 * If you want the output to be two objects: body (contains `body` and `formData` JSON\n * Schema) and metadata (contains `path`, `query`, `cookie`, and `header`).\n */\n mergeIntoBodyAndMetadata?: boolean;\n\n /**\n * If you wish to **not** split out deprecated properties into a separate `deprecatedProps`\n * object.\n */\n retainDeprecatedProperties?: boolean;\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\nexport function getParametersAsJSONSchema(\n operation: Operation,\n api: OASDocument,\n opts?: getParametersAsJSONSchemaOptions,\n): SchemaWrapper[] {\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 function getDeprecated(schema: SchemaObject, type: string) {\n // If we wish to retain deprecated properties then we shouldn't split them out into the\n // `deprecatedProps` object.\n if (opts.retainDeprecatedProperties) {\n return null;\n }\n\n // If there's no properties, bail\n if (!schema || !schema.properties) return null;\n\n // Clone the original schema so this doesn't interfere with it\n const deprecatedBody = cloneObject(schema);\n\n // Booleans are not valid for required in draft 4, 7 or 2020. Not sure why the typing thinks\n // they are.\n const requiredParams = (schema.required || []) as string[];\n\n // Find all top-level deprecated properties from the schema - required and readOnly params are\n // excluded.\n const allDeprecatedProps: Record<string, SchemaObject> = {};\n\n Object.keys(deprecatedBody.properties).forEach(key => {\n const deprecatedProp = deprecatedBody.properties[key] as SchemaObject;\n if (deprecatedProp.deprecated && !requiredParams.includes(key) && !deprecatedProp.readOnly) {\n allDeprecatedProps[key] = deprecatedProp;\n }\n });\n\n // We know this is the right type. todo: don't use as\n (deprecatedBody.properties as Record<string, SchemaObject>) = allDeprecatedProps;\n const deprecatedSchema = toJSONSchema(deprecatedBody, {\n globalDefaults: opts.globalDefaults,\n hideReadOnlyProperties: opts.hideReadOnlyProperties,\n hideWriteOnlyProperties: opts.hideWriteOnlyProperties,\n prevExampleSchemas: [],\n refLogger,\n transformer: opts.transformer,\n });\n\n // Check if the schema wasn't created or there's no deprecated properties\n if (Object.keys(deprecatedSchema).length === 0 || Object.keys(deprecatedSchema.properties).length === 0) {\n return null;\n }\n\n // Remove deprecated properties from the original schema\n // Not using the clone here becuase we WANT this to affect the original\n Object.keys(schema.properties).forEach(key => {\n // We know this will always be a SchemaObject\n if ((schema.properties[key] as SchemaObject).deprecated && !requiredParams.includes(key)) {\n delete schema.properties[key];\n }\n });\n\n return {\n type,\n schema: isPrimitive(deprecatedSchema)\n ? deprecatedSchema\n : {\n ...deprecatedSchema,\n $schema: getSchemaVersionString(deprecatedSchema, api),\n },\n };\n }\n\n /**\n *\n */\n function transformRequestBody(): SchemaWrapper {\n const requestBody = operation.getRequestBody();\n if (!requestBody || !Array.isArray(requestBody)) return null;\n\n const [mediaType, mediaTypeObject, description] = requestBody;\n const type = mediaType === 'application/x-www-form-urlencoded' ? 'formData' : 'body';\n\n // If this schema is completely empty, don't bother processing it.\n if (!mediaTypeObject.schema || !Object.keys(mediaTypeObject.schema).length) {\n return null;\n }\n\n const prevExampleSchemas: toJSONSchemaOptions['prevExampleSchemas'] = [];\n if ('example' in mediaTypeObject) {\n prevExampleSchemas.push({ example: mediaTypeObject.example });\n } else if ('examples' in mediaTypeObject) {\n prevExampleSchemas.push({\n examples: Object.values(mediaTypeObject.examples)\n .map((example: ExampleObject) => example.value)\n .filter(val => val !== undefined),\n });\n }\n\n // We're cloning the request schema because we've had issues with request schemas that were\n // dereferenced being processed multiple times because their component is also processed.\n const requestSchema = cloneObject(mediaTypeObject.schema);\n\n const cleanedSchema = toJSONSchema(requestSchema, {\n globalDefaults: opts.globalDefaults,\n hideReadOnlyProperties: opts.hideReadOnlyProperties,\n hideWriteOnlyProperties: opts.hideWriteOnlyProperties,\n prevExampleSchemas,\n refLogger,\n transformer: opts.transformer,\n });\n\n // If this schema is **still** empty, don't bother returning it.\n if (!Object.keys(cleanedSchema).length) {\n return null;\n }\n\n return {\n type,\n label: types[type],\n schema: isPrimitive(cleanedSchema)\n ? cleanedSchema\n : {\n ...cleanedSchema,\n $schema: getSchemaVersionString(cleanedSchema, api),\n },\n deprecatedProps: getDeprecated(cleanedSchema, type),\n ...(description ? { description } : {}),\n };\n }\n\n function transformComponents(): ComponentsObject {\n if (!('components' in api)) {\n return false;\n }\n\n const components: Partial<ComponentsObject> = {\n ...Object.keys(api.components)\n .map(componentType => ({ [componentType]: {} }))\n .reduce((prev, next) => Object.assign(prev, next), {}),\n };\n\n Object.keys(api.components).forEach((componentType: keyof ComponentsObject) => {\n if (typeof api.components[componentType] === 'object' && !Array.isArray(api.components[componentType])) {\n Object.keys(api.components[componentType]).forEach(schemaName => {\n const componentSchema = cloneObject(api.components[componentType][schemaName]);\n components[componentType][schemaName] = toJSONSchema(componentSchema as SchemaObject, {\n globalDefaults: opts.globalDefaults,\n hideReadOnlyProperties: opts.hideReadOnlyProperties,\n hideWriteOnlyProperties: opts.hideWriteOnlyProperties,\n refLogger,\n transformer: opts.transformer,\n });\n });\n }\n });\n\n // If none of our above component type placeholders got used let's clean them up.\n Object.keys(components).forEach((componentType: keyof ComponentsObject) => {\n if (!Object.keys(components[componentType]).length) {\n delete components[componentType];\n }\n });\n\n return components;\n }\n\n function transformParameters(): SchemaWrapper[] {\n const operationParams = operation.getParameters();\n\n const transformed = Object.keys(types)\n .map(type => {\n const required: string[] = [];\n\n // This `as` actually *could* be a ref, but we don't want refs to pass through here, so\n // `.in` will never match `type`\n const parameters = operationParams.filter(param => (param as ParameterObject).in === type);\n if (parameters.length === 0) {\n return null;\n }\n\n const properties = parameters.reduce((prev: Record<string, SchemaObject>, current: ParameterObject) => {\n let schema: SchemaObject = {};\n if ('schema' in current) {\n const currentSchema: SchemaObject = current.schema ? cloneObject(current.schema) : {};\n\n if (current.example) {\n // `example` can be present outside of the `schema` block so if it's there we should\n // pull it in so it can be handled and returned if it's valid.\n currentSchema.example = current.example;\n } else if (current.examples) {\n // `examples` isn't actually supported here in OAS 3.0, but we might as well support\n // it because `examples` is JSON Schema and that's fully supported in OAS 3.1.\n currentSchema.examples = current.examples as unknown as unknown[];\n }\n\n if (current.deprecated) currentSchema.deprecated = current.deprecated;\n\n const interimSchema = toJSONSchema(currentSchema, {\n currentLocation: `/${current.name}`,\n globalDefaults: opts.globalDefaults,\n hideReadOnlyProperties: opts.hideReadOnlyProperties,\n hideWriteOnlyProperties: opts.hideWriteOnlyProperties,\n refLogger,\n transformer: opts.transformer,\n });\n\n schema = isPrimitive(interimSchema)\n ? interimSchema\n : {\n ...interimSchema,\n\n // Note: this applies a `$schema` version to each field in the larger schema\n // object. It's not really **correct** but it's what we have to do because\n // there's a chance that the end user has indicated the schemas are different.\n $schema: getSchemaVersionString(currentSchema, api),\n };\n } else if ('content' in current && typeof current.content === 'object') {\n const contentKeys = Object.keys(current.content);\n if (contentKeys.length) {\n let contentType;\n if (contentKeys.length === 1) {\n contentType = contentKeys[0];\n } else {\n // We should always try to prioritize `application/json` over any other possible\n // content that might be present on this schema.\n const jsonLikeContentTypes = contentKeys.filter(k => matchesMimetype.json(k));\n if (jsonLikeContentTypes.length) {\n contentType = jsonLikeContentTypes[0];\n } else {\n contentType = contentKeys[0];\n }\n }\n\n if (typeof current.content[contentType] === 'object' && 'schema' in current.content[contentType]) {\n const currentSchema: SchemaObject = current.content[contentType].schema\n ? cloneObject(current.content[contentType].schema)\n : {};\n\n if (current.example) {\n // `example` can be present outside of the `schema` block so if it's there we\n // should pull it in so it can be handled and returned if it's valid.\n currentSchema.example = current.example;\n } else if (current.examples) {\n // `examples` isn't actually supported here in OAS 3.0, but we might as well\n // support it because `examples` is JSON Schema and that's fully supported in OAS\n // 3.1.\n currentSchema.examples = current.examples as unknown as unknown[];\n }\n\n if (current.deprecated) currentSchema.deprecated = current.deprecated;\n\n const interimSchema = toJSONSchema(currentSchema, {\n currentLocation: `/${current.name}`,\n globalDefaults: opts.globalDefaults,\n hideReadOnlyProperties: opts.hideReadOnlyProperties,\n hideWriteOnlyProperties: opts.hideWriteOnlyProperties,\n refLogger,\n transformer: opts.transformer,\n });\n\n schema = isPrimitive(interimSchema)\n ? interimSchema\n : {\n ...interimSchema,\n\n // Note: this applies a `$schema` version to each field in the larger schema\n // object. It's not really **correct** but it's what we have to do because\n // there's a chance that the end user has indicated the schemas are different.\n $schema: getSchemaVersionString(currentSchema, api),\n };\n }\n }\n }\n\n // Parameter descriptions don't exist in `current.schema` so `constructSchema` will never\n // have access to it.\n if (current.description) {\n if (!isPrimitive(schema)) {\n schema.description = current.description;\n }\n }\n\n prev[current.name] = schema;\n\n if (current.required) {\n required.push(current.name);\n }\n\n return prev;\n }, {});\n\n // This typing is technically WRONG :( but it's the best we can do for now.\n const schema: OpenAPIV3_1.SchemaObject = {\n type: 'object',\n properties: properties as Record<string, OpenAPIV3_1.SchemaObject>,\n required,\n };\n\n return {\n type,\n label: types[type],\n schema,\n deprecatedProps: getDeprecated(schema, type),\n };\n })\n .filter(Boolean);\n\n if (!opts.mergeIntoBodyAndMetadata) {\n return transformed;\n } else if (!transformed.length) {\n return [];\n }\n\n // If we want to merge parameters into a single metadata entry then we need to pull all\n // available schemas and `deprecatedProps` (if we don't want to retain them via the\n // `retainDeprecatedProps` option) under one roof.\n const deprecatedProps = transformed.map(r => r.deprecatedProps?.schema || null).filter(Boolean);\n return [\n {\n type: 'metadata',\n label: types.metadata,\n schema: {\n allOf: transformed.map(r => r.schema),\n } as SchemaObject,\n deprecatedProps: deprecatedProps.length\n ? {\n type: 'metadata',\n schema: {\n allOf: deprecatedProps,\n } as SchemaObject,\n }\n : null,\n },\n ];\n }\n\n // If this operation neither has any parameters or a request body then we should return null\n // because there won't be any JSON Schema.\n if (!operation.hasParameters() && !operation.hasRequestBody()) {\n return null;\n }\n\n // `metadata` is `api` SDK specific, is not a part of the `PARAMETER_ORDERING` extension, and\n // should always be sorted last. We also define `formData` as `form` in the extension because\n // we don't want folks to have to deal with casing issues so we need to rewrite it to `formData`.\n const typeKeys = (getExtension(PARAMETER_ORDERING, api, operation) as string[]).map(k => k.toLowerCase());\n typeKeys[typeKeys.indexOf('form')] = 'formData';\n typeKeys.push('metadata');\n\n const jsonSchema = [transformRequestBody()].concat(...transformParameters()).filter(Boolean);\n\n // We should only include `components`, or even bother transforming components into JSON Schema,\n // if we either have circular refs or if we have discriminator mapping refs somewhere and want to\n // include them.\n const shouldIncludeComponents =\n hasCircularRefs || (hasDiscriminatorMappingRefs && opts.includeDiscriminatorMappingRefs);\n\n const components = shouldIncludeComponents ? transformComponents() : false;\n\n return jsonSchema\n .map(group => {\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 (components && shouldIncludeComponents) {\n // Fixing typing and confused version mismatches\n (group.schema.components as ComponentsObject) = components;\n }\n\n // Delete deprecatedProps if it's null on the schema.\n if (!group.deprecatedProps) delete group.deprecatedProps;\n\n return group;\n })\n .sort((a, b) => {\n return typeKeys.indexOf(a.type) - typeKeys.indexOf(b.type);\n });\n}\n"],"mappings":";;;;;;;;;;;AAAe,SAAR,YAAgC,KAAW;AAChD,MAAI,OAAO,QAAQ,aAAa;AAC9B,WAAO;AAAA,EACT;AAGA,SAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AACvC;;;ACLO,SAAS,cAAc,QAAsB,eAA4C;AAC9F,MAAI,MAAM,QAAQ,OAAO,IAAI,GAAG;AAC9B,WAAO,OAAO,KAAK,SAAS,aAAa;AAAA,EAC3C;AAEA,SAAO,OAAO,SAAS;AACzB;AAEO,SAAS,SAAS,KAA8C;AACrE,SAAO,OAAO,QAAQ,YAAY,QAAQ,QAAQ,CAAC,MAAM,QAAQ,GAAG;AACtE;AAEO,SAAS,YAAY,KAAgD;AAC1E,SAAO,OAAO,QAAQ,YAAY,OAAO,QAAQ,YAAY,OAAO,QAAQ;AAC9E;;;AChBA,SAAS,iBAAiBA,QAAiB,WAA4B;AACrE,SAAOA,OAAM,KAAK,UAAQ;AACxB,WAAO,UAAU,QAAQ,IAAI,IAAI;AAAA,EACnC,CAAC;AACH;AAEA,IAAO,2BAAQ;AAAA,EACb,gBAAg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