oas 28.2.0 → 28.3.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 (43) hide show
  1. package/dist/analyzer/index.cjs +6 -6
  2. package/dist/analyzer/index.js +4 -4
  3. package/dist/{chunk-5H5ODYVE.cjs → chunk-636SYI6H.cjs} +20 -20
  4. package/dist/{chunk-5H5ODYVE.cjs.map → chunk-636SYI6H.cjs.map} +1 -1
  5. package/dist/{chunk-N37BGVKV.cjs → chunk-6JSHPV2O.cjs} +1 -1
  6. package/dist/chunk-6JSHPV2O.cjs.map +1 -0
  7. package/dist/{chunk-YKTDUFLY.cjs → chunk-G5MSDVMW.cjs} +3 -3
  8. package/dist/{chunk-YKTDUFLY.cjs.map → chunk-G5MSDVMW.cjs.map} +1 -1
  9. package/dist/{chunk-WCXAO744.cjs → chunk-GDEE6EQV.cjs} +19 -19
  10. package/dist/{chunk-WCXAO744.cjs.map → chunk-GDEE6EQV.cjs.map} +1 -1
  11. package/dist/{chunk-FHMF4CEN.js → chunk-NBQXNFZT.js} +1 -1
  12. package/dist/chunk-NBQXNFZT.js.map +1 -0
  13. package/dist/{chunk-FBOFXOMD.js → chunk-NIBF7F33.js} +4 -4
  14. package/dist/{chunk-J5RLIWSD.js → chunk-RF2D4VVK.js} +3 -3
  15. package/dist/{chunk-ATLAOOV5.js → chunk-T34XCOTS.js} +2 -2
  16. package/dist/{extensions-CJIHlfU6.d.ts → extensions-DAFceEIL.d.ts} +14 -1
  17. package/dist/{extensions-HnzLmmuw.d.cts → extensions-DlGC1TJ1.d.cts} +14 -1
  18. package/dist/extensions.cjs +2 -2
  19. package/dist/extensions.d.cts +1 -1
  20. package/dist/extensions.d.ts +1 -1
  21. package/dist/extensions.js +1 -1
  22. package/dist/index.cjs +5 -5
  23. package/dist/index.d.cts +1 -1
  24. package/dist/index.d.ts +1 -1
  25. package/dist/index.js +4 -4
  26. package/dist/operation/index.cjs +4 -4
  27. package/dist/operation/index.d.cts +1 -1
  28. package/dist/operation/index.d.ts +1 -1
  29. package/dist/operation/index.js +3 -3
  30. package/dist/operation/lib/get-parameters-as-json-schema.cjs +3 -3
  31. package/dist/operation/lib/get-parameters-as-json-schema.d.cts +1 -1
  32. package/dist/operation/lib/get-parameters-as-json-schema.d.ts +1 -1
  33. package/dist/operation/lib/get-parameters-as-json-schema.js +2 -2
  34. package/dist/utils.cjs +3 -3
  35. package/dist/utils.d.cts +1 -1
  36. package/dist/utils.d.ts +1 -1
  37. package/dist/utils.js +2 -2
  38. package/package.json +2 -2
  39. package/dist/chunk-FHMF4CEN.js.map +0 -1
  40. package/dist/chunk-N37BGVKV.cjs.map +0 -1
  41. /package/dist/{chunk-FBOFXOMD.js.map → chunk-NIBF7F33.js.map} +0 -0
  42. /package/dist/{chunk-J5RLIWSD.js.map → chunk-RF2D4VVK.js.map} +0 -0
  43. /package/dist/{chunk-ATLAOOV5.js.map → chunk-T34XCOTS.js.map} +0 -0
@@ -1,4 +1,4 @@
1
1
  import '../../types.js';
2
- export { S as SchemaWrapper, a as getParametersAsJSONSchema, g as getParametersAsJSONSchemaOptions, t as types } from '../../extensions-CJIHlfU6.js';
2
+ export { S as SchemaWrapper, a as getParametersAsJSONSchema, g as getParametersAsJSONSchemaOptions, t as types } from '../../extensions-DAFceEIL.js';
3
3
  import 'json-schema';
4
4
  import 'openapi-types';
