OAS3_1 types SchemaProperties updated per JSON Schema draft 2020-12 (#1310)

This commit is contained in:
Jeremy Fiel
2023-10-27 09:17:58 -04:00
committed by GitHub
parent b50ae469c4
commit f83fc54d35
2 changed files with 21 additions and 0 deletions

View File

@@ -0,0 +1,9 @@
---
'@redocly/openapi-core': patch
---
OpenAPI 3.1.x defaults to JSON Schema draft 2020-12 and the value of property names defined in `properties` was updated since OpenAPI 3.0.x and JSON Schema draft-04.
In the new JSON Schema specification, each property value within a `properties` schema accepts a `boolean` or `object` schema.
https://json-schema.org/draft/2020-12/json-schema-core#section-10.3.2.1

View File

@@ -181,6 +181,17 @@ const Schema: NodeType = {
extensionsPrefix: 'x-',
};
const SchemaProperties: NodeType = {
properties: {},
additionalProperties: (value: any) => {
if (typeof value === 'boolean') {
return { type: 'boolean' };
} else {
return 'Schema';
}
},
};
const SecurityScheme: NodeType = {
properties: {
type: { enum: ['apiKey', 'http', 'oauth2', 'openIdConnect', 'mutualTLS'] },
@@ -256,6 +267,7 @@ export const Oas3_1Types: Record<string, NodeType> = {
Info,
Root,
Schema,
SchemaProperties,
License,
Components,
NamedPathItems: mapOf('PathItem'),