oas 32.1.9 → 32.1.11

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 (37) hide show
  1. package/dist/analyzer/index.cjs +6 -6
  2. package/dist/analyzer/index.js +4 -4
  3. package/dist/{chunk-WRZUJO3I.js → chunk-2J4VKLIT.js} +4 -4
  4. package/dist/{chunk-YPR7YTHM.cjs → chunk-3MTU2ESP.cjs} +1 -1
  5. package/dist/{chunk-YPR7YTHM.cjs.map → chunk-3MTU2ESP.cjs.map} +1 -1
  6. package/dist/{chunk-NG4A45EE.cjs → chunk-DNLCD3K6.cjs} +153 -141
  7. package/dist/chunk-DNLCD3K6.cjs.map +1 -0
  8. package/dist/{chunk-Q6ABRA4U.cjs → chunk-FGPV2UXT.cjs} +28 -28
  9. package/dist/{chunk-Q6ABRA4U.cjs.map → chunk-FGPV2UXT.cjs.map} +1 -1
  10. package/dist/{chunk-55H65L6J.js → chunk-JCBISKOK.js} +37 -25
  11. package/dist/chunk-JCBISKOK.js.map +1 -0
  12. package/dist/{chunk-MNOEMVCF.js → chunk-PSNTODZL.js} +1 -1
  13. package/dist/{chunk-MNOEMVCF.js.map → chunk-PSNTODZL.js.map} +1 -1
  14. package/dist/{chunk-7BR3G6FM.js → chunk-QINBUHP2.js} +179 -48
  15. package/dist/chunk-QINBUHP2.js.map +1 -0
  16. package/dist/{chunk-KZCEPS4J.cjs → chunk-X7KOY66H.cjs} +206 -75
  17. package/dist/chunk-X7KOY66H.cjs.map +1 -0
  18. package/dist/index.cjs +5 -5
  19. package/dist/index.js +4 -4
  20. package/dist/operation/index.cjs +4 -4
  21. package/dist/operation/index.js +3 -3
  22. package/dist/reducer/index.cjs +49 -28
  23. package/dist/reducer/index.cjs.map +1 -1
  24. package/dist/reducer/index.js +23 -2
  25. package/dist/reducer/index.js.map +1 -1
  26. package/dist/types.cjs +2 -2
  27. package/dist/types.d.cts +3 -0
  28. package/dist/types.d.ts +3 -0
  29. package/dist/types.js +1 -1
  30. package/dist/utils.cjs +3 -3
  31. package/dist/utils.js +2 -2
  32. package/package.json +2 -2
  33. package/dist/chunk-55H65L6J.js.map +0 -1
  34. package/dist/chunk-7BR3G6FM.js.map +0 -1
  35. package/dist/chunk-KZCEPS4J.cjs.map +0 -1
  36. package/dist/chunk-NG4A45EE.cjs.map +0 -1
  37. /package/dist/{chunk-WRZUJO3I.js.map → chunk-2J4VKLIT.js.map} +0 -0
@@ -1,14 +1,14 @@
1
1
  "use strict";Object.defineProperty(exports, "__esModule", {value: true});
2
2
 
3
- var _chunkQ6ABRA4Ucjs = require('../chunk-Q6ABRA4U.cjs');
4
- require('../chunk-NG4A45EE.cjs');
3
+ var _chunkFGPV2UXTcjs = require('../chunk-FGPV2UXT.cjs');
4
+ require('../chunk-DNLCD3K6.cjs');
5
5
 
6
6
 
7
7
 
8
8
  var _chunkW6GBV2JTcjs = require('../chunk-W6GBV2JT.cjs');
9
- require('../chunk-KZCEPS4J.cjs');
9
+ require('../chunk-X7KOY66H.cjs');
10
10
  require('../chunk-AYA3UT4L.cjs');
11
- require('../chunk-YPR7YTHM.cjs');
11
+ require('../chunk-3MTU2ESP.cjs');
12
12
 
13
13
  // src/analyzer/queries/openapi.ts
14
14
  function additionalProperties(definition) {
@@ -20,7 +20,7 @@ function callbacks(definition) {
20
20
  );
21
21
  }
