From c22499bc088d2d49bfdfa245379552c1cfcfc2f4 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sat, 9 Oct 2021 21:58:46 -0700 Subject: [PATCH 1/3] move definitions to the single place where they are used this improves readability, and makes it possible to add dependencies between keywords --- schemas/v3.1/meta/base.schema.json | 19 ++++++++----------- schemas/v3.1/meta/base.schema.yaml | 18 ++++++------------ 2 files changed, 14 insertions(+), 23 deletions(-) diff --git a/schemas/v3.1/meta/base.schema.json b/schemas/v3.1/meta/base.schema.json index f3ee03fb96..3656883c32 100644 --- a/schemas/v3.1/meta/base.schema.json +++ b/schemas/v3.1/meta/base.schema.json @@ -10,16 +10,6 @@ "type": ["object", "boolean"], "properties": { "example": true, - "discriminator": { "$ref": "#/$defs/discriminator" }, - "externalDocs": { "$ref": "#/$defs/external-docs" }, - "xml": { "$ref": "#/$defs/xml" } - }, - "$defs": { - "extensible": { - "patternProperties": { - "^x-": true - } - }, "discriminator": { "$ref": "#/$defs/extensible", "type": "object", @@ -37,7 +27,7 @@ "required": ["propertyName"], "unevaluatedProperties": false }, - "external-docs": { + "externalDocs": { "$ref": "#/$defs/extensible", "type": "object", "properties": { @@ -75,5 +65,12 @@ }, "unevaluatedProperties": false } + }, + "$defs": { + "extensible": { + "patternProperties": { + "^x-": true + } + } } } diff --git a/schemas/v3.1/meta/base.schema.yaml b/schemas/v3.1/meta/base.schema.yaml index 80a662a179..63cd48c59d 100644 --- a/schemas/v3.1/meta/base.schema.yaml +++ b/schemas/v3.1/meta/base.schema.yaml @@ -1,5 +1,9 @@ --- $defs: + extensible: + patternProperties: + ^x-: true +properties: discriminator: $ref: '#/$defs/extensible' properties: @@ -13,10 +17,8 @@ $defs: - propertyName type: object unevaluatedProperties: false - extensible: - patternProperties: - ^x-: true - external-docs: + example: true + externalDocs: $ref: '#/$defs/extensible' properties: description: @@ -49,14 +51,6 @@ $id: https://spec.openapis.org/oas/3.1/meta/base $schema: https://json-schema.org/draft/2020-12/schema $vocabulary: https://spec.openapis.org/oas/3.1/vocab/base: true -properties: - discriminator: - $ref: '#/$defs/discriminator' - example: true - externalDocs: - $ref: '#/$defs/external-docs' - xml: - $ref: '#/$defs/xml' title: OAS Base vocabulary type: - object From 4c7d88c15b8bcb3f10ba88ece85188e199d49c2d Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sat, 9 Oct 2021 22:04:36 -0700 Subject: [PATCH 2/3] "example" is deprecated https://spec.openapis.org/oas/v3.1.0#fixed-fields-19 --- schemas/v3.1/meta/base.schema.json | 4 +++- schemas/v3.1/meta/base.schema.yaml | 3 ++- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/schemas/v3.1/meta/base.schema.json b/schemas/v3.1/meta/base.schema.json index 3656883c32..653e23f10c 100644 --- a/schemas/v3.1/meta/base.schema.json +++ b/schemas/v3.1/meta/base.schema.json @@ -9,7 +9,9 @@ "type": ["object", "boolean"], "properties": { - "example": true, + "example": { + "deprecated": true + }, "discriminator": { "$ref": "#/$defs/extensible", "type": "object", diff --git a/schemas/v3.1/meta/base.schema.yaml b/schemas/v3.1/meta/base.schema.yaml index 63cd48c59d..d76c00715c 100644 --- a/schemas/v3.1/meta/base.schema.yaml +++ b/schemas/v3.1/meta/base.schema.yaml @@ -17,7 +17,8 @@ properties: - propertyName type: object unevaluatedProperties: false - example: true + example: + deprecated: true externalDocs: $ref: '#/$defs/extensible' properties: From b1770ad89206853927f09c29a13cae19950c5cd7 Mon Sep 17 00:00:00 2001 From: Karen Etheridge Date: Sat, 9 Oct 2021 22:17:16 -0700 Subject: [PATCH 3/3] "The discriminator object is legal only when using one of the composite keywords oneOf, anyOf, allOf." https://spec.openapis.org/oas/v3.1.0#fixed-fields-20 --- schemas/v3.1/meta/base.schema.json | 12 +++++++++++- schemas/v3.1/meta/base.schema.yaml | 7 +++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/schemas/v3.1/meta/base.schema.json b/schemas/v3.1/meta/base.schema.json index 653e23f10c..cb26bd09de 100644 --- a/schemas/v3.1/meta/base.schema.json +++ b/schemas/v3.1/meta/base.schema.json @@ -22,7 +22,8 @@ "mapping": { "type": "object", "additionalProperties": { - "type": "string" + "type": "string", + "format": "uri-reference" } } }, @@ -68,6 +69,15 @@ "unevaluatedProperties": false } }, + "dependentSchemas": { + "discriminator": { + "anyOf": [ + { "required": [ "oneOf" ] }, + { "required": [ "anyOf" ] }, + { "required": [ "allOf" ] } + ] + } + }, "$defs": { "extensible": { "patternProperties": { diff --git a/schemas/v3.1/meta/base.schema.yaml b/schemas/v3.1/meta/base.schema.yaml index d76c00715c..f5327b2d5a 100644 --- a/schemas/v3.1/meta/base.schema.yaml +++ b/schemas/v3.1/meta/base.schema.yaml @@ -10,6 +10,7 @@ properties: mapping: additionalProperties: type: string + format: uri-reference type: object propertyName: type: string @@ -47,6 +48,12 @@ properties: type: boolean type: object unevaluatedProperties: false +dependentSchemas: + discriminator: + anyOf: + - required: [ oneOf ] + - required: [ anyOf ] + - required: [ allOf ] $dynamicAnchor: meta $id: https://spec.openapis.org/oas/3.1/meta/base $schema: https://json-schema.org/draft/2020-12/schema