From 0e8587063a0ef1f4a9240124e4a11b78b5510802 Mon Sep 17 00:00:00 2001 From: p1c2u Date: Sat, 10 Jun 2023 09:30:50 +0100 Subject: [PATCH] openapi 3.1 schema update --- .../resources/schemas/v3.1/schema.json | 246 +++++++++++++----- 1 file changed, 174 insertions(+), 72 deletions(-) diff --git a/openapi_spec_validator/resources/schemas/v3.1/schema.json b/openapi_spec_validator/resources/schemas/v3.1/schema.json index 6b1105d..b57b3ba 100644 --- a/openapi_spec_validator/resources/schemas/v3.1/schema.json +++ b/openapi_spec_validator/resources/schemas/v3.1/schema.json @@ -1,6 +1,7 @@ { - "$id": "https://spec.openapis.org/oas/3.1/schema/2021-05-20", + "$id": "https://spec.openapis.org/oas/3.1/schema/2022-10-07", "$schema": "https://json-schema.org/draft/2020-12/schema", + "description": "The description of OpenAPI v3.1.x documents without schema validation, as defined by https://spec.openapis.org/oas/v3.1.0", "type": "object", "properties": { "openapi": { @@ -19,7 +20,12 @@ "type": "array", "items": { "$ref": "#/$defs/server" - } + }, + "default": [ + { + "url": "/" + } + ] }, "paths": { "$ref": "#/$defs/paths" @@ -74,6 +80,7 @@ "unevaluatedProperties": false, "$defs": { "info": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#info-object", "type": "object", "properties": { "title": { @@ -86,7 +93,8 @@ "type": "string" }, "termsOfService": { - "type": "string" + "type": "string", + "format": "uri" }, "contact": { "$ref": "#/$defs/contact" @@ -106,22 +114,26 @@ "unevaluatedProperties": false }, "contact": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#contact-object", "type": "object", "properties": { "name": { "type": "string" }, "url": { - "type": "string" + "type": "string", + "format": "uri" }, "email": { - "type": "string" + "type": "string", + "format": "email" } }, "$ref": "#/$defs/specification-extensions", "unevaluatedProperties": false }, "license": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#license-object", "type": "object", "properties": { "name": { @@ -138,22 +150,20 @@ "required": [ "name" ], - "oneOf": [ - { - "required": [ - "identifier" - ] - }, - { - "required": [ - "url" - ] + "dependentSchemas": { + "identifier": { + "not": { + "required": [ + "url" + ] + } } - ], + }, "$ref": "#/$defs/specification-extensions", "unevaluatedProperties": false }, "server": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#server-object", "type": "object", "properties": { "url": { @@ -177,6 +187,7 @@ "unevaluatedProperties": false }, "server-variable": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#server-variable-object", "type": "object", "properties": { "enum": { @@ -200,6 +211,7 @@ "unevaluatedProperties": false }, "components": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#components-object", "type": "object", "properties": { "schemas": { @@ -275,6 +287,7 @@ "unevaluatedProperties": false }, "paths": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#paths-object", "type": "object", "patternProperties": { "^/": { @@ -285,6 +298,7 @@ "unevaluatedProperties": false }, "path-item": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#path-item-object", "type": "object", "properties": { "summary": { @@ -304,10 +318,29 @@ "items": { "$ref": "#/$defs/parameter-or-reference" } - } - }, - "patternProperties": { - "^(get|put|post|delete|options|head|patch|trace)$": { + }, + "get": { + "$ref": "#/$defs/operation" + }, + "put": { + "$ref": "#/$defs/operation" + }, + "post": { + "$ref": "#/$defs/operation" + }, + "delete": { + "$ref": "#/$defs/operation" + }, + "options": { + "$ref": "#/$defs/operation" + }, + "head": { + "$ref": "#/$defs/operation" + }, + "patch": { + "$ref": "#/$defs/operation" + }, + "trace": { "$ref": "#/$defs/operation" } }, @@ -316,6 +349,7 @@ }, "path-item-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -328,6 +362,7 @@ } }, "operation": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#operation-object", "type": "object", "properties": { "tags": { @@ -387,6 +422,7 @@ "unevaluatedProperties": false }, "external-documentation": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#external-documentation-object", "type": "object", "properties": { "description": { @@ -404,6 +440,7 @@ "unevaluatedProperties": false }, "parameter": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#parameter-object", "type": "object", "properties": { "name": { @@ -428,18 +465,17 @@ "default": false, "type": "boolean" }, - "allowEmptyValue": { - "default": false, - "type": "boolean" - }, "schema": { "$dynamicRef": "#meta" }, "content": { - "$ref": "#/$defs/content" + "$ref": "#/$defs/content", + "minProperties": 1, + "maxProperties": 1 } }, "required": [ + "name", "in" ], "oneOf": [ @@ -454,6 +490,24 @@ ] } ], + "if": { + "properties": { + "in": { + "const": "query" + } + }, + "required": [ + "in" + ] + }, + "then": { + "properties": { + "allowEmptyValue": { + "default": false, + "type": "boolean" + } + } + }, "dependentSchemas": { "schema": { "properties": { @@ -462,10 +516,6 @@ }, "explode": { "type": "boolean" - }, - "allowReserved": { - "default": false, - "type": "boolean" } }, "allOf": [ @@ -502,6 +552,9 @@ }, "then": { "properties": { + "name": { + "pattern": "[^/#?]+$" + }, "style": { "default": "simple", "enum": [ @@ -534,9 +587,7 @@ "properties": { "style": { "default": "simple", - "enum": [ - "simple" - ] + "const": "simple" } } } @@ -562,6 +613,10 @@ "pipeDelimited", "deepObject" ] + }, + "allowReserved": { + "default": false, + "type": "boolean" } } } @@ -581,9 +636,7 @@ "properties": { "style": { "default": "form", - "enum": [ - "form" - ] + "const": "form" } } } @@ -622,6 +675,7 @@ }, "parameter-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -634,6 +688,7 @@ } }, "request-body": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#request-body-object", "type": "object", "properties": { "description": { @@ -655,6 +710,7 @@ }, "request-body-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -667,6 +723,7 @@ } }, "content": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#fixed-fields-10", "type": "object", "additionalProperties": { "$ref": "#/$defs/media-type" @@ -676,6 +733,7 @@ } }, "media-type": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#media-type-object", "type": "object", "properties": { "schema": { @@ -699,6 +757,7 @@ "unevaluatedProperties": false }, "encoding": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#encoding-object", "type": "object", "properties": { "contentType": { @@ -767,6 +826,7 @@ } }, "responses": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#responses-object", "type": "object", "properties": { "default": { @@ -774,14 +834,25 @@ } }, "patternProperties": { - "^[1-5][0-9X]{2}$": { + "^[1-5](?:[0-9]{2}|XX)$": { "$ref": "#/$defs/response-or-reference" } }, + "minProperties": 1, "$ref": "#/$defs/specification-extensions", - "unevaluatedProperties": false + "unevaluatedProperties": false, + "if": { + "$comment": "either default, or at least one response code property must exist", + "patternProperties": { + "^[1-5](?:[0-9]{2}|XX)$": false + } + }, + "then" : { + "required": [ "default" ] + } }, "response": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#response-object", "type": "object", "properties": { "description": { @@ -811,6 +882,7 @@ }, "response-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -823,6 +895,7 @@ } }, "callbacks": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#callback-object", "type": "object", "$ref": "#/$defs/specification-extensions", "additionalProperties": { @@ -831,6 +904,7 @@ }, "callbacks-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -843,6 +917,7 @@ } }, "example": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#example-object", "type": "object", "properties": { "summary": { @@ -857,11 +932,18 @@ "format": "uri" } }, + "not": { + "required": [ + "value", + "externalValue" + ] + }, "$ref": "#/$defs/specification-extensions", "unevaluatedProperties": false }, "example-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -874,13 +956,16 @@ } }, "link": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#link-object", "type": "object", "properties": { "operationRef": { "type": "string", "format": "uri-reference" }, - "operationId": true, + "operationId": { + "type": "string" + }, "parameters": { "$ref": "#/$defs/map-of-strings" }, @@ -909,6 +994,7 @@ }, "link-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -921,6 +1007,7 @@ } }, "header": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#header-object", "type": "object", "properties": { "description": { @@ -934,40 +1021,40 @@ "default": false, "type": "boolean" }, - "allowEmptyValue": { - "default": false, - "type": "boolean" + "schema": { + "$dynamicRef": "#meta" + }, + "content": { + "$ref": "#/$defs/content", + "minProperties": 1, + "maxProperties": 1 } }, + "oneOf": [ + { + "required": [ + "schema" + ] + }, + { + "required": [ + "content" + ] + } + ], "dependentSchemas": { "schema": { "properties": { "style": { "default": "simple", - "enum": [ - "simple" - ] + "const": "simple" }, "explode": { "default": false, "type": "boolean" - }, - "allowReserved": { - "default": false, - "type": "boolean" - }, - "schema": { - "$dynamicRef": "#meta" } }, "$ref": "#/$defs/examples" - }, - "content": { - "properties": { - "content": { - "$ref": "#/$defs/content" - } - } } }, "$ref": "#/$defs/specification-extensions", @@ -975,6 +1062,7 @@ }, "header-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -987,6 +1075,7 @@ } }, "tag": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#tag-object", "type": "object", "properties": { "name": { @@ -1006,6 +1095,7 @@ "unevaluatedProperties": false }, "reference": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#reference-object", "type": "object", "properties": { "$ref": { @@ -1022,6 +1112,7 @@ "unevaluatedProperties": false }, "schema": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#schema-object", "$dynamicAnchor": "meta", "type": [ "object", @@ -1029,6 +1120,7 @@ ] }, "security-scheme": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#security-scheme-object", "type": "object", "properties": { "type": { @@ -1128,7 +1220,8 @@ "const": "http" }, "scheme": { - "const": "bearer" + "type": "string", + "pattern": "^[Bb][Ee][Aa][Rr][Ee][Rr]$" } }, "required": [ @@ -1141,10 +1234,7 @@ "bearerFormat": { "type": "string" } - }, - "required": [ - "scheme" - ] + } } }, "type-oauth2": { @@ -1196,6 +1286,7 @@ }, "security-scheme-or-reference": { "if": { + "type": "object", "required": [ "$ref" ] @@ -1230,10 +1321,12 @@ "type": "object", "properties": { "authorizationUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "refreshUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "scopes": { "$ref": "#/$defs/map-of-strings" @@ -1250,10 +1343,12 @@ "type": "object", "properties": { "tokenUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "refreshUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "scopes": { "$ref": "#/$defs/map-of-strings" @@ -1270,10 +1365,12 @@ "type": "object", "properties": { "tokenUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "refreshUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "scopes": { "$ref": "#/$defs/map-of-strings" @@ -1290,13 +1387,16 @@ "type": "object", "properties": { "authorizationUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "tokenUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "refreshUrl": { - "type": "string" + "type": "string", + "format": "uri" }, "scopes": { "$ref": "#/$defs/map-of-strings" @@ -1313,6 +1413,7 @@ } }, "security-requirement": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#security-requirement-object", "type": "object", "additionalProperties": { "type": "array", @@ -1322,6 +1423,7 @@ } }, "specification-extensions": { + "$comment": "https://spec.openapis.org/oas/v3.1.0#specification-extensions", "patternProperties": { "^x-": true }