Skip to content

Commit

Permalink
fix(types): update unevaluatedItems type defintion
Browse files Browse the repository at this point in the history
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 Redocly#1233
  • Loading branch information
jeremyfiel authored and tatomyr committed Oct 13, 2023
1 parent 4769ca5 commit c7d8ca7
Show file tree
Hide file tree
Showing 3 changed files with 20 additions and 2 deletions.
6 changes: 6 additions & 0 deletions .changeset/slow-lemons-accept.md
Original file line number Diff line number Diff line change
@@ -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
8 changes: 7 additions & 1 deletion packages/core/src/types/asyncapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' };
Expand Down
8 changes: 7 additions & 1 deletion packages/core/src/types/oas3_1.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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' };
Expand Down

0 comments on commit c7d8ca7

Please sign in to comment.