From 4dde683358e5e70d11b454e1f7c321ac2f52816a Mon Sep 17 00:00:00 2001 From: Graham Esau Date: Mon, 13 May 2024 18:17:21 +0100 Subject: [PATCH] Update OpenAPI 3.0 schema URI --- schemars/src/gen.rs | 2 +- .../tests/expected/from_value_openapi3.json | 104 +++++++++--------- .../expected/schema_settings-openapi3.json | 40 +++---- 3 files changed, 73 insertions(+), 73 deletions(-) diff --git a/schemars/src/gen.rs b/schemars/src/gen.rs index d19f80b..8336ecc 100644 --- a/schemars/src/gen.rs +++ b/schemars/src/gen.rs @@ -88,7 +88,7 @@ impl SchemaSettings { option_add_null_type: false, definitions_path: "#/components/schemas/".to_owned(), meta_schema: Some( - "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema" + "https://spec.openapis.org/oas/3.0/schema/2021-09-28#/definitions/Schema" .to_owned(), ), visitors: vec![ diff --git a/schemars/tests/expected/from_value_openapi3.json b/schemars/tests/expected/from_value_openapi3.json index 132a59a..858d286 100644 --- a/schemars/tests/expected/from_value_openapi3.json +++ b/schemars/tests/expected/from_value_openapi3.json @@ -1,58 +1,7 @@ { - "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "$schema": "https://spec.openapis.org/oas/3.0/schema/2021-09-28#/definitions/Schema", "title": "MyStruct", "type": "object", - "properties": { - "myInt": { - "type": "integer" - }, - "myBool": { - "type": "boolean" - }, - "myNullableEnum": { - "nullable": true - }, - "myInnerStruct": { - "type": "object", - "properties": { - "my_map": { - "type": "object", - "additionalProperties": { - "type": "number" - } - }, - "my_vec": { - "type": "array", - "items": { - "type": "string" - } - }, - "my_empty_map": { - "type": "object", - "additionalProperties": true - }, - "my_empty_vec": { - "type": "array", - "items": {} - }, - "my_tuple": { - "type": "array", - "items": [ - { - "type": "string", - "maxLength": 1, - "minLength": 1 - }, - { - "type": "integer" - } - ], - "maxItems": 2, - "minItems": 2 - } - } - } - }, "example": { "myBool": true, "myInnerStruct": { @@ -72,5 +21,56 @@ }, "myInt": 123, "myNullableEnum": null + }, + "properties": { + "myBool": { + "type": "boolean" + }, + "myInnerStruct": { + "type": "object", + "properties": { + "my_empty_map": { + "type": "object", + "additionalProperties": true + }, + "my_empty_vec": { + "type": "array", + "items": {} + }, + "my_map": { + "type": "object", + "additionalProperties": { + "type": "number" + } + }, + "my_tuple": { + "type": "array", + "items": [ + { + "type": "string", + "maxLength": 1, + "minLength": 1 + }, + { + "type": "integer" + } + ], + "maxItems": 2, + "minItems": 2 + }, + "my_vec": { + "type": "array", + "items": { + "type": "string" + } + } + } + }, + "myInt": { + "type": "integer" + }, + "myNullableEnum": { + "nullable": true + } } } \ No newline at end of file diff --git a/schemars/tests/expected/schema_settings-openapi3.json b/schemars/tests/expected/schema_settings-openapi3.json index 17fe805..15b752d 100644 --- a/schemars/tests/expected/schema_settings-openapi3.json +++ b/schemars/tests/expected/schema_settings-openapi3.json @@ -1,23 +1,8 @@ { - "$schema": "https://spec.openapis.org/oas/3.0/schema/2019-04-02#/definitions/Schema", + "$schema": "https://spec.openapis.org/oas/3.0/schema/2021-09-28#/definitions/Schema", "title": "Outer", "type": "object", - "required": [ - "int", - "value", - "values" - ], "properties": { - "int": { - "type": "integer", - "format": "int32", - "example": 8 - }, - "values": { - "type": "object", - "additionalProperties": true - }, - "value": {}, "inner": { "allOf": [ { @@ -25,8 +10,23 @@ } ], "nullable": true + }, + "int": { + "type": "integer", + "format": "int32", + "example": 8 + }, + "value": {}, + "values": { + "type": "object", + "additionalProperties": true } }, + "required": [ + "int", + "value", + "values" + ], "definitions": { "Inner": { "oneOf": [ @@ -46,13 +46,13 @@ }, { "type": "object", - "required": [ - "ValueNewType" - ], + "additionalProperties": false, "properties": { "ValueNewType": {} }, - "additionalProperties": false + "required": [ + "ValueNewType" + ] } ] }