22
22
  async function circularRefs(definition) {
23
- const oas = new (0, _chunkQ6ABRA4Ucjs.Oas)(structuredClone(definition));
23
+ const oas = new (0, _chunkFGPV2UXTcjs.Oas)(structuredClone(definition));
24
24
  await oas.dereference();
25
25
  const results = oas.getCircularReferences();
26
26
  results.sort();
@@ -33,7 +33,7 @@ function discriminators(definition) {
33
33
  return _chunkW6GBV2JTcjs.query.call(void 0, ["$..discriminator"], definition).map((res) => _chunkW6GBV2JTcjs.refizePointer.call(void 0, res.pointer));
34
34
  }
35
35
  async function fileSize(definition) {
36
- const oas = new (0, _chunkQ6ABRA4Ucjs.Oas)(structuredClone(definition));
36
+ const oas = new (0, _chunkFGPV2UXTcjs.Oas)(structuredClone(definition));
37
37
  const originalSizeInBytes = Buffer.from(JSON.stringify(oas.api)).length;
38
38
  const raw = Number((originalSizeInBytes / (1024 * 1024)).toFixed(2));
39
39
  await oas.dereference();
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  Oas
3
- } from "../chunk-WRZUJO3I.js";
4
- import "../chunk-55H65L6J.js";
3
+ } from "../chunk-2J4VKLIT.js";
4
+ import "../chunk-JCBISKOK.js";
5
5
  import {
6
6
  query,
7
7
  refizePointer
8
8
  } from "../chunk-CKC36IL7.js";
9
- import "../chunk-7BR3G6FM.js";
9
+ import "../chunk-QINBUHP2.js";
10
10
  import "../chunk-S27IGTVG.js";
11
- import "../chunk-MNOEMVCF.js";
11
+ import "../chunk-PSNTODZL.js";
12
12
 
13
13
  // src/analyzer/queries/openapi.ts