@@ -1,8 +1,8 @@
1
1
  import {
2
2
  getParametersAsJSONSchema,
3
3
  types
4
- } from "../../chunk-ATLAOOV5.js";
5
- import "../../chunk-FHMF4CEN.js";
4
+ } from "../../chunk-T34XCOTS.js";
5
+ import "../../chunk-NBQXNFZT.js";
6
6
  import "../../chunk-UCEHCARG.js";
7
7
  export {
8
8
  getParametersAsJSONSchema,
package/dist/utils.cjs CHANGED
@@ -5,13 +5,13 @@ var _chunk4DBNE7RJcjs = require('./chunk-4DBNE7RJ.cjs');
5
5
 
6
6
 
7
7
 
8
- var _chunkYKTDUFLYcjs = require('./chunk-YKTDUFLY.cjs');
9
- require('./chunk-N37BGVKV.cjs');
8
+ var _chunkG5MSDVMWcjs = require('./chunk-G5MSDVMW.cjs');
9
+ require('./chunk-6JSHPV2O.cjs');
10
10
  require('./chunk-EQEXNJJE.cjs');
11
11
 
12
12
 
13
13
 
14
14
 
15
15
 
16
- exports.findSchemaDefinition = _chunk4DBNE7RJcjs.findSchemaDefinition; exports.jsonSchemaTypes = _chunkYKTDUFLYcjs.types; exports.matchesMimeType = _chunkYKTDUFLYcjs.matches_mimetype_default; exports.supportedMethods = _chunk4DBNE7RJcjs.supportedMethods;
16
+ exports.findSchemaDefinition = _chunk4DBNE7RJcjs.findSchemaDefinition; exports.jsonSchemaTypes = _chunkG5MSDVMWcjs.types; exports.matchesMimeType = _chunkG5MSDVMWcjs.matches_mimetype_default; exports.supportedMethods = _chunk4DBNE7RJcjs.supportedMethods;
17
17
  //# sourceMappingURL=utils.cjs.map
package/dist/utils.d.cts CHANGED
@@ -1,4 +1,4 @@
1
- export { t as jsonSchemaTypes } from './extensions-HnzLmmuw.cjs';
1
+ export { t as jsonSchemaTypes } from './extensions-DlGC1TJ1.cjs';
2
2
  import './types.cjs';
3
3
  import 'json-schema';
4
4
  import 'openapi-types';
package/dist/utils.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { t as jsonSchemaTypes } from './extensions-CJIHlfU6.js';
1
+ export { t as jsonSchemaTypes } from './extensions-DAFceEIL.js';
2
2
  import './types.js';
3
3
  import 'json-schema';
4
4
  import 'openapi-types';
package/dist/utils.js CHANGED
@@ -5,8 +5,8 @@ import {
5
5
  import {
6
6
  matches_mimetype_default,
7
7
  types
8
- } from "./chunk-ATLAOOV5.js";
9
- import "./chunk-FHMF4CEN.js";
8
+ } from "./chunk-T34XCOTS.js";
9
+ import "./chunk-NBQXNFZT.js";
10
10
  import "./chunk-UCEHCARG.js";
11
11
  export {
12
12
  findSchemaDefinition,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "oas",
3
- "version": "28.2.0",
3
+ "version": "28.3.0",
4
4
  "description": "Comprehensive tooling for working with OpenAPI definitions",
5
5
  "license": "MIT",
6
6
  "author": "ReadMe <support@readme.io> (https://readme.com)",
@@ -107,5 +107,5 @@
107
107
  "vitest": "^3.2.1"
108
108
  },
109
109
  "prettier": "@readme/standards/prettier",
110
- "gitHead": "f28ec74e7472f0c6958307ee7f9e822e8481ec4b"
110
+ "gitHead": "3d895bfa7f64a674b4462b0fd005ee96319d5263"
111
111
  }
