oas 28.3.0 → 28.4.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.
- package/dist/analyzer/index.cjs +6 -6
- package/dist/analyzer/index.js +4 -4
- package/dist/chunk-47ELBTA5.js +32 -0
- package/dist/chunk-47ELBTA5.js.map +1 -0
- package/dist/{chunk-GDEE6EQV.cjs → chunk-DUQ3BL5H.cjs} +6 -6
- package/dist/{chunk-GDEE6EQV.cjs.map → chunk-DUQ3BL5H.cjs.map} +1 -1
- package/dist/{chunk-RF2D4VVK.js → chunk-FISLBMFJ.js} +3 -3
- package/dist/{chunk-636SYI6H.cjs → chunk-R33HRXQA.cjs} +27 -27
- package/dist/{chunk-636SYI6H.cjs.map → chunk-R33HRXQA.cjs.map} +1 -1
- package/dist/{chunk-T34XCOTS.js → chunk-SVQE2R3T.js} +4 -4
- package/dist/{chunk-T34XCOTS.js.map → chunk-SVQE2R3T.js.map} +1 -1
- package/dist/{chunk-NIBF7F33.js → chunk-TRLQJSYU.js} +3 -3
- package/dist/chunk-UZVIB6QV.cjs +32 -0
- package/dist/chunk-UZVIB6QV.cjs.map +1 -0
- package/dist/{chunk-G5MSDVMW.cjs → chunk-ZGCROLGH.cjs} +11 -11
- package/dist/chunk-ZGCROLGH.cjs.map +1 -0
- package/dist/index.cjs +5 -5
- package/dist/index.js +4 -4
- package/dist/operation/index.cjs +4 -4
- package/dist/operation/index.js +3 -3
- package/dist/operation/lib/get-parameters-as-json-schema.cjs +3 -3
- package/dist/operation/lib/get-parameters-as-json-schema.js +2 -2
- package/dist/types.cjs +10 -2
- package/dist/types.cjs.map +1 -1
- package/dist/types.d.cts +24 -2
- package/dist/types.d.ts +24 -2
- package/dist/types.js +11 -3
- package/dist/utils.cjs +3 -3
- package/dist/utils.js +2 -2
- package/package.json +4 -4
- package/dist/chunk-EQEXNJJE.cjs +0 -17
- package/dist/chunk-EQEXNJJE.cjs.map +0 -1
- package/dist/chunk-G5MSDVMW.cjs.map +0 -1
- package/dist/chunk-UCEHCARG.js +0 -17
- package/dist/chunk-UCEHCARG.js.map +0 -1
- /package/dist/{chunk-RF2D4VVK.js.map → chunk-FISLBMFJ.js.map} +0 -0
- /package/dist/{chunk-NIBF7F33.js.map → chunk-TRLQJSYU.js.map} +0 -0
|
@@ -3,10 +3,10 @@ import {
|
|
|
3
3
|
getExtension
|
|
4
4
|
} from "./chunk-NBQXNFZT.js";
|
|
5
5
|
import {
|
|
6
|
-
|
|
6
|
+
isOpenAPI30,
|
|
7
7
|
isRef,
|
|
8
8
|
isSchema
|
|
9
|
-
} from "./chunk-
|
|
9
|
+
} from "./chunk-47ELBTA5.js";
|
|
10
10
|
|
|
11
11
|
// src/lib/clone-object.ts
|
|
12
12
|
function cloneObject(obj) {
|
|
@@ -84,7 +84,7 @@ function encodePointer(str) {
|
|
|
84
84
|
return str.replace("~", "~0").replace("/", "~1");
|
|
85
85
|
}
|
|
86
86
|
function getSchemaVersionString(schema, api) {
|
|
87
|
-
if (
|
|
87
|
+
if (isOpenAPI30(api)) {
|
|
88
88
|
return "http://json-schema.org/draft-04/schema#";
|
|
89
89
|
}
|
|
90
90
|
if (schema.$schema) {
|
|
@@ -832,4 +832,4 @@ export {
|
|
|
832
832
|
types,
|
|
833
833
|
getParametersAsJSONSchema
|
|
834
834
|
};
|
|
835
|
-
//# sourceMappingURL=chunk-
|
|
835
|
+
//# sourceMappingURL=chunk-SVQE2R3T.js.map
|
|
@@ -1 +1 @@
|
|
|
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 function cloneObject<T>(obj: T): T {\n if (typeof obj === 'undefined') {\n return undefined;\n }\n\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\n// biome-ignore lint/style/noDefaultExport: This is safe for now.\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","import type { JSONSchema7TypeName } from 'json-schema';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { JSONSchema, OASDocument, RequestBodyObject, SchemaObject } from '../types.js';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\nimport jsonpointer from 'jsonpointer';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport { isOAS31, isRef, isSchema } from '../types.js';\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?: SchemaObject[];\n\n /**\n * Array of parent `example` schemas to utilize when attempting to path together schema examples.\n */\n prevExampleSchemas?: 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: SchemaObject) => 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: SchemaObject, api: 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 (!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: SchemaObject): boolean {\n return 'allOf' in schema || 'anyOf' in schema || 'oneOf' in schema;\n}\n\nfunction isRequestBodySchema(schema: unknown): schema is RequestBodyObject {\n return 'content' in (schema as 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: any;\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 {\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: SchemaObject | boolean, opts: toJSONSchemaOptions = {}): SchemaObject {\n let schema = data === true ? {} : { ...data };\n const schemaAdditionalProperties = 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: 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 (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 (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 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 SchemaObject;\n } catch {\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 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 (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 SchemaObject,\n polyOptions,\n );\n } else if ('items' in schema) {\n schema[polyType][idx] = toJSONSchema(\n { allOf: [item, { items: schema.items }] } as SchemaObject,\n polyOptions,\n );\n } else {\n schema[polyType][idx] = toJSONSchema(item as 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 (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 && 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 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 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 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 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 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 {\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 (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(v => v !== undefined && (typeof v !== 'string' || v.trim() !== ''))\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 { OpenAPIV3_1 } from 'openapi-types';\nimport 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';\n\nimport { getExtension, PARAMETER_ORDERING } from '../../extensions.js';\nimport { cloneObject } from '../../lib/clone-object.js';\nimport { isPrimitive } from '../../lib/helpers.js';\nimport matchesMimetype from '../../lib/matches-mimetype.js';\nimport { getSchemaVersionString, toJSONSchema } 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: string;\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":";;;;;;;;;;;AAAO,SAAS,YAAe,KAAW;AACxC,MAAI,OAAO,QAAQ,aAAa;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CA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,QAAI,cAAc,yBAAyB;AAEzC,MAAC,MAAM,OAAO,aAAkC;AAAA,IAClD;AAGA,QAAI,CAAC,MAAM,gBAAiB,QAAO,MAAM;AAEzC,WAAO;AAAA,EACT,CAAC,EACA,KAAK,CAAC,GAAG,MAAM;AACd,WAAO,SAAS,QAAQ,EAAE,IAAI,IAAI,SAAS,QAAQ,EAAE,IAAI;AAAA,EAC3D,CAAC;AACL;","names":["types","components","schema"]}
|
|
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 function cloneObject<T>(obj: T): T {\n if (typeof obj === 'undefined') {\n return undefined;\n }\n\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\n// biome-ignore lint/style/noDefaultExport: This is safe for now.\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","import type { JSONSchema7TypeName } from 'json-schema';\nimport type { OpenAPIV3_1 } from 'openapi-types';\nimport type { JSONSchema, OASDocument, RequestBodyObject, SchemaObject } from '../types.js';\n\nimport mergeJSONSchemaAllOf from 'json-schema-merge-allof';\nimport jsonpointer from 'jsonpointer';\nimport removeUndefinedObjects from 'remove-undefined-objects';\n\nimport { isOpenAPI30, isRef, isSchema } from '../types.js';\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?: SchemaObject[];\n\n /**\n * Array of parent `example` schemas to utilize when attempting to path together schema examples.\n */\n prevExampleSchemas?: 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: SchemaObject) => 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: SchemaObject, api: OASDocument): string {\n // If we're not on OpenAPI 3.1+ then we should fall back to the default schema version.\n if (isOpenAPI30(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 `isOpenAPI30` 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: SchemaObject): boolean {\n return 'allOf' in schema || 'anyOf' in schema || 'oneOf' in schema;\n}\n\nfunction isRequestBodySchema(schema: unknown): schema is RequestBodyObject {\n return 'content' in (schema as 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: any;\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 {\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: SchemaObject | boolean, opts: toJSONSchemaOptions = {}): SchemaObject {\n let schema = data === true ? {} : { ...data };\n const schemaAdditionalProperties = 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: 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 (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 (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 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 SchemaObject;\n } catch {\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 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 (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 SchemaObject,\n polyOptions,\n );\n } else if ('items' in schema) {\n schema[polyType][idx] = toJSONSchema(\n { allOf: [item, { items: schema.items }] } as SchemaObject,\n polyOptions,\n );\n } else {\n schema[polyType][idx] = toJSONSchema(item as 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 (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 && 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 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 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 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 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 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 {\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 (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(v => v !== undefined && (typeof v !== 'string' || v.trim() !== ''))\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 { OpenAPIV3_1 } from 'openapi-types';\nimport 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';\n\nimport { getExtension, PARAMETER_ORDERING } from '../../extensions.js';\nimport { cloneObject } from '../../lib/clone-object.js';\nimport { isPrimitive } from '../../lib/helpers.js';\nimport matchesMimetype from '../../lib/matches-mimetype.js';\nimport { getSchemaVersionString, toJSONSchema } 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: string;\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":";;;;;;;;;;;AAAO,SAAS,YAAe,KAAW;AACxC,MAAI,OAAO,QAAQ,aAAa;AAC9B,WAAO;AAAA,EACT;AAEA,SAAO,KAAK,MAAM,KAAK,UAAU,GAAG,CAAC;AACvC;;;ACJO,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;AAGA,IAAO,2BAAQ;AAAA,EACb,gBAAgB,CAAC,aAA8B;AAC7C,WAAO,iBAAiB,CAAC,mCAAmC,GAAG,QAAQ;AAAA,EACzE;AAAA,EAEA,MAAM,CAAC,gB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,QACA,iBAAiB,gBAAgB,SAC7B;AAAA,UACE,MAAM;AAAA,UACN,QAAQ;AAAA,YACN,OAAO;AAAA,UACT;AAAA,QACF,IACA;AAAA,MACN;AAAA,IACF;AAAA,EACF;AAIA,MAAI,CAAC,UAAU,cAAc,KAAK,CAAC,UAAU,eAAe,GAAG;AAC7D,WAAO;AAAA,EACT;AAKA,QAAM,WAAY,aAAa,oBAAoB,KAAK,SAAS,EAAe,IAAI,OAAK,EAAE,YAAY,CAAC;AACxG,WAAS,SAAS,QAAQ,MAAM,CAAC,IAAI;AACrC,WAAS,KAAK,UAAU;AAExB,QAAM,aAAa,CAAC,qBAAqB,CAAC,EAAE,OAAO,GAAG,oBAAoB,CAAC,EAAE,OAAO,OAAO;AAK3F,QAAM,0BACJ,mBAAoB,+BAA+B,KAAK;AAE1D,QAAM,aAAa,0BAA0B,oBAAoB,IAAI;AAErE,SAAO,WACJ,IAAI,WAAS;AAQZ,QAAI,cAAc,yBAAyB;AAEzC,MAAC,MAAM,OAAO,aAAkC;AAAA,IAClD;AAGA,QAAI,CAAC,MAAM,gBAAiB,QAAO,MAAM;AAEzC,WAAO;AAAA,EACT,CAAC,EACA,KAAK,CAAC,GAAG,MAAM;AACd,WAAO,SAAS,QAAQ,EAAE,IAAI,IAAI,SAAS,QAAQ,EAAE,IAAI;AAAA,EAC3D,CAAC;AACL;","names":["types","components","schema"]}
|
|
@@ -1,14 +1,14 @@
|
|
|
1
1
|
import {
|
|
2
2
|
Operation,
|
|
3
3
|
Webhook
|
|
4
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-FISLBMFJ.js";
|
|
5
5
|
import {
|
|
6
6
|
findSchemaDefinition,
|
|
7
7
|
supportedMethods
|
|
8
8
|
} from "./chunk-W3LSKLU6.js";
|
|
9
9
|
import {
|
|
10
10
|
isPrimitive
|
|
11
|
-
} from "./chunk-
|
|
11
|
+
} from "./chunk-SVQE2R3T.js";
|
|
12
12
|
import {
|
|
13
13
|
CODE_SAMPLES,
|
|
14
14
|
HEADERS,
|
|
@@ -785,4 +785,4 @@ var Oas = class _Oas {
|
|
|
785
785
|
export {
|
|
786
786
|
Oas
|
|
787
787
|
};
|
|
788
|
-
//# sourceMappingURL=chunk-
|
|
788
|
+
//# sourceMappingURL=chunk-TRLQJSYU.js.map
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
"use strict";Object.defineProperty(exports, "__esModule", {value: true});// src/types.ts
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
var _assertions = require('@readme/openapi-parser/lib/assertions');
|
|
7
|
+
function isRef(check) {
|
|
8
|
+
return check.$ref !== void 0;
|
|
9
|
+
}
|
|
10
|
+
var isSwagger = _assertions.isSwagger;
|
|
11
|
+
var isOpenAPI30 = _assertions.isOpenAPI30;
|
|
12
|
+
function isOAS30(check) {
|
|
13
|
+
return "openapi" in check && check.openapi !== void 0 && check.openapi.startsWith("3.0");
|
|
14
|
+
}
|
|
15
|
+
var isOpenAPI31 = _assertions.isOpenAPI31;
|
|
16
|
+
function isOAS31(check) {
|
|
17
|
+
return "openapi" in check && check.openapi !== void 0 && check.openapi.startsWith("3.1");
|
|
18
|
+
}
|
|
19
|
+
function isSchema(check, isPolymorphicAllOfChild = false) {
|
|
20
|
+
return check.type !== void 0 || check.allOf !== void 0 || check.anyOf !== void 0 || check.oneOf !== void 0 || isPolymorphicAllOfChild;
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
|
|
28
|
+
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
exports.isRef = isRef; exports.isSwagger = isSwagger; exports.isOpenAPI30 = isOpenAPI30; exports.isOAS30 = isOAS30; exports.isOpenAPI31 = isOpenAPI31; exports.isOAS31 = isOAS31; exports.isSchema = isSchema;
|
|
32
|
+
//# sourceMappingURL=chunk-UZVIB6QV.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["/Users/erunion/code/readme/oas/packages/oas/dist/chunk-UZVIB6QV.cjs","../src/types.ts"],"names":[],"mappings":"AAAA;ACGA;AACE;AACA;AACA;AAAa,mEACR;AAQA,SAAS,KAAA,CAAM,KAAA,EAAkF;AACtG,EAAA,OAAQ,KAAA,CAAkE,KAAA,IAAS,KAAA,CAAA;AACrF;AAMO,IAAM,UAAA,EAA2D,qBAAA;AAMjE,IAAM,YAAA,EAA6D,uBAAA;AAOnE,SAAS,OAAA,CAAQ,KAAA,EAA+E;AACrG,EAAA,OAAO,UAAA,GAAa,MAAA,GAAS,KAAA,CAAM,QAAA,IAAY,KAAA,EAAA,GAAa,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW,KAAK,CAAA;AAC5F;AAMO,IAAM,YAAA,EAA+D,uBAAA;AAOrE,SAAS,OAAA,CAAQ,KAAA,EAAiF;AACvG,EAAA,OAAO,UAAA,GAAa,MAAA,GAAS,KAAA,CAAM,QAAA,IAAY,KAAA,EAAA,GAAa,KAAA,CAAM,OAAA,CAAQ,UAAA,CAAW,KAAK,CAAA;AAC5F;AAyMO,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;ADjPA;AACA;AACE;AACA;AACA;AACA;AACA;AACA;AACA;AACF,8MAAC","file":"/Users/erunion/code/readme/oas/packages/oas/dist/chunk-UZVIB6QV.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 (check as OpenAPIV3_1.ReferenceObject | OpenAPIV3.ReferenceObject).$ref !== undefined;\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 * @param check API definition to determine if it's a 3.0 definition.\n * @returns If the definition is a 3.0 definition.\n * @deprecated Use `isOpenAPI30` instead. This function will be removed in the next major version.\n */\nexport function isOAS30(check: OpenAPIV3_1.Document | OpenAPIV3.Document): check is OpenAPIV3.Document {\n return 'openapi' in check && check.openapi !== undefined && check.openapi.startsWith('3.0');\n}\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 * @param check API definition to determine if it's a 3.1 definition.\n * @returns If the definition is a 3.1 definition.\n * @deprecated Use `isOpenAPI31` instead. This function will be removed in the next major version.\n */\nexport function isOAS31(check: OpenAPIV3_1.Document | OpenAPIV3.Document): check is OpenAPIV3_1.Document {\n return 'openapi' in check && check.openapi !== undefined && check.openapi.startsWith('3.1');\n}\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#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 // 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\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"]}
|
|
@@ -6,7 +6,7 @@ var _chunk6JSHPV2Ocjs = require('./chunk-6JSHPV2O.cjs');
|
|
|
6
6
|
|
|
7
7
|
|
|
8
8
|
|
|
9
|
-
var
|
|
9
|
+
var _chunkUZVIB6QVcjs = require('./chunk-UZVIB6QV.cjs');
|
|
10
10
|
|
|
11
11
|
// src/lib/clone-object.ts
|
|
12
12
|
function cloneObject(obj) {
|
|
@@ -84,7 +84,7 @@ function encodePointer(str) {
|
|
|
84
84
|
return str.replace("~", "~0").replace("/", "~1");
|
|
85
85
|
}
|
|
86
86
|
function getSchemaVersionString(schema, api) {
|
|
87
|
-
if (
|
|
87
|
+
if (_chunkUZVIB6QVcjs.isOpenAPI30.call(void 0, api)) {
|
|
88
88
|
return "http://json-schema.org/draft-04/schema#";
|
|
89
89
|
}
|
|
90
90
|
if (schema.$schema) {
|
|
@@ -145,7 +145,7 @@ function searchForValueByPropAndPointer(property, pointer, schemas = []) {
|
|
|
145
145
|
}
|
|
146
146
|
function toJSONSchema(data, opts = {}) {
|
|
147
147
|
let schema = data === true ? {} : { ...data };
|
|
148
|
-
const schemaAdditionalProperties =
|
|
148
|
+
const schemaAdditionalProperties = _chunkUZVIB6QVcjs.isSchema.call(void 0, schema) ? schema.additionalProperties : null;
|
|
149
149
|
const {
|
|
150
150
|
addEnumsToDescriptions,
|
|
151
151
|
currentLocation,
|
|
@@ -170,13 +170,13 @@ function toJSONSchema(data, opts = {}) {
|
|
|
170
170
|
transformer: (s) => s,
|
|
171
171
|
...opts
|
|
172
172
|
};
|
|
173
|
-
if (
|
|
173
|
+
if (_chunkUZVIB6QVcjs.isRef.call(void 0, schema)) {
|
|
174
174
|
refLogger(schema.$ref, "ref");
|
|
175
175
|
return transformer({
|
|
176
176
|
$ref: schema.$ref
|
|
177
177
|
});
|
|
178
178
|
}
|
|
179
|
-
if (
|
|
179
|
+
if (_chunkUZVIB6QVcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild)) {
|
|
180
180
|
if ("allOf" in schema && Array.isArray(schema.allOf)) {
|
|
181
181
|
try {
|
|
182
182
|
schema = _jsonschemamergeallof2.default.call(void 0, schema, {
|
|
@@ -211,7 +211,7 @@ function toJSONSchema(data, opts = {}) {
|
|
|
211
211
|
schema = schemaWithoutAllOf;
|
|
212
212
|
delete schema.allOf;
|
|
213
213
|
}
|
|
214
|
-
if (
|
|
214
|
+
if (_chunkUZVIB6QVcjs.isRef.call(void 0, schema)) {
|
|
215
215
|
refLogger(schema.$ref, "ref");
|
|
216
216
|
return transformer({
|
|
217
217
|
$ref: schema.$ref
|
|
@@ -356,7 +356,7 @@ function toJSONSchema(data, opts = {}) {
|
|
|
356
356
|
}
|
|
357
357
|
}
|
|
358
358
|
}
|
|
359
|
-
if (
|
|
359
|
+
if (_chunkUZVIB6QVcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild)) {
|
|
360
360
|
if ("default" in schema && isObject(schema.default)) {
|
|
361
361
|
prevDefaultSchemas.push({ default: schema.default });
|
|
362
362
|
}
|
|
@@ -415,7 +415,7 @@ function toJSONSchema(data, opts = {}) {
|
|
|
415
415
|
}
|
|
416
416
|
if (hasSchemaType(schema, "array")) {
|
|
417
417
|
if ("items" in schema) {
|
|
418
|
-
if (!Array.isArray(schema.items) && Object.keys(schema.items).length === 1 &&
|
|
418
|
+
if (!Array.isArray(schema.items) && Object.keys(schema.items).length === 1 && _chunkUZVIB6QVcjs.isRef.call(void 0, schema.items)) {
|
|
419
419
|
refLogger(schema.items.$ref, "ref");
|
|
420
420
|
} else if (schema.items !== true) {
|
|
421
421
|
schema.items = toJSONSchema(schema.items, {
|
|
@@ -501,7 +501,7 @@ function toJSONSchema(data, opts = {}) {
|
|
|
501
501
|
}
|
|
502
502
|
}
|
|
503
503
|
}
|
|
504
|
-
if (
|
|
504
|
+
if (_chunkUZVIB6QVcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild) && globalDefaults && Object.keys(globalDefaults).length > 0 && currentLocation) {
|
|
505
505
|
try {
|
|
506
506
|
const userJwtDefault = _jsonpointer2.default.get(globalDefaults, currentLocation);
|
|
507
507
|
if (userJwtDefault) {
|
|
@@ -523,7 +523,7 @@ function toJSONSchema(data, opts = {}) {
|
|
|
523
523
|
schema.default = foundDefault;
|
|
524
524
|
}
|
|
525
525
|
}
|
|
526
|
-
if (
|
|
526
|
+
if (_chunkUZVIB6QVcjs.isSchema.call(void 0, schema, isPolymorphicAllOfChild) && "enum" in schema && Array.isArray(schema.enum)) {
|
|
527
527
|
schema.enum = Array.from(new Set(schema.enum));
|
|
528
528
|
if (addEnumsToDescriptions) {
|
|
529
529
|
const enums = schema.enum.filter((v) => v !== void 0 && (typeof v !== "string" || v.trim() !== "")).map((str) => `\`${str}\``).join(" ");
|
|
@@ -832,4 +832,4 @@ function getParametersAsJSONSchema(operation, api, opts) {
|
|
|
832
832
|
|
|
833
833
|
|
|
834
834
|
exports.isObject = isObject; exports.isPrimitive = isPrimitive; exports.matches_mimetype_default = matches_mimetype_default; exports.cloneObject = cloneObject; exports.getSchemaVersionString = getSchemaVersionString; exports.toJSONSchema = toJSONSchema; exports.types = types; exports.getParametersAsJSONSchema = getParametersAsJSONSchema;
|
|
835
|
-
//# sourceMappingURL=chunk-
|
|
835
|
+
//# sourceMappingURL=chunk-ZGCROLGH.cjs.map
|