From c7d8ca7a75355cbbc3b1caf9a6dbe6284f5c928c Mon Sep 17 00:00:00 2001 From: Jeremy Fiel <32110157+jeremyfiel@users.noreply.github.com> Date: Thu, 12 Oct 2023 15:02:20 +0000 Subject: [PATCH] fix(types): update unevaluatedItems type defintion Per JSON Schema 2019-09+ spec. this annotation keyword can be any valid JSON Schema schema. e.g. `boolean` or `schema` https://json-schema.org/draft/2019-09/json-schema-core#unevaluatedItems partially fixes #1233 --- .changeset/slow-lemons-accept.md | 6 ++++++ packages/core/src/types/asyncapi.ts | 8 +++++++- packages/core/src/types/oas3_1.ts | 8 +++++++- 3 files changed, 20 insertions(+), 2 deletions(-) create mode 100644 .changeset/slow-lemons-accept.md diff --git a/.changeset/slow-lemons-accept.md b/.changeset/slow-lemons-accept.md new file mode 100644 index 000000000..09ef626d4 --- /dev/null +++ b/.changeset/slow-lemons-accept.md @@ -0,0 +1,6 @@ +--- +'@redocly/cli': major +'@redocly/openapi-core': major +--- + +fix(types): update `unevaluatedItems` type definition to resolve either boolean or object schema per JSON Schema 2019-09 specification diff --git a/packages/core/src/types/asyncapi.ts b/packages/core/src/types/asyncapi.ts index 2fb74314f..3dec98618 100644 --- a/packages/core/src/types/asyncapi.ts +++ b/packages/core/src/types/asyncapi.ts @@ -390,7 +390,13 @@ const Schema: NodeType = { maxContains: { type: 'integer', minimum: 0 }, patternProperties: { type: 'object' }, propertyNames: 'Schema', - unevaluatedItems: 'Schema', + unevaluatedItems: (value: unknown) => { + if (typeof value === 'boolean') { + return { type: 'boolean' }; + } else { + return 'Schema'; + } + }, unevaluatedProperties: (value: unknown) => { if (typeof value === 'boolean') { return { type: 'boolean' }; diff --git a/packages/core/src/types/oas3_1.ts b/packages/core/src/types/oas3_1.ts index 4a8a49efd..d9f8adffe 100755 --- a/packages/core/src/types/oas3_1.ts +++ b/packages/core/src/types/oas3_1.ts @@ -137,7 +137,13 @@ const Schema: NodeType = { maxContains: { type: 'integer', minimum: 0 }, patternProperties: { type: 'object' }, propertyNames: 'Schema', - unevaluatedItems: 'Schema', + unevaluatedItems: (value: unknown) => { + if (typeof value === 'boolean') { + return { type: 'boolean' }; + } else { + return 'Schema'; + } + }, unevaluatedProperties: (value: unknown) => { if (typeof value === 'boolean') { return { type: 'boolean' };