@@ -1 +0,0 @@
1
- {"version":3,"sources":["../src/extensions.ts"],"sourcesContent":["import type { Operation } from './operation/index.js';\nimport type { OASDocument } from './types.js';\n\n/**\n * Enables custom-written code samples to be set for your operations. Use this if you have specific\n * formatting that may not be followed by the auto-generated code samples. Custom code samples are\n * treated as static content.\n *\n * This extension only be placed at the operation level.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#custom-code-samples}\n * @example\n * {\n * \"x-readme\": {\n * \"code-samples\": [\n * {\n * \"language\": \"curl\",\n * \"code\": \"curl -X POST https://api.example.com/v2/alert\",\n * \"name\": \"Custom cURL snippet\",\n * \"install\": \"brew install curl\"\n * },\n * {\n * \"language\": \"php\",\n * \"code\": \"<?php echo \\\"This is our custom PHP code snippet.\\\"; ?>\",\n * \"name\": \"Custom PHP snippet\"\n * }\n * ]\n * }\n * }\n */\nexport const CODE_SAMPLES = 'code-samples';\n\n/**\n * Disables the API Explorer's \"Try It\" button, preventing users from making API requests from\n * within your docs. Users will still be able to fill out any entry fields (path or query\n * parameters, etc.), and code snippets will be auto-generated based on the user's input, however\n * to interact with your API the user will need to copy the code snippet and execute it outside of\n * your docs.\n *\n * This **does not** disable your API Reference documentation.\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-the-api-explorer}\n * @example\n * {\n * \"x-readme\": {\n * \"explorer-enabled\": true\n * }\n * }\n */\nexport const EXPLORER_ENABLED = 'explorer-enabled';\n\n/**\n * Adds static headers to add to each request. Use this when there are specific headers unique to\n * your API.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#static-headers}\n * @example\n * {\n * \"x-readme\": {\n * \"headers\": [\n * {\n * \"key\": \"X-Static-Header-One\",\n * \"value\": \"owlbert\"\n * },\n * {\n * \"key\": \"X-Static-Header-Two\",\n * \"value\": \"owlivia\"\n * }\n * ]\n * }\n * }\n */\nexport const HEADERS = 'headers';\n\n/**\n * Disables API requests from the API Explorer's \"Try It\" button from being sent into our [API\n * Metrics](https://readme.com/metrics) for you and your users. Additionally on any API endpoint\n * that this is disabled on your users will not see lists or graphs of previous requests they've\n * made against that API endpoint — either through the API Explorer's interactivity or through one\n * of our [Metrics SDKs](https://docs.readme.com/main/docs/api-metrics-setup) (if you have those\n * installed on your API).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-api-metrics}\n * @example\n * {\n * \"x-readme\": {\n * \"metrics-defaults\": false\n * }\n * }\n */\nexport const METRICS_ENABLED = 'metrics-enabled';\n\n/**\n * Configuration options for OAuth flows in the API Explorer.\n *\n * @defaultValue {}\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#oauth-configuration-options}\n * @example\n * {\n * \"x-readme\": {\n * \"oauth-options\": {\n * \"scopeSeparator\": \",\",\n * \"useInsecureClientAuthentication\": true\n * }\n * }\n * }\n */\nexport const OAUTH_OPTIONS = 'oauth-options';\n\n/**\n * Controls the order of parameters on your API Reference pages.\n *\n * Your custom ordering **must** contain all of our available parameter types:\n *\n * - `path`: Path parameters\n * - `query`: Query parameters\n * - `body`: Non-`application/x-www-form-urlencoded` request body payloads\n * - `cookie`: Cookie parameters\n * - `form`: `application/x-www-form-urlencoded` request body payloads\n * - `header`: Header parameters\n *\n * @defaultValue ['path', 'query', 'body', 'cookie', 'form', 'header']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#parameter-ordering}\n * @example\n * {\n * \"x-readme\": {\n * \"parameter-ordering\": ['path', 'query', 'header', 'cookie', 'body', 'form']\n * }\n * }\n */\nexport const PARAMETER_ORDERING = 'parameter-ordering';\n\n/**\n * Toggles the CORS proxy used when making API requests from within your docs (via the \"Try It\"\n * button). If your API is already set up to return CORS headers, you can safely disable this\n * feature.\n *\n * Disabling the CORS proxy will make the request directly from the user's browser and will prevent\n * [Metrics](https://docs.readme.com/main/docs/getting-started-with-metrics) data from being logged\n * by us unless [Metrics have already set up on your backend](https://docs.readme.com/main/docs/api-metrics-setup).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#cors-proxy-enabled}\n * @example\n * {\n * \"x-readme\": {\n * \"proxy-enabled\": true\n * }\n * }\n */\nexport const PROXY_ENABLED = 'proxy-enabled';\n\n/**\n * Toggles what languages are shown by default for code samples in the API Explorer. This only\n * affects what languages are initially shown to the user; if the user picks another language from\n * the three-dot menu, that language and the respective auto-generated code snippet will also appear\n * as an option in the API Explorer.\n *\n * @defaultValue ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#code-sample-languages}\n * @example\n * {\n * \"x-readme\": {\n * \"samples-languages\": [\"shell\", \"node\", \"ruby\", \"javascript\", \"python\"]\n * }\n * }\n */\nexport const SAMPLES_LANGUAGES = 'samples-languages';\n\n/**\n * Toggles if you will see code snippets for ReadMe's SDK code generator tool `api`.\n *\n * @defaultValue true\n * @see {@link https://api.readme.dev}\n * @example\n * {\n * \"x-readme\": {\n * \"simple-mode\": false\n * }\n * }\n */\nexport const SIMPLE_MODE = 'simple-mode';\n\n/**\n * If `true`, tags are generated from the file top-down. If `false`, we sort the tags\n * based off the `tags` array in the OAS file.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-tag-sorting}\n * @example\n * {\n * \"x-readme\": {\n * \"disable-tag-sorting\": true\n * }\n * }\n */\nexport const DISABLE_TAG_SORTING = 'disable-tag-sorting';\n\nexport interface Extensions {\n [CODE_SAMPLES]: {\n /**\n * Custom code snippet\n * @example \"curl -X POST https://api.example.com/v2/alert\"\n */\n code: string;\n /**\n * Corresponding response example\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#corresponding-response-examples}\n */\n correspondingExample?: string;\n /**\n * Library installation instructions\n * @example \"brew install httpie\"\n * @example \"npm install node-fetch@2 --save\"\n */\n install?: string;\n /**\n * Language for syntax highlighting\n * @example shell\n */\n language: string;\n /**\n * Optional title for code sample\n * @example \"Custom cURL snippet\"\n */\n name?: string;\n }[];\n [DISABLE_TAG_SORTING]: boolean;\n [EXPLORER_ENABLED]: boolean;\n [HEADERS]: Record<string, number | string>[];\n [METRICS_ENABLED]: boolean;\n [OAUTH_OPTIONS]: {\n /**\n * Scope separator for passing scopes. This value will be URL-encoded.\n *\n * @example \",\"\n * @example \"+\"\n * @default \" \"\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.3} Scope separators information from OAuth 2.0 specification\n */\n scopeSeparator?: string;\n\n /**\n * When enabled, the client credentials (i.e., `client_id` and `client_secret`) are sent in the request body (NOT recommended).\n * When disabled (the default), client credentials are sent using the HTTP Basic Authentication scheme.\n *\n * This is applicable for all requests to the token endpoint.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.2}\n *\n * @example true\n * @default false\n */\n useInsecureClientAuthentication?: boolean;\n };\n [PARAMETER_ORDERING]: ('body' | 'cookie' | 'form' | 'header' | 'path' | 'query')[];\n [PROXY_ENABLED]: boolean;\n [SAMPLES_LANGUAGES]: string[];\n [SIMPLE_MODE]: boolean;\n}\n\nexport const extensionDefaults: Extensions = {\n [CODE_SAMPLES]: undefined,\n [DISABLE_TAG_SORTING]: false,\n [EXPLORER_ENABLED]: true,\n [HEADERS]: undefined,\n [METRICS_ENABLED]: true,\n [OAUTH_OPTIONS]: {},\n [PARAMETER_ORDERING]: ['path', 'query', 'body', 'cookie', 'form', 'header'],\n [PROXY_ENABLED]: true,\n [SAMPLES_LANGUAGES]: ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp'],\n [SIMPLE_MODE]: true,\n};\n\n/**\n * Determing if an OpenAPI definition has an extension set in its root schema.\n *\n */\nexport function hasRootExtension(extension: string | keyof Extensions, api: OASDocument): boolean {\n return Boolean(api && extension in api);\n}\n\n/**\n * Retrieve a custom specification extension off of the API definition.\n *\n */\nexport function getExtension(extension: string | keyof Extensions, api: OASDocument, operation?: Operation): any {\n if (operation) {\n if (operation.hasExtension('x-readme')) {\n const data = operation.getExtension('x-readme') as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (operation.hasExtension(`x-${extension}`)) {\n return operation.getExtension(`x-${extension}`);\n } else if (operation.hasExtension(extension)) {\n return operation.getExtension(extension);\n }\n }\n\n // Because our `code-samples` extension is intended for operation-level use, if it's instead\n // placed at the API definition root level then we should ignore it and return our set defaults.\n if (extension === CODE_SAMPLES) {\n return extensionDefaults[extension];\n }\n\n if (hasRootExtension('x-readme', api)) {\n const data = api?.['x-readme'] as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (hasRootExtension(`x-${extension}`, api)) {\n return api?.[`x-${extension}`];\n } else if (hasRootExtension(extension, api)) {\n return api?.[extension];\n }\n\n // If this is otherwise an extension of our own then we should return the default value for it.\n if (extension in extensionDefaults) {\n return extensionDefaults[extension as keyof Extensions];\n }\n\n return undefined;\n}\n\n/**\n * Validate that the data for an instanceof our `PARAMETER_ORDERING` extension is properly\n * configured.\n *\n * @private\n */\nexport function validateParameterOrdering(\n ordering: (typeof extensionDefaults)[typeof PARAMETER_ORDERING] | undefined,\n extension: string,\n): void {\n const defaultValue = extensionDefaults[PARAMETER_ORDERING];\n const requiredLength = defaultValue.length;\n const defaultsHuman = `${defaultValue.slice(0, -1).join(', ')}, and ${defaultValue.slice(-1)}`;\n\n if (ordering.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n\n const intersection = ordering.filter(value => defaultValue.includes(value.toLowerCase() as any));\n if (intersection.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n}\n"],"mappings":";AA+BO,IAAM,eAAe;AAoBrB,IAAM,mBAAmB;AAwBzB,IAAM,UAAU;AAmBhB,IAAM,kBAAkB;AAiBxB,IAAM,gBAAgB;AAuBtB,IAAM,qBAAqB;AAoB3B,IAAM,gBAAgB;AAiBtB,IAAM,oBAAoB;AAc1B,IAAM,cAAc;AAepB,IAAM,sBAAsB;AAkE5B,IAAM,oBAAgC;AAAA,EAC3C,CAAC,YAAY,GAAG;AAAA,EAChB,CAAC,mBAAmB,GAAG;AAAA,EACvB,CAAC,gBAAgB,GAAG;AAAA,EACpB,CAAC,OAAO,GAAG;AAAA,EACX,CAAC,eAAe,GAAG;AAAA,EACnB,CAAC,aAAa,GAAG,CAAC;AAAA,EAClB,CAAC,kBAAkB,GAAG,CAAC,QAAQ,SAAS,QAAQ,UAAU,QAAQ,QAAQ;AAAA,EAC1E,CAAC,aAAa,GAAG;AAAA,EACjB,CAAC,iBAAiB,GAAG,CAAC,SAAS,QAAQ,QAAQ,OAAO,UAAU,QAAQ,QAAQ;AAAA,EAChF,CAAC,WAAW,GAAG;AACjB;AAMO,SAAS,iBAAiB,WAAsC,KAA2B;AAChG,SAAO,QAAQ,OAAO,aAAa,GAAG;AACxC;AAMO,SAAS,aAAa,WAAsC,KAAkB,WAA4B;AAC/G,MAAI,WAAW;AACb,QAAI,UAAU,aAAa,UAAU,GAAG;AACtC,YAAM,OAAO,UAAU,aAAa,UAAU;AAC9C,UAAI,QAAQ,OAAO,SAAS,YAAY,aAAa,MAAM;AACzD,eAAO,KAAK,SAA6B;AAAA,MAC3C;AAAA,IACF;AAEA,QAAI,UAAU,aAAa,KAAK,SAAS,EAAE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,CAAI,SAAA,EAAW;AACb,IAAA,GAAA,CAAI,SAAA,CAAU,YAAA,CAAa,UAAU,CAAA,EAAG;AACtC,MAAA,MAAM,KAAA,EAAO,SAAA,CAAU,YAAA,CAAa,UAAU,CAAA;AAC9C,MAAA,GAAA,CAAI,KAAA,GAAQ,OAAO,KAAA,IAAS,SAAA,GAAY,UAAA,GAAa,IAAA,EAAM;AACzD,QAAA,OAAO,IAAA,CAAK,SAA6B,CAAA;AAAA,MAC3C;AAAA,IACF;AAEA,IAAA,GAAA,CAAI,SAAA,CAAU,YAAA,CAAa,CAAA,EAAA,EAAK,SAAS,CAAA,CAAA;AACJ,MAAA;AACH,IAAA;AACO,MAAA;AACzC,IAAA;AACF,EAAA;AAIgC,EAAA;AACI,IAAA;AACpC,EAAA;AAEuC,EAAA;AACR,IAAA;AACW,IAAA;AACG,MAAA;AAC3C,IAAA;AACF,EAAA;AAE0C,EAAA;AACX,IAAA;AACW,EAAA;AAClB,IAAA;AACxB,EAAA;AAGoC,EAAA;AACoB,IAAA;AACxD,EAAA;AAEO,EAAA;AACT;AAUE;AAEuC,EAAA;AACH,EAAA;AACQ,EAAA;AAEJ,EAAA;AACL,IAAA;AACnC,EAAA;AAEqC,EAAA;AACO,EAAA;AACT,IAAA;AACnC,EAAA;AACF;AD7R8C;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-N37BGVKV.cjs","sourcesContent":[null,"import type { Operation } from './operation/index.js';\nimport type { OASDocument } from './types.js';\n\n/**\n * Enables custom-written code samples to be set for your operations. Use this if you have specific\n * formatting that may not be followed by the auto-generated code samples. Custom code samples are\n * treated as static content.\n *\n * This extension only be placed at the operation level.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#custom-code-samples}\n * @example\n * {\n * \"x-readme\": {\n * \"code-samples\": [\n * {\n * \"language\": \"curl\",\n * \"code\": \"curl -X POST https://api.example.com/v2/alert\",\n * \"name\": \"Custom cURL snippet\",\n * \"install\": \"brew install curl\"\n * },\n * {\n * \"language\": \"php\",\n * \"code\": \"<?php echo \\\"This is our custom PHP code snippet.\\\"; ?>\",\n * \"name\": \"Custom PHP snippet\"\n * }\n * ]\n * }\n * }\n */\nexport const CODE_SAMPLES = 'code-samples';\n\n/**\n * Disables the API Explorer's \"Try It\" button, preventing users from making API requests from\n * within your docs. Users will still be able to fill out any entry fields (path or query\n * parameters, etc.), and code snippets will be auto-generated based on the user's input, however\n * to interact with your API the user will need to copy the code snippet and execute it outside of\n * your docs.\n *\n * This **does not** disable your API Reference documentation.\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-the-api-explorer}\n * @example\n * {\n * \"x-readme\": {\n * \"explorer-enabled\": true\n * }\n * }\n */\nexport const EXPLORER_ENABLED = 'explorer-enabled';\n\n/**\n * Adds static headers to add to each request. Use this when there are specific headers unique to\n * your API.\n *\n * @defaultValue []\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#static-headers}\n * @example\n * {\n * \"x-readme\": {\n * \"headers\": [\n * {\n * \"key\": \"X-Static-Header-One\",\n * \"value\": \"owlbert\"\n * },\n * {\n * \"key\": \"X-Static-Header-Two\",\n * \"value\": \"owlivia\"\n * }\n * ]\n * }\n * }\n */\nexport const HEADERS = 'headers';\n\n/**\n * Disables API requests from the API Explorer's \"Try It\" button from being sent into our [API\n * Metrics](https://readme.com/metrics) for you and your users. Additionally on any API endpoint\n * that this is disabled on your users will not see lists or graphs of previous requests they've\n * made against that API endpoint — either through the API Explorer's interactivity or through one\n * of our [Metrics SDKs](https://docs.readme.com/main/docs/api-metrics-setup) (if you have those\n * installed on your API).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-api-metrics}\n * @example\n * {\n * \"x-readme\": {\n * \"metrics-defaults\": false\n * }\n * }\n */\nexport const METRICS_ENABLED = 'metrics-enabled';\n\n/**\n * Configuration options for OAuth flows in the API Explorer.\n *\n * @defaultValue {}\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#oauth-configuration-options}\n * @example\n * {\n * \"x-readme\": {\n * \"oauth-options\": {\n * \"scopeSeparator\": \",\",\n * \"useInsecureClientAuthentication\": true\n * }\n * }\n * }\n */\nexport const OAUTH_OPTIONS = 'oauth-options';\n\n/**\n * Controls the order of parameters on your API Reference pages.\n *\n * Your custom ordering **must** contain all of our available parameter types:\n *\n * - `path`: Path parameters\n * - `query`: Query parameters\n * - `body`: Non-`application/x-www-form-urlencoded` request body payloads\n * - `cookie`: Cookie parameters\n * - `form`: `application/x-www-form-urlencoded` request body payloads\n * - `header`: Header parameters\n *\n * @defaultValue ['path', 'query', 'body', 'cookie', 'form', 'header']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#parameter-ordering}\n * @example\n * {\n * \"x-readme\": {\n * \"parameter-ordering\": ['path', 'query', 'header', 'cookie', 'body', 'form']\n * }\n * }\n */\nexport const PARAMETER_ORDERING = 'parameter-ordering';\n\n/**\n * Toggles the CORS proxy used when making API requests from within your docs (via the \"Try It\"\n * button). If your API is already set up to return CORS headers, you can safely disable this\n * feature.\n *\n * Disabling the CORS proxy will make the request directly from the user's browser and will prevent\n * [Metrics](https://docs.readme.com/main/docs/getting-started-with-metrics) data from being logged\n * by us unless [Metrics have already set up on your backend](https://docs.readme.com/main/docs/api-metrics-setup).\n *\n * @defaultValue true\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#cors-proxy-enabled}\n * @example\n * {\n * \"x-readme\": {\n * \"proxy-enabled\": true\n * }\n * }\n */\nexport const PROXY_ENABLED = 'proxy-enabled';\n\n/**\n * Toggles what languages are shown by default for code samples in the API Explorer. This only\n * affects what languages are initially shown to the user; if the user picks another language from\n * the three-dot menu, that language and the respective auto-generated code snippet will also appear\n * as an option in the API Explorer.\n *\n * @defaultValue ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp']\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#code-sample-languages}\n * @example\n * {\n * \"x-readme\": {\n * \"samples-languages\": [\"shell\", \"node\", \"ruby\", \"javascript\", \"python\"]\n * }\n * }\n */\nexport const SAMPLES_LANGUAGES = 'samples-languages';\n\n/**\n * Toggles if you will see code snippets for ReadMe's SDK code generator tool `api`.\n *\n * @defaultValue true\n * @see {@link https://api.readme.dev}\n * @example\n * {\n * \"x-readme\": {\n * \"simple-mode\": false\n * }\n * }\n */\nexport const SIMPLE_MODE = 'simple-mode';\n\n/**\n * If `true`, tags are generated from the file top-down. If `false`, we sort the tags\n * based off the `tags` array in the OAS file.\n *\n * @defaultValue false\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#disable-tag-sorting}\n * @example\n * {\n * \"x-readme\": {\n * \"disable-tag-sorting\": true\n * }\n * }\n */\nexport const DISABLE_TAG_SORTING = 'disable-tag-sorting';\n\nexport interface Extensions {\n [CODE_SAMPLES]: {\n /**\n * Custom code snippet\n * @example \"curl -X POST https://api.example.com/v2/alert\"\n */\n code: string;\n /**\n * Corresponding response example\n * @see {@link https://docs.readme.com/main/docs/openapi-extensions#corresponding-response-examples}\n */\n correspondingExample?: string;\n /**\n * Library installation instructions\n * @example \"brew install httpie\"\n * @example \"npm install node-fetch@2 --save\"\n */\n install?: string;\n /**\n * Language for syntax highlighting\n * @example shell\n */\n language: string;\n /**\n * Optional title for code sample\n * @example \"Custom cURL snippet\"\n */\n name?: string;\n }[];\n [DISABLE_TAG_SORTING]: boolean;\n [EXPLORER_ENABLED]: boolean;\n [HEADERS]: Record<string, number | string>[];\n [METRICS_ENABLED]: boolean;\n [OAUTH_OPTIONS]: {\n /**\n * Scope separator for passing scopes. This value will be URL-encoded.\n *\n * @example \",\"\n * @example \"+\"\n * @default \" \"\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.3} Scope separators information from OAuth 2.0 specification\n */\n scopeSeparator?: string;\n\n /**\n * When enabled, the client credentials (i.e., `client_id` and `client_secret`) are sent in the request body (NOT recommended).\n * When disabled (the default), client credentials are sent using the HTTP Basic Authentication scheme.\n *\n * This is applicable for all requests to the token endpoint.\n *\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-2.3.1}\n * @see {@link https://datatracker.ietf.org/doc/html/rfc6749#section-3.2}\n *\n * @example true\n * @default false\n */\n useInsecureClientAuthentication?: boolean;\n };\n [PARAMETER_ORDERING]: ('body' | 'cookie' | 'form' | 'header' | 'path' | 'query')[];\n [PROXY_ENABLED]: boolean;\n [SAMPLES_LANGUAGES]: string[];\n [SIMPLE_MODE]: boolean;\n}\n\nexport const extensionDefaults: Extensions = {\n [CODE_SAMPLES]: undefined,\n [DISABLE_TAG_SORTING]: false,\n [EXPLORER_ENABLED]: true,\n [HEADERS]: undefined,\n [METRICS_ENABLED]: true,\n [OAUTH_OPTIONS]: {},\n [PARAMETER_ORDERING]: ['path', 'query', 'body', 'cookie', 'form', 'header'],\n [PROXY_ENABLED]: true,\n [SAMPLES_LANGUAGES]: ['shell', 'node', 'ruby', 'php', 'python', 'java', 'csharp'],\n [SIMPLE_MODE]: true,\n};\n\n/**\n * Determing if an OpenAPI definition has an extension set in its root schema.\n *\n */\nexport function hasRootExtension(extension: string | keyof Extensions, api: OASDocument): boolean {\n return Boolean(api && extension in api);\n}\n\n/**\n * Retrieve a custom specification extension off of the API definition.\n *\n */\nexport function getExtension(extension: string | keyof Extensions, api: OASDocument, operation?: Operation): any {\n if (operation) {\n if (operation.hasExtension('x-readme')) {\n const data = operation.getExtension('x-readme') as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (operation.hasExtension(`x-${extension}`)) {\n return operation.getExtension(`x-${extension}`);\n } else if (operation.hasExtension(extension)) {\n return operation.getExtension(extension);\n }\n }\n\n // Because our `code-samples` extension is intended for operation-level use, if it's instead\n // placed at the API definition root level then we should ignore it and return our set defaults.\n if (extension === CODE_SAMPLES) {\n return extensionDefaults[extension];\n }\n\n if (hasRootExtension('x-readme', api)) {\n const data = api?.['x-readme'] as Extensions;\n if (data && typeof data === 'object' && extension in data) {\n return data[extension as keyof Extensions];\n }\n }\n\n if (hasRootExtension(`x-${extension}`, api)) {\n return api?.[`x-${extension}`];\n } else if (hasRootExtension(extension, api)) {\n return api?.[extension];\n }\n\n // If this is otherwise an extension of our own then we should return the default value for it.\n if (extension in extensionDefaults) {\n return extensionDefaults[extension as keyof Extensions];\n }\n\n return undefined;\n}\n\n/**\n * Validate that the data for an instanceof our `PARAMETER_ORDERING` extension is properly\n * configured.\n *\n * @private\n */\nexport function validateParameterOrdering(\n ordering: (typeof extensionDefaults)[typeof PARAMETER_ORDERING] | undefined,\n extension: string,\n): void {\n const defaultValue = extensionDefaults[PARAMETER_ORDERING];\n const requiredLength = defaultValue.length;\n const defaultsHuman = `${defaultValue.slice(0, -1).join(', ')}, and ${defaultValue.slice(-1)}`;\n\n if (ordering.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n\n const intersection = ordering.filter(value => defaultValue.includes(value.toLowerCase() as any));\n if (intersection.length !== requiredLength) {\n throw new TypeError(`\"${extension}\" must contain ${requiredLength} items comprised of: ${defaultsHuman}`);\n }\n}\n"]}