14
14
  function additionalProperties(definition) {
@@ -1,14 +1,14 @@
1
1
  import {
2
2
  Operation,
3
3
  Webhook
4
- } from "./chunk-55H65L6J.js";
4
+ } from "./chunk-JCBISKOK.js";
5
5
  import {
6
6
  SERVER_VARIABLE_REGEX,
7
7
  decorateComponentSchemasWithRefName,
8
8
  dereferenceRef,
9
9
  getDereferencingOptions,
10
10
  supportedMethods
11
- } from "./chunk-7BR3G6FM.js";
11
+ } from "./chunk-QINBUHP2.js";
12
12
  import {
13
13
  CODE_SAMPLES,
14
14
  HEADERS,
@@ -23,7 +23,7 @@ import {
23
23
  import {
24
24
  isOpenAPI31,
25
25
  isRef
26
- } from "./chunk-MNOEMVCF.js";
26
+ } from "./chunk-PSNTODZL.js";
27
27
 
28
28
  // src/index.ts
29
29
  import { dereference } from "@readme/openapi-parser";
@@ -856,4 +856,4 @@ var Oas = class _Oas {
856
856
  export {
857
857
  Oas
858
858
  };
859
- //# sourceMappingURL=chunk-WRZUJO3I.js.map
859
+ //# sourceMappingURL=chunk-2J4VKLIT.js.map
@@ -21,4 +21,4 @@ function isSchema(check, isPolymorphicAllOfChild = false) {
21
21
 
22
22
 
23
23
  exports.isRef = isRef; exports.isSwagger = isSwagger; exports.isOpenAPI30 = isOpenAPI30; exports.isOpenAPI31 = isOpenAPI31; exports.isSchema = isSchema;
24
- //# sourceMappingURL=chunk-YPR7YTHM.cjs.map
24
+ //# sourceMappingURL=chunk-3MTU2ESP.cjs.map
@@ -1 +1 @@
1
- {"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-YPR7YTHM.cjs","../src/types.ts"],"names":[],"mappings":"AAAA;ACGA;AACE;AACA;AACA;AAAa,mEACR;AAQA,SAAS,KAAA,CAAM,KAAA,EAAkF;AACtG,EAAA,OAAO,uBAAQ,KAAA,2BAAmE,OAAA,IAAS,QAAA;AAC7F;AAMO,IAAM,UAAA,EAA2D,qBAAA;AAMjE,IAAM,YAAA,EAA6D,uBAAA;AAMnE,IAAM,YAAA,EAA+D,uBAAA;AA4NrE,SAAS,QAAA,CAAS,KAAA,EAAgB,wBAAA,EAA0B,KAAA,EAA8B;AAC/F,EAAA,OACG,KAAA,CAAuB,KAAA,IAAS,KAAA,EAAA,GAChC,KAAA,CAAuB,MAAA,IAAU,KAAA,EAAA,GACjC,KAAA,CAAuB,MAAA,IAAU,KAAA,EAAA,GACjC,KAAA,CAAuB,MAAA,IAAU,KAAA,EAAA,GAClC,uBAAA;AAEJ;ADxPA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,wJAAC","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-YPR7YTHM.cjs","sourcesContent":[null,"import type { JSONSchema4, JSONSchema6, JSONSchema7 } from 'json-schema';\nimport type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\nimport {\n isOpenAPI30 as assertOpenAPI30,\n isOpenAPI31 as assertOpenAPI31,\n isSwagger as assertSwagger,\n} from '@readme/openapi-parser/lib/assertions';\n\nexport type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;\n\n/**\n * @param check Data to determine if it contains a ReferenceObject (`$ref` pointer`).\n * @returns If the supplied data has a `$ref` pointer.\n */\nexport function isRef(check: unknown): check is OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject {\n return typeof (check as OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject)?.$ref === 'string';\n}\n\n/**\n * Is a given object a Swagger API definition?\n *\n */\nexport const isSwagger: (schema: any) => schema is OpenAPIV2.Document = assertSwagger;\n\n/**\n * Is a given object an OpenAPI 3.0 API definition?\n *\n */\nexport const isOpenAPI30: (schema: any) => schema is OpenAPIV3.Document = assertOpenAPI30;\n\n/**\n * Is a given object an OpenAPI 3.1 API definition?\n *\n */\nexport const isOpenAPI31: (schema: any) => schema is OpenAPIV3_1.Document = assertOpenAPI31;\n\n/**\n * Data shape for taking OpenAPI operation data and converting it into HAR.\n *\n * @see {@link https://github.com/readmeio/oas/tree/main/packages/oas-to-har}\n */\nexport interface DataForHAR {\n body?: any;\n cookie?: Record<string, any>;\n formData?: Record<string, any>; // `application/x-www-form-urlencoded` requests payloads.\n header?: Record<string, any>;\n path?: Record<string, any>;\n query?: Record<string, any>;\n server?: {\n selected: number;\n variables?: ServerVariable;\n };\n}\n\nexport type AuthForHAR = Record<string, number | string | { pass?: string; user?: string }>;\n\nexport interface User {\n [key: string]: unknown;\n keys?: {\n [key: string]: unknown;\n name: number | string;\n pass?: number | string;\n user?: number | string;\n }[];\n}\n\n/**\n * The type of security scheme. Used by `operation.getSecurityWithTypes()` and `operation.prepareSecurity()`.\n */\nexport type SecurityType = 'apiKey' | 'Basic' | 'Bearer' | 'Cookie' | 'Header' | 'http' | 'OAuth2' | 'Query';\n\nexport type HttpMethods =\n | OpenAPIV3_1.HttpMethods\n | OpenAPIV3.HttpMethods\n | 'delete'\n | 'get'\n | 'head'\n | 'options'\n | 'patch'\n | 'post'\n | 'put'\n | 'trace';\n\n// The following are custom OpenAPI types that we use throughout this library, sans\n// `ReferenceObject` because we assume that the API definition has been dereferenced.\n//\n// These are organized by how they're defined in the OpenAPI Specification.\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n */\nexport type OASDocument = (OpenAPIV3_1.Document | OpenAPIV3.Document) &\n // `x-*` extensions\n Record<string, unknown>;\n\nexport type OAS31Document = OpenAPIV3_1.Document &\n // `x-*` extensions\n Record<string, unknown>;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#server-object}\n */\nexport type ServerObject = OpenAPIV3_1.ServerObject | OpenAPIV3.ServerObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-variable-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#server-variable-object}\n */\nexport type ServerVariableObject = OpenAPIV3_1.ServerVariableObject | OpenAPIV3.ServerVariableObject;\nexport type ServerVariablesObject = Record<string, ServerVariableObject>;\nexport type ServerVariable = Record<\n string,\n { default?: number | string }[] | Record<string, never> | number | string | { default?: number | string }\n>;\n\nexport interface Servers {\n selected: number;\n variables: ServerVariable;\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#components-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#components-object}\n */\nexport type ComponentsObject = OpenAPIV3_1.ComponentsObject | OpenAPIV3.ComponentsObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object}\n */\nexport type ReferenceObject = OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject;\n\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 */\nexport type PathsObject = OpenAPIV3_1.PathsObject | OpenAPIV3.PathsObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#path-item-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object}\n */\nexport type PathItemObject = OpenAPIV3_1.PathItemObject | OpenAPIV3.PathItemObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object}\n */\nexport type OperationObject = (OpenAPIV3_1.OperationObject | OpenAPIV3.OperationObject) &\n // `x-*` extensions\n Record<string, unknown>;\n\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 type ParameterObject = {\n in: 'cookie' | 'header' | 'path' | 'query';\n} & (OpenAPIV3_1.ParameterObject | OpenAPIV3.ParameterObject);\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#request-body-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object}\n */\nexport type RequestBodyObject = OpenAPIV3_1.RequestBodyObject | OpenAPIV3.RequestBodyObject;\n\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 */\nexport type MediaTypeObject = OpenAPIV3_1.MediaTypeObject | OpenAPIV3.MediaTypeObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#response-object}\n */\nexport type ResponseObject = OpenAPIV3_1.ResponseObject | OpenAPIV3.ResponseObject;\n\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 */\nexport type CallbackObject = OpenAPIV3_1.CallbackObject | OpenAPIV3.CallbackObject;\n\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.3.md#example-object}\n */\nexport type ExampleObject = OpenAPIV3_1.ExampleObject | OpenAPIV3.ExampleObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#tag-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#tag-object}\n */\nexport type TagObject = OpenAPIV3_1.TagObject | OpenAPIV3.TagObject;\n\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.0.md#header-object}\n */\nexport type HeaderObject = OpenAPIV3_1.HeaderObject | OpenAPIV3.HeaderObject;\n\n/**\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 */\nexport type SchemaObject = {\n // OpenAPI-specific properties\n externalDocs?: unknown;\n xml?: unknown;\n} & {\n // TODO: We should split this into one type for v3 and one type for v3.1 to ensure type accuracy.\n $schema?: string;\n\n // We add this to the schema to help out with circular refs\n components?: OpenAPIV3_1.ComponentsObject;\n\n deprecated?: boolean;\n example?: unknown;\n examples?: unknown[];\n nullable?: boolean;\n readOnly?: boolean;\n writeOnly?: boolean;\n\n // `discriminator` comes through in `OpenAPIV3.SchemaObject` but because we also union this type\n // to `JSONSchema` TS gets confused when we narrow types everywhere and doens't pick up valid\n // `discriminator` types when we need them.\n discriminator?: DiscriminatorObject;\n\n // We add this extension within our dereferencing work to preserve the origin dereferenced\n // schemas.\n 'x-readme-ref-name'?: string;\n} & (\n | OpenAPIV3.SchemaObject\n | OpenAPIV3_1.SchemaObject\n // Adding `JSONSchema` to this because `json-schema-merge-allof` expects those.\n | JSONSchema\n );\n\nexport interface SchemaWrapper {\n $schema?: string;\n description?: string;\n label?: string;\n schema: SchemaObject;\n type: string;\n}\n\n/**\n * @param check JSON Schema object to determine if it's a non-polymorphic schema.\n * @param isPolymorphicAllOfChild If this JSON Schema object is the child of a polymorphic `allOf`.\n * @returns If the JSON Schema object is a JSON Schema object.\n */\nexport function isSchema(check: unknown, isPolymorphicAllOfChild = false): check is SchemaObject {\n return (\n (check as SchemaObject).type !== undefined ||\n (check as SchemaObject).allOf !== undefined ||\n (check as SchemaObject).anyOf !== undefined ||\n (check as SchemaObject).oneOf !== undefined ||\n isPolymorphicAllOfChild\n );\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object}\n */\nexport type SecuritySchemeObject = OpenAPIV3_1.SecuritySchemeObject | OpenAPIV3.SecuritySchemeObject;\n\nexport type SecuritySchemesObject = Record<string, SecuritySchemeObject>;\n\nexport type KeyedSecuritySchemeObject = SecuritySchemeObject & {\n /**\n * The key for the given security scheme object\n */\n _key: string;\n\n /**\n * An array of required scopes for the given security scheme object.\n * Used for `oauth2` security scheme types.\n */\n _requirements?: string[];\n\n // `x-default` is our custom extension for specifying auth defaults.\n // https://docs.readme.com/docs/openapi-extensions#authentication-defaults\n 'x-default'?: number | string;\n};\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-requirement-object}\n */\nexport type SecurityRequirementObject = OpenAPIV3_1.SecurityRequirementObject | OpenAPIV3.SecurityRequirementObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminator-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#discriminator-object}\n */\nexport type DiscriminatorObject = OpenAPIV3.DiscriminatorObject | OpenAPIV3_1.DiscriminatorObject;\n\n/**\n * Mapping of discriminator schema names to their child schema names.\n * Used to pass information between the pre-dereference and post-dereference phases.\n */\nexport type DiscriminatorChildrenMap = Map<string, string[]>;\n"]}
1
+ {"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-3MTU2ESP.cjs","../src/types.ts"],"names":[],"mappings":"AAAA;ACGA;AACE;AACA;AACA;AAAa,mEACR;AAQA,SAAS,KAAA,CAAM,KAAA,EAAkF;AACtG,EAAA,OAAO,uBAAQ,KAAA,2BAAmE,OAAA,IAAS,QAAA;AAC7F;AAMO,IAAM,UAAA,EAA2D,qBAAA;AAMjE,IAAM,YAAA,EAA6D,uBAAA;AAMnE,IAAM,YAAA,EAA+D,uBAAA;AA+NrE,SAAS,QAAA,CAAS,KAAA,EAAgB,wBAAA,EAA0B,KAAA,EAA8B;AAC/F,EAAA,OACG,KAAA,CAAuB,KAAA,IAAS,KAAA,EAAA,GAChC,KAAA,CAAuB,MAAA,IAAU,KAAA,EAAA,GACjC,KAAA,CAAuB,MAAA,IAAU,KAAA,EAAA,GACjC,KAAA,CAAuB,MAAA,IAAU,KAAA,EAAA,GAClC,uBAAA;AAEJ;AD3PA;AACA;AACE;AACA;AACA;AACA;AACA;AACF,wJAAC","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-3MTU2ESP.cjs","sourcesContent":[null,"import type { JSONSchema4, JSONSchema6, JSONSchema7 } from 'json-schema';\nimport type { OpenAPIV2, OpenAPIV3, OpenAPIV3_1 } from 'openapi-types';\n\nimport {\n isOpenAPI30 as assertOpenAPI30,\n isOpenAPI31 as assertOpenAPI31,\n isSwagger as assertSwagger,\n} from '@readme/openapi-parser/lib/assertions';\n\nexport type JSONSchema = JSONSchema4 | JSONSchema6 | JSONSchema7;\n\n/**\n * @param check Data to determine if it contains a ReferenceObject (`$ref` pointer`).\n * @returns If the supplied data has a `$ref` pointer.\n */\nexport function isRef(check: unknown): check is OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject {\n return typeof (check as OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject)?.$ref === 'string';\n}\n\n/**\n * Is a given object a Swagger API definition?\n *\n */\nexport const isSwagger: (schema: any) => schema is OpenAPIV2.Document = assertSwagger;\n\n/**\n * Is a given object an OpenAPI 3.0 API definition?\n *\n */\nexport const isOpenAPI30: (schema: any) => schema is OpenAPIV3.Document = assertOpenAPI30;\n\n/**\n * Is a given object an OpenAPI 3.1 API definition?\n *\n */\nexport const isOpenAPI31: (schema: any) => schema is OpenAPIV3_1.Document = assertOpenAPI31;\n\n/**\n * Data shape for taking OpenAPI operation data and converting it into HAR.\n *\n * @see {@link https://github.com/readmeio/oas/tree/main/packages/oas-to-har}\n */\nexport interface DataForHAR {\n body?: any;\n cookie?: Record<string, any>;\n formData?: Record<string, any>; // `application/x-www-form-urlencoded` requests payloads.\n header?: Record<string, any>;\n path?: Record<string, any>;\n query?: Record<string, any>;\n server?: {\n selected: number;\n variables?: ServerVariable;\n };\n}\n\nexport type AuthForHAR = Record<string, number | string | { pass?: string; user?: string }>;\n\nexport interface User {\n [key: string]: unknown;\n keys?: {\n [key: string]: unknown;\n name: number | string;\n pass?: number | string;\n user?: number | string;\n }[];\n}\n\n/**\n * The type of security scheme. Used by `operation.getSecurityWithTypes()` and `operation.prepareSecurity()`.\n */\nexport type SecurityType = 'apiKey' | 'Basic' | 'Bearer' | 'Cookie' | 'Header' | 'http' | 'OAuth2' | 'Query';\n\nexport type HttpMethods =\n | OpenAPIV3_1.HttpMethods\n | OpenAPIV3.HttpMethods\n | 'delete'\n | 'get'\n | 'head'\n | 'options'\n | 'patch'\n | 'post'\n | 'put'\n | 'trace';\n\n// The following are custom OpenAPI types that we use throughout this library, sans\n// `ReferenceObject` because we assume that the API definition has been dereferenced.\n//\n// These are organized by how they're defined in the OpenAPI Specification.\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#openapi-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#openapi-object}\n */\nexport type OASDocument = (OpenAPIV3_1.Document | OpenAPIV3.Document) &\n // `x-*` extensions\n Record<string, unknown>;\n\nexport type OAS31Document = OpenAPIV3_1.Document &\n // `x-*` extensions\n Record<string, unknown>;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#server-object}\n */\nexport type ServerObject = OpenAPIV3_1.ServerObject | OpenAPIV3.ServerObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#server-variable-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#server-variable-object}\n */\nexport type ServerVariableObject = OpenAPIV3_1.ServerVariableObject | OpenAPIV3.ServerVariableObject;\nexport type ServerVariablesObject = Record<string, ServerVariableObject>;\nexport type ServerVariable = Record<\n string,\n { default?: number | string }[] | Record<string, never> | number | string | { default?: number | string }\n>;\n\nexport interface Servers {\n selected: number;\n variables: ServerVariable;\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#components-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#components-object}\n */\nexport type ComponentsObject = OpenAPIV3_1.ComponentsObject | OpenAPIV3.ComponentsObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#reference-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#reference-object}\n */\nexport type ReferenceObject = OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject;\n\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 */\nexport type PathsObject = OpenAPIV3_1.PathsObject | OpenAPIV3.PathsObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#path-item-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#path-item-object}\n */\nexport type PathItemObject = OpenAPIV3_1.PathItemObject | OpenAPIV3.PathItemObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#operation-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#operation-object}\n */\nexport type OperationObject = (OpenAPIV3_1.OperationObject | OpenAPIV3.OperationObject) &\n // `x-*` extensions\n Record<string, unknown>;\n\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 type ParameterObject = {\n in: 'cookie' | 'header' | 'path' | 'query';\n} & (OpenAPIV3_1.ParameterObject | OpenAPIV3.ParameterObject);\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#request-body-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#request-body-object}\n */\nexport type RequestBodyObject = OpenAPIV3_1.RequestBodyObject | OpenAPIV3.RequestBodyObject;\n\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 */\nexport type MediaTypeObject = OpenAPIV3_1.MediaTypeObject | OpenAPIV3.MediaTypeObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#response-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#response-object}\n */\nexport type ResponseObject = OpenAPIV3_1.ResponseObject | OpenAPIV3.ResponseObject;\n\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 */\nexport type CallbackObject = OpenAPIV3_1.CallbackObject | OpenAPIV3.CallbackObject;\n\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.3.md#example-object}\n */\nexport type ExampleObject = OpenAPIV3_1.ExampleObject | OpenAPIV3.ExampleObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#tag-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#tag-object}\n */\nexport type TagObject = OpenAPIV3_1.TagObject | OpenAPIV3.TagObject;\n\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.0.md#header-object}\n */\nexport type HeaderObject = OpenAPIV3_1.HeaderObject | OpenAPIV3.HeaderObject;\n\n/**\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 */\nexport type SchemaObject = {\n // OpenAPI-specific properties\n externalDocs?: unknown;\n xml?: unknown;\n} & {\n // TODO: We should split this into one type for v3 and one type for v3.1 to ensure type accuracy.\n $schema?: string;\n\n // We add this to the schema to help out with circular refs\n components?: OpenAPIV3_1.ComponentsObject;\n\n deprecated?: boolean;\n example?: unknown;\n examples?: unknown[];\n nullable?: boolean;\n readOnly?: boolean;\n writeOnly?: boolean;\n\n // `discriminator` comes through in `OpenAPIV3.SchemaObject` but because we also union this type\n // to `JSONSchema` TS gets confused when we narrow types everywhere and doens't pick up valid\n // `discriminator` types when we need them.\n discriminator?: DiscriminatorObject;\n\n // We add this extension within our dereferencing work to preserve the origin dereferenced\n // schemas.\n 'x-readme-ref-name'?: string;\n} & (\n | OpenAPIV3.SchemaObject\n | OpenAPIV3_1.SchemaObject\n // Adding `JSONSchema` to this because `json-schema-merge-allof` expects those.\n | JSONSchema\n );\n\nexport interface SchemaWrapper {\n $schema?: string;\n description?: string;\n label?: string;\n schema: SchemaObject;\n type: string;\n}\n\n/**\n * Determine if a given JSON Schema object is a valid JSON Schema object and either has a declared\n * `type` or is polymorphic in one form or another.\n *\n * @param check JSON Schema object to determine if it's a non-polymorphic schema.\n * @param isPolymorphicAllOfChild If this JSON Schema object is the child of a polymorphic `allOf`.\n * @returns If the JSON Schema object is a JSON Schema object.\n */\nexport function isSchema(check: unknown, isPolymorphicAllOfChild = false): check is SchemaObject {\n return (\n (check as SchemaObject).type !== undefined ||\n (check as SchemaObject).allOf !== undefined ||\n (check as SchemaObject).anyOf !== undefined ||\n (check as SchemaObject).oneOf !== undefined ||\n isPolymorphicAllOfChild\n );\n}\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-scheme-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-scheme-object}\n */\nexport type SecuritySchemeObject = OpenAPIV3_1.SecuritySchemeObject | OpenAPIV3.SecuritySchemeObject;\n\nexport type SecuritySchemesObject = Record<string, SecuritySchemeObject>;\n\nexport type KeyedSecuritySchemeObject = SecuritySchemeObject & {\n /**\n * The key for the given security scheme object\n */\n _key: string;\n\n /**\n * An array of required scopes for the given security scheme object.\n * Used for `oauth2` security scheme types.\n */\n _requirements?: string[];\n\n // `x-default` is our custom extension for specifying auth defaults.\n // https://docs.readme.com/docs/openapi-extensions#authentication-defaults\n 'x-default'?: number | string;\n};\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#security-requirement-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#security-requirement-object}\n */\nexport type SecurityRequirementObject = OpenAPIV3_1.SecurityRequirementObject | OpenAPIV3.SecurityRequirementObject;\n\n/**\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.0.3.md#discriminator-object}\n * @see {@link https://github.com/OAI/OpenAPI-Specification/blob/main/versions/3.1.0.md#discriminator-object}\n */\nexport type DiscriminatorObject = OpenAPIV3.DiscriminatorObject | OpenAPIV3_1.DiscriminatorObject;\n\n/**\n * Mapping of discriminator schema names to their child schema names.\n * Used to pass information between the pre-dereference and post-dereference phases.\n */\nexport type DiscriminatorChildrenMap = Map<string, string[]>;\n"]}