diff --git a/README.md b/README.md index dc395aa..ca2bc17 100644 --- a/README.md +++ b/README.md @@ -6,7 +6,7 @@ OpenAPI schema implemented in [Pydantic](https://github.com/samuelcolvin/pydantic). Both Pydantic 1.8+ and 2.x are supported. The naming of the classes follows the schema in -[OpenAPI specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schema). +[OpenAPI specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.1.md#schema). > This library is forked from [OpenAPI Schema Pydantic](https://github.com/kuimono/openapi-schema-pydantic) (at version [1.2.4](https://github.com/kuimono/openapi-schema-pydantic/releases/tag/v1.2.4)) which is no longer actively maintained. @@ -45,7 +45,7 @@ Result: ```json { - "openapi": "3.1.0", + "openapi": "3.1.1", "info": { "title": "My own API", "version": "v0.0.1" @@ -81,7 +81,7 @@ from openapi_pydantic import parse_obj, OpenAPI, PathItem, Response # Construct OpenAPI from dict, inferring the correct schema version open_api = parse_obj({ - "openapi": "3.1.0", + "openapi": "3.1.1", "info": {"title": "My own API", "version": "v0.0.1"}, "paths": { "/ping": { @@ -91,7 +91,7 @@ open_api = parse_obj({ }) -# Construct OpenAPI v3.1.0 schema from dict +# Construct OpenAPI v3.1 schema from dict # Note: for Pydantic 1.x, replace `model_validate` with `parse_obj` open_api = OpenAPI.model_validate({ "info": {"title": "My own API", "version": "v0.0.1"}, @@ -116,7 +116,7 @@ open_api = OpenAPI.model_validate({ ## Use Pydantic classes as schema -- The [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#schemaObject) +- The [Schema Object](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.4.md#schemaObject) in OpenAPI has definitions and tweaks in JSON Schema, which are hard to comprehend and define a good data class - Pydantic already has a good way to [create JSON schema](https://pydantic-docs.helpmanual.io/usage/schema/). Let's not reinvent the wheel. @@ -175,7 +175,7 @@ Result: ```json { - "openapi": "3.1.0", + "openapi": "3.1.1", "info": { "title": "My own API", "version": "v0.0.1" @@ -286,8 +286,8 @@ More info about field aliases: | OpenAPI version | Field alias info | | --------------- | ---------------- | -| 3.1.0 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_1_0/README.md#alias) | -| 3.0.3 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_0_3/README.md#alias) | +| 3.1 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_1/README.md#alias) | +| 3.0 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_0/README.md#alias) | ### Non-pydantic schema types @@ -296,17 +296,17 @@ Please refer to the following for more info: | OpenAPI version | Non-pydantic schema type info | | --------------- | ----------------------------- | -| 3.1.0 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_1_0/README.md#non-pydantic-schema-types) | -| 3.0.3 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_0_3/README.md#non-pydantic-schema-types) | +| 3.1 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_1/README.md#non-pydantic-schema-types) | +| 3.0 | [here](https://github.com/mike-oakley/openapi-pydantic/blob/main/openapi_pydantic/v3/v3_0/README.md#non-pydantic-schema-types) | -### Use OpenAPI 3.0.3 instead of 3.1.0 +### Use OpenAPI 3.0 instead of 3.1 -Some UI renderings (e.g. Swagger) still do not support OpenAPI 3.1.0. -The old 3.0.3 version is available by importing from different paths: +Some UI renderings (e.g. Swagger) still do not support OpenAPI 3.1.x. +The old 3.0.x version is available by importing from different paths: ```python -from openapi_pydantic.v3.v3_0_3 import OpenAPI, ... -from openapi_pydantic.v3.v3_0_3.util import PydanticSchema, construct_open_api_with_schema_class +from openapi_pydantic.v3.v3_0 import OpenAPI, ... +from openapi_pydantic.v3.v3_0.util import PydanticSchema, construct_open_api_with_schema_class ``` ### Pydantic version compatibility diff --git a/openapi_pydantic/v3/__init__.py b/openapi_pydantic/v3/__init__.py index 859ccbe..ee575e8 100644 --- a/openapi_pydantic/v3/__init__.py +++ b/openapi_pydantic/v3/__init__.py @@ -1,34 +1,34 @@ from .parser import parse_obj as parse_obj -from .v3_1_0 import XML as XML -from .v3_1_0 import Callback as Callback -from .v3_1_0 import Components as Components -from .v3_1_0 import Contact as Contact -from .v3_1_0 import DataType as DataType -from .v3_1_0 import Discriminator as Discriminator -from .v3_1_0 import Encoding as Encoding -from .v3_1_0 import Example as Example -from .v3_1_0 import ExternalDocumentation as ExternalDocumentation -from .v3_1_0 import Header as Header -from .v3_1_0 import Info as Info -from .v3_1_0 import License as License -from .v3_1_0 import Link as Link -from .v3_1_0 import MediaType as MediaType -from .v3_1_0 import OAuthFlow as OAuthFlow -from .v3_1_0 import OAuthFlows as OAuthFlows -from .v3_1_0 import OpenAPI as OpenAPI -from .v3_1_0 import Operation as Operation -from .v3_1_0 import Parameter as Parameter -from .v3_1_0 import ParameterLocation as ParameterLocation -from .v3_1_0 import PathItem as PathItem -from .v3_1_0 import Paths as Paths -from .v3_1_0 import Reference as Reference -from .v3_1_0 import RequestBody as RequestBody -from .v3_1_0 import Response as Response -from .v3_1_0 import Responses as Responses -from .v3_1_0 import Schema as Schema -from .v3_1_0 import SecurityRequirement as SecurityRequirement -from .v3_1_0 import SecurityScheme as SecurityScheme -from .v3_1_0 import Server as Server -from .v3_1_0 import ServerVariable as ServerVariable -from .v3_1_0 import Tag as Tag -from .v3_1_0 import schema_validate as schema_validate +from .v3_1 import XML as XML +from .v3_1 import Callback as Callback +from .v3_1 import Components as Components +from .v3_1 import Contact as Contact +from .v3_1 import DataType as DataType +from .v3_1 import Discriminator as Discriminator +from .v3_1 import Encoding as Encoding +from .v3_1 import Example as Example +from .v3_1 import ExternalDocumentation as ExternalDocumentation +from .v3_1 import Header as Header +from .v3_1 import Info as Info +from .v3_1 import License as License +from .v3_1 import Link as Link +from .v3_1 import MediaType as MediaType +from .v3_1 import OAuthFlow as OAuthFlow +from .v3_1 import OAuthFlows as OAuthFlows +from .v3_1 import OpenAPI as OpenAPI +from .v3_1 import Operation as Operation +from .v3_1 import Parameter as Parameter +from .v3_1 import ParameterLocation as ParameterLocation +from .v3_1 import PathItem as PathItem +from .v3_1 import Paths as Paths +from .v3_1 import Reference as Reference +from .v3_1 import RequestBody as RequestBody +from .v3_1 import Response as Response +from .v3_1 import Responses as Responses +from .v3_1 import Schema as Schema +from .v3_1 import SecurityRequirement as SecurityRequirement +from .v3_1 import SecurityScheme as SecurityScheme +from .v3_1 import Server as Server +from .v3_1 import ServerVariable as ServerVariable +from .v3_1 import Tag as Tag +from .v3_1 import schema_validate as schema_validate diff --git a/openapi_pydantic/v3/parser.py b/openapi_pydantic/v3/parser.py index e80b52f..0149bff 100644 --- a/openapi_pydantic/v3/parser.py +++ b/openapi_pydantic/v3/parser.py @@ -4,8 +4,8 @@ from openapi_pydantic.compat import PYDANTIC_V2 -from .v3_0_3 import OpenAPI as OpenAPIv3_0 -from .v3_1_0 import OpenAPI as OpenAPIv3_1 +from .v3_0 import OpenAPI as OpenAPIv3_0 +from .v3_1 import OpenAPI as OpenAPIv3_1 OpenAPIv3 = Union[OpenAPIv3_1, OpenAPIv3_0] diff --git a/openapi_pydantic/v3/v3_0_3/README.md b/openapi_pydantic/v3/v3_0/README.md similarity index 98% rename from openapi_pydantic/v3/v3_0_3/README.md rename to openapi_pydantic/v3/v3_0/README.md index 7a4892a..16b9c44 100644 --- a/openapi_pydantic/v3/v3_0_3/README.md +++ b/openapi_pydantic/v3/v3_0/README.md @@ -1,4 +1,4 @@ -# OpenAPI v3.0.3 schema classes +# OpenAPI v3.0 schema classes ## Alias diff --git a/openapi_pydantic/v3/v3_1_0/__init__.py b/openapi_pydantic/v3/v3_0/__init__.py similarity index 95% rename from openapi_pydantic/v3/v3_1_0/__init__.py rename to openapi_pydantic/v3/v3_0/__init__.py index b6b2b8f..af250d4 100644 --- a/openapi_pydantic/v3/v3_1_0/__init__.py +++ b/openapi_pydantic/v3/v3_0/__init__.py @@ -1,9 +1,9 @@ """ -OpenAPI v3.1.0 schema types, created according to the specification: -https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md +OpenAPI v3.0 schema types, created according to the specification: +https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.4.md The type orders are according to the contents of the specification: -https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#table-of-contents +https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.4.md#table-of-contents """ from typing import TYPE_CHECKING diff --git a/openapi_pydantic/v3/v3_0_3/callback.py b/openapi_pydantic/v3/v3_0/callback.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/callback.py rename to openapi_pydantic/v3/v3_0/callback.py diff --git a/openapi_pydantic/v3/v3_0_3/components.py b/openapi_pydantic/v3/v3_0/components.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/components.py rename to openapi_pydantic/v3/v3_0/components.py diff --git a/openapi_pydantic/v3/v3_0_3/contact.py b/openapi_pydantic/v3/v3_0/contact.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/contact.py rename to openapi_pydantic/v3/v3_0/contact.py diff --git a/openapi_pydantic/v3/v3_0_3/datatype.py b/openapi_pydantic/v3/v3_0/datatype.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/datatype.py rename to openapi_pydantic/v3/v3_0/datatype.py diff --git a/openapi_pydantic/v3/v3_0_3/discriminator.py b/openapi_pydantic/v3/v3_0/discriminator.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/discriminator.py rename to openapi_pydantic/v3/v3_0/discriminator.py diff --git a/openapi_pydantic/v3/v3_0_3/encoding.py b/openapi_pydantic/v3/v3_0/encoding.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/encoding.py rename to openapi_pydantic/v3/v3_0/encoding.py diff --git a/openapi_pydantic/v3/v3_0_3/example.py b/openapi_pydantic/v3/v3_0/example.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/example.py rename to openapi_pydantic/v3/v3_0/example.py diff --git a/openapi_pydantic/v3/v3_0_3/external_documentation.py b/openapi_pydantic/v3/v3_0/external_documentation.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/external_documentation.py rename to openapi_pydantic/v3/v3_0/external_documentation.py diff --git a/openapi_pydantic/v3/v3_0_3/header.py b/openapi_pydantic/v3/v3_0/header.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/header.py rename to openapi_pydantic/v3/v3_0/header.py diff --git a/openapi_pydantic/v3/v3_0_3/info.py b/openapi_pydantic/v3/v3_0/info.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/info.py rename to openapi_pydantic/v3/v3_0/info.py diff --git a/openapi_pydantic/v3/v3_0_3/license.py b/openapi_pydantic/v3/v3_0/license.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/license.py rename to openapi_pydantic/v3/v3_0/license.py diff --git a/openapi_pydantic/v3/v3_0_3/link.py b/openapi_pydantic/v3/v3_0/link.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/link.py rename to openapi_pydantic/v3/v3_0/link.py diff --git a/openapi_pydantic/v3/v3_0_3/media_type.py b/openapi_pydantic/v3/v3_0/media_type.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/media_type.py rename to openapi_pydantic/v3/v3_0/media_type.py diff --git a/openapi_pydantic/v3/v3_0_3/oauth_flow.py b/openapi_pydantic/v3/v3_0/oauth_flow.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/oauth_flow.py rename to openapi_pydantic/v3/v3_0/oauth_flow.py diff --git a/openapi_pydantic/v3/v3_0_3/oauth_flows.py b/openapi_pydantic/v3/v3_0/oauth_flows.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/oauth_flows.py rename to openapi_pydantic/v3/v3_0/oauth_flows.py diff --git a/openapi_pydantic/v3/v3_0_3/open_api.py b/openapi_pydantic/v3/v3_0/open_api.py similarity index 97% rename from openapi_pydantic/v3/v3_0_3/open_api.py rename to openapi_pydantic/v3/v3_0/open_api.py index be788df..b436ffa 100644 --- a/openapi_pydantic/v3/v3_0_3/open_api.py +++ b/openapi_pydantic/v3/v3_0/open_api.py @@ -16,7 +16,7 @@ class OpenAPI(BaseModel): """This is the root document object of the OpenAPI document.""" - openapi: Literal["3.0.3", "3.0.2", "3.0.1", "3.0.0"] = "3.0.3" + openapi: Literal["3.0.4", "3.0.3", "3.0.2", "3.0.1", "3.0.0"] = "3.0.4" """ **REQUIRED**. This string MUST be the [semantic version number](https://semver.org/spec/v2.0.0.html) of the [OpenAPI Specification version](#versions) that the OpenAPI document uses. diff --git a/openapi_pydantic/v3/v3_0_3/operation.py b/openapi_pydantic/v3/v3_0/operation.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/operation.py rename to openapi_pydantic/v3/v3_0/operation.py diff --git a/openapi_pydantic/v3/v3_0_3/parameter.py b/openapi_pydantic/v3/v3_0/parameter.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/parameter.py rename to openapi_pydantic/v3/v3_0/parameter.py diff --git a/openapi_pydantic/v3/v3_0_3/path_item.py b/openapi_pydantic/v3/v3_0/path_item.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/path_item.py rename to openapi_pydantic/v3/v3_0/path_item.py diff --git a/openapi_pydantic/v3/v3_0_3/paths.py b/openapi_pydantic/v3/v3_0/paths.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/paths.py rename to openapi_pydantic/v3/v3_0/paths.py diff --git a/openapi_pydantic/v3/v3_0_3/reference.py b/openapi_pydantic/v3/v3_0/reference.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/reference.py rename to openapi_pydantic/v3/v3_0/reference.py diff --git a/openapi_pydantic/v3/v3_0_3/request_body.py b/openapi_pydantic/v3/v3_0/request_body.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/request_body.py rename to openapi_pydantic/v3/v3_0/request_body.py diff --git a/openapi_pydantic/v3/v3_0_3/response.py b/openapi_pydantic/v3/v3_0/response.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/response.py rename to openapi_pydantic/v3/v3_0/response.py diff --git a/openapi_pydantic/v3/v3_0_3/responses.py b/openapi_pydantic/v3/v3_0/responses.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/responses.py rename to openapi_pydantic/v3/v3_0/responses.py diff --git a/openapi_pydantic/v3/v3_0_3/schema.py b/openapi_pydantic/v3/v3_0/schema.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/schema.py rename to openapi_pydantic/v3/v3_0/schema.py diff --git a/openapi_pydantic/v3/v3_0_3/security_requirement.py b/openapi_pydantic/v3/v3_0/security_requirement.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/security_requirement.py rename to openapi_pydantic/v3/v3_0/security_requirement.py diff --git a/openapi_pydantic/v3/v3_0_3/security_scheme.py b/openapi_pydantic/v3/v3_0/security_scheme.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/security_scheme.py rename to openapi_pydantic/v3/v3_0/security_scheme.py diff --git a/openapi_pydantic/v3/v3_0_3/server.py b/openapi_pydantic/v3/v3_0/server.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/server.py rename to openapi_pydantic/v3/v3_0/server.py diff --git a/openapi_pydantic/v3/v3_0_3/server_variable.py b/openapi_pydantic/v3/v3_0/server_variable.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/server_variable.py rename to openapi_pydantic/v3/v3_0/server_variable.py diff --git a/openapi_pydantic/v3/v3_0_3/tag.py b/openapi_pydantic/v3/v3_0/tag.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/tag.py rename to openapi_pydantic/v3/v3_0/tag.py diff --git a/openapi_pydantic/v3/v3_0_3/util.py b/openapi_pydantic/v3/v3_0/util.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/util.py rename to openapi_pydantic/v3/v3_0/util.py diff --git a/openapi_pydantic/v3/v3_0_3/xml.py b/openapi_pydantic/v3/v3_0/xml.py similarity index 100% rename from openapi_pydantic/v3/v3_0_3/xml.py rename to openapi_pydantic/v3/v3_0/xml.py diff --git a/openapi_pydantic/v3/v3_1_0/README.md b/openapi_pydantic/v3/v3_1/README.md similarity index 98% rename from openapi_pydantic/v3/v3_1_0/README.md rename to openapi_pydantic/v3/v3_1/README.md index 22d4474..2232c46 100644 --- a/openapi_pydantic/v3/v3_1_0/README.md +++ b/openapi_pydantic/v3/v3_1/README.md @@ -1,4 +1,4 @@ -# OpenAPI v3.1.0 schema classes +# OpenAPI v3.1 schema classes ## Alias diff --git a/openapi_pydantic/v3/v3_0_3/__init__.py b/openapi_pydantic/v3/v3_1/__init__.py similarity index 95% rename from openapi_pydantic/v3/v3_0_3/__init__.py rename to openapi_pydantic/v3/v3_1/__init__.py index 73d1d3d..0574504 100644 --- a/openapi_pydantic/v3/v3_0_3/__init__.py +++ b/openapi_pydantic/v3/v3_1/__init__.py @@ -1,9 +1,9 @@ """ -OpenAPI v3.0.3 schema types, created according to the specification: -https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md +OpenAPI v3.1 schema types, created according to the specification: +https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.1.md The type orders are according to the contents of the specification: -https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.3.md#table-of-contents +https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.1.md#table-of-contents """ from typing import TYPE_CHECKING diff --git a/openapi_pydantic/v3/v3_1_0/callback.py b/openapi_pydantic/v3/v3_1/callback.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/callback.py rename to openapi_pydantic/v3/v3_1/callback.py diff --git a/openapi_pydantic/v3/v3_1_0/components.py b/openapi_pydantic/v3/v3_1/components.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/components.py rename to openapi_pydantic/v3/v3_1/components.py diff --git a/openapi_pydantic/v3/v3_1_0/contact.py b/openapi_pydantic/v3/v3_1/contact.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/contact.py rename to openapi_pydantic/v3/v3_1/contact.py diff --git a/openapi_pydantic/v3/v3_1_0/datatype.py b/openapi_pydantic/v3/v3_1/datatype.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/datatype.py rename to openapi_pydantic/v3/v3_1/datatype.py diff --git a/openapi_pydantic/v3/v3_1_0/discriminator.py b/openapi_pydantic/v3/v3_1/discriminator.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/discriminator.py rename to openapi_pydantic/v3/v3_1/discriminator.py diff --git a/openapi_pydantic/v3/v3_1_0/encoding.py b/openapi_pydantic/v3/v3_1/encoding.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/encoding.py rename to openapi_pydantic/v3/v3_1/encoding.py diff --git a/openapi_pydantic/v3/v3_1_0/example.py b/openapi_pydantic/v3/v3_1/example.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/example.py rename to openapi_pydantic/v3/v3_1/example.py diff --git a/openapi_pydantic/v3/v3_1_0/external_documentation.py b/openapi_pydantic/v3/v3_1/external_documentation.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/external_documentation.py rename to openapi_pydantic/v3/v3_1/external_documentation.py diff --git a/openapi_pydantic/v3/v3_1_0/header.py b/openapi_pydantic/v3/v3_1/header.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/header.py rename to openapi_pydantic/v3/v3_1/header.py diff --git a/openapi_pydantic/v3/v3_1_0/info.py b/openapi_pydantic/v3/v3_1/info.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/info.py rename to openapi_pydantic/v3/v3_1/info.py diff --git a/openapi_pydantic/v3/v3_1_0/license.py b/openapi_pydantic/v3/v3_1/license.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/license.py rename to openapi_pydantic/v3/v3_1/license.py diff --git a/openapi_pydantic/v3/v3_1_0/link.py b/openapi_pydantic/v3/v3_1/link.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/link.py rename to openapi_pydantic/v3/v3_1/link.py diff --git a/openapi_pydantic/v3/v3_1_0/media_type.py b/openapi_pydantic/v3/v3_1/media_type.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/media_type.py rename to openapi_pydantic/v3/v3_1/media_type.py diff --git a/openapi_pydantic/v3/v3_1_0/oauth_flow.py b/openapi_pydantic/v3/v3_1/oauth_flow.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/oauth_flow.py rename to openapi_pydantic/v3/v3_1/oauth_flow.py diff --git a/openapi_pydantic/v3/v3_1_0/oauth_flows.py b/openapi_pydantic/v3/v3_1/oauth_flows.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/oauth_flows.py rename to openapi_pydantic/v3/v3_1/oauth_flows.py diff --git a/openapi_pydantic/v3/v3_1_0/open_api.py b/openapi_pydantic/v3/v3_1/open_api.py similarity index 98% rename from openapi_pydantic/v3/v3_1_0/open_api.py rename to openapi_pydantic/v3/v3_1/open_api.py index 0d186c5..3427dc5 100644 --- a/openapi_pydantic/v3/v3_1_0/open_api.py +++ b/openapi_pydantic/v3/v3_1/open_api.py @@ -18,7 +18,7 @@ class OpenAPI(BaseModel): """This is the root document object of the OpenAPI document.""" - openapi: Literal["3.1.0"] = "3.1.0" + openapi: Literal["3.1.1", "3.1.0"] = "3.1.1" """ **REQUIRED**. This string MUST be the [version number](#versions) of the OpenAPI Specification that the OpenAPI document uses. diff --git a/openapi_pydantic/v3/v3_1_0/operation.py b/openapi_pydantic/v3/v3_1/operation.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/operation.py rename to openapi_pydantic/v3/v3_1/operation.py diff --git a/openapi_pydantic/v3/v3_1_0/parameter.py b/openapi_pydantic/v3/v3_1/parameter.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/parameter.py rename to openapi_pydantic/v3/v3_1/parameter.py diff --git a/openapi_pydantic/v3/v3_1_0/path_item.py b/openapi_pydantic/v3/v3_1/path_item.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/path_item.py rename to openapi_pydantic/v3/v3_1/path_item.py diff --git a/openapi_pydantic/v3/v3_1_0/paths.py b/openapi_pydantic/v3/v3_1/paths.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/paths.py rename to openapi_pydantic/v3/v3_1/paths.py diff --git a/openapi_pydantic/v3/v3_1_0/reference.py b/openapi_pydantic/v3/v3_1/reference.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/reference.py rename to openapi_pydantic/v3/v3_1/reference.py diff --git a/openapi_pydantic/v3/v3_1_0/request_body.py b/openapi_pydantic/v3/v3_1/request_body.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/request_body.py rename to openapi_pydantic/v3/v3_1/request_body.py diff --git a/openapi_pydantic/v3/v3_1_0/response.py b/openapi_pydantic/v3/v3_1/response.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/response.py rename to openapi_pydantic/v3/v3_1/response.py diff --git a/openapi_pydantic/v3/v3_1_0/responses.py b/openapi_pydantic/v3/v3_1/responses.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/responses.py rename to openapi_pydantic/v3/v3_1/responses.py diff --git a/openapi_pydantic/v3/v3_1_0/schema.py b/openapi_pydantic/v3/v3_1/schema.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/schema.py rename to openapi_pydantic/v3/v3_1/schema.py diff --git a/openapi_pydantic/v3/v3_1_0/security_requirement.py b/openapi_pydantic/v3/v3_1/security_requirement.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/security_requirement.py rename to openapi_pydantic/v3/v3_1/security_requirement.py diff --git a/openapi_pydantic/v3/v3_1_0/security_scheme.py b/openapi_pydantic/v3/v3_1/security_scheme.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/security_scheme.py rename to openapi_pydantic/v3/v3_1/security_scheme.py diff --git a/openapi_pydantic/v3/v3_1_0/server.py b/openapi_pydantic/v3/v3_1/server.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/server.py rename to openapi_pydantic/v3/v3_1/server.py diff --git a/openapi_pydantic/v3/v3_1_0/server_variable.py b/openapi_pydantic/v3/v3_1/server_variable.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/server_variable.py rename to openapi_pydantic/v3/v3_1/server_variable.py diff --git a/openapi_pydantic/v3/v3_1_0/tag.py b/openapi_pydantic/v3/v3_1/tag.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/tag.py rename to openapi_pydantic/v3/v3_1/tag.py diff --git a/openapi_pydantic/v3/v3_1_0/xml.py b/openapi_pydantic/v3/v3_1/xml.py similarity index 100% rename from openapi_pydantic/v3/v3_1_0/xml.py rename to openapi_pydantic/v3/v3_1/xml.py diff --git a/tests/test_openapi.py b/tests/test_openapi.py index df92cb6..536e34a 100644 --- a/tests/test_openapi.py +++ b/tests/test_openapi.py @@ -3,10 +3,10 @@ import pytest from openapi_pydantic.compat import PYDANTIC_V2 -from openapi_pydantic.v3 import v3_0_3, v3_1_0 +from openapi_pydantic.v3 import v3_0, v3_1 -@pytest.mark.parametrize("version", ["3.0.3", "3.1.0"]) +@pytest.mark.parametrize("version", ["3.0.4", "3.1.1"]) def test_parse_with_callback(version: str) -> None: data = { "openapi": version, @@ -29,24 +29,22 @@ def test_parse_with_callback(version: str) -> None: }, } - if version == "3.0.3": - model_validate_3_0: Callable[[dict], v3_0_3.OpenAPI] = getattr( - v3_0_3.OpenAPI, "model_validate" if PYDANTIC_V2 else "parse_obj" + if version == "3.0.4": + model_validate_3_0: Callable[[dict], v3_0.OpenAPI] = getattr( + v3_0.OpenAPI, "model_validate" if PYDANTIC_V2 else "parse_obj" ) - assert model_validate_3_0(data) == v3_0_3.OpenAPI( - info=v3_0_3.Info(title="API with Callback", version=""), + assert model_validate_3_0(data) == v3_0.OpenAPI( + info=v3_0.Info(title="API with Callback", version=""), paths={ - "/create": v3_0_3.PathItem( - post=v3_0_3.Operation( - responses={"200": v3_0_3.Response(description="Success")}, + "/create": v3_0.PathItem( + post=v3_0.Operation( + responses={"200": v3_0.Response(description="Success")}, callbacks={ "event": { - "callback": v3_0_3.PathItem( - post=v3_0_3.Operation( + "callback": v3_0.PathItem( + post=v3_0.Operation( responses={ - "200": v3_0_3.Response( - description="Success" - ) + "200": v3_0.Response(description="Success") } ) ) @@ -57,23 +55,21 @@ def test_parse_with_callback(version: str) -> None: }, ) else: - model_validate_3_1: Callable[[dict], v3_1_0.OpenAPI] = getattr( - v3_1_0.OpenAPI, "model_validate" if PYDANTIC_V2 else "parse_obj" + model_validate_3_1: Callable[[dict], v3_1.OpenAPI] = getattr( + v3_1.OpenAPI, "model_validate" if PYDANTIC_V2 else "parse_obj" ) - assert model_validate_3_1(data) == v3_1_0.OpenAPI( - info=v3_1_0.Info(title="API with Callback", version=""), + assert model_validate_3_1(data) == v3_1.OpenAPI( + info=v3_1.Info(title="API with Callback", version=""), paths={ - "/create": v3_1_0.PathItem( - post=v3_1_0.Operation( - responses={"200": v3_1_0.Response(description="Success")}, + "/create": v3_1.PathItem( + post=v3_1.Operation( + responses={"200": v3_1.Response(description="Success")}, callbacks={ "event": { - "callback": v3_1_0.PathItem( - post=v3_1_0.Operation( + "callback": v3_1.PathItem( + post=v3_1.Operation( responses={ - "200": v3_1_0.Response( - description="Success" - ) + "200": v3_1.Response(description="Success") } ) ) diff --git a/tests/test_parse.py b/tests/test_parse.py index fc1db20..0a48140 100644 --- a/tests/test_parse.py +++ b/tests/test_parse.py @@ -3,11 +3,13 @@ import pytest from openapi_pydantic import parse_obj -from openapi_pydantic.v3 import v3_0_3, v3_1_0 +from openapi_pydantic.v3 import v3_0, v3_1 -@pytest.mark.parametrize("version", ["3.0.3", "3.0.2", "3.0.1", "3.0.0"]) -def test_parse_obj_3_0_3(version: Literal["3.0.3", "3.0.2", "3.0.1", "3.0.0"]) -> None: +@pytest.mark.parametrize("version", ["3.0.4", "3.0.3", "3.0.2", "3.0.1", "3.0.0"]) +def test_parse_obj_3_0( + version: Literal["3.0.4", "3.0.3", "3.0.2", "3.0.1", "3.0.0"] +) -> None: result = parse_obj( { "openapi": version, @@ -16,24 +18,25 @@ def test_parse_obj_3_0_3(version: Literal["3.0.3", "3.0.2", "3.0.1", "3.0.0"]) - } ) - assert result == v3_0_3.OpenAPI( + assert result == v3_0.OpenAPI( openapi=version, - info=v3_0_3.Info(title="foo", version="0.1.0"), - paths={"/": v3_0_3.PathItem()}, + info=v3_0.Info(title="foo", version="0.1.0"), + paths={"/": v3_0.PathItem()}, ) -def test_parse_obj_3_1_0() -> None: +@pytest.mark.parametrize("version", ["3.1.1", "3.1.0"]) +def test_parse_obj_3_1(version: Literal["3.1.1", "3.1.0"]) -> None: result = parse_obj( { - "openapi": "3.1.0", + "openapi": version, "info": {"title": "foo", "version": "0.1.0"}, "paths": {"/": {}}, } ) - assert result == v3_1_0.OpenAPI( - openapi="3.1.0", - info=v3_1_0.Info(title="foo", version="0.1.0"), - paths={"/": v3_1_0.PathItem()}, + assert result == v3_1.OpenAPI( + openapi=version, + info=v3_1.Info(title="foo", version="0.1.0"), + paths={"/": v3_1.PathItem()}, ) diff --git a/tests/test_swagger_openapi_v3.py b/tests/test_swagger_openapi_v3.py index 1c30e82..a6214e3 100644 --- a/tests/test_swagger_openapi_v3.py +++ b/tests/test_swagger_openapi_v3.py @@ -3,7 +3,7 @@ from pydantic import Field from openapi_pydantic.compat import PYDANTIC_V2, ConfigDict -from openapi_pydantic.v3.v3_0_3 import OpenAPI, Operation, PathItem +from openapi_pydantic.v3.v3_0 import OpenAPI, Operation, PathItem def test_swagger_openapi_v3() -> None: diff --git a/tests/v3_0_3/__init__.py b/tests/v3_0/__init__.py similarity index 100% rename from tests/v3_0_3/__init__.py rename to tests/v3_0/__init__.py diff --git a/tests/v3_0_3/test_config_example.py b/tests/v3_0/test_config_example.py similarity index 97% rename from tests/v3_0_3/test_config_example.py rename to tests/v3_0/test_config_example.py index 0295250..7f37594 100644 --- a/tests/v3_0_3/test_config_example.py +++ b/tests/v3_0/test_config_example.py @@ -1,7 +1,7 @@ from typing import Any from openapi_pydantic.compat import PYDANTIC_V2 -from openapi_pydantic.v3.v3_0_3 import ( +from openapi_pydantic.v3.v3_0 import ( XML, Callback, Components, diff --git a/tests/v3_0_3/test_datatype.py b/tests/v3_0/test_datatype.py similarity index 93% rename from tests/v3_0_3/test_datatype.py rename to tests/v3_0/test_datatype.py index 259bf8b..c5afe97 100644 --- a/tests/v3_0_3/test_datatype.py +++ b/tests/v3_0/test_datatype.py @@ -1,7 +1,7 @@ import pytest from pydantic import ValidationError -from openapi_pydantic.v3.v3_0_3 import Schema +from openapi_pydantic.v3.v3_0 import Schema @pytest.mark.parametrize( diff --git a/tests/v3_0_3/test_optional_and_computed.py b/tests/v3_0/test_optional_and_computed.py similarity index 97% rename from tests/v3_0_3/test_optional_and_computed.py rename to tests/v3_0/test_optional_and_computed.py index c9cbd98..0518929 100644 --- a/tests/v3_0_3/test_optional_and_computed.py +++ b/tests/v3_0/test_optional_and_computed.py @@ -5,7 +5,7 @@ import pytest from openapi_pydantic.compat import PYDANTIC_V2 -from openapi_pydantic.v3.v3_0_3 import ( +from openapi_pydantic.v3.v3_0 import ( Info, MediaType, OpenAPI, @@ -15,7 +15,7 @@ Response, Schema, ) -from openapi_pydantic.v3.v3_0_3.util import ( +from openapi_pydantic.v3.v3_0.util import ( PydanticSchema, construct_open_api_with_schema_class, ) diff --git a/tests/v3_0_3/test_util.py b/tests/v3_0/test_util.py similarity index 99% rename from tests/v3_0_3/test_util.py rename to tests/v3_0/test_util.py index dd65dcf..2551fc3 100644 --- a/tests/v3_0_3/test_util.py +++ b/tests/v3_0/test_util.py @@ -4,7 +4,7 @@ from pydantic import BaseModel, Field from openapi_pydantic.compat import PYDANTIC_V2 -from openapi_pydantic.v3.v3_0_3 import ( +from openapi_pydantic.v3.v3_0 import ( Info, MediaType, OpenAPI, @@ -15,7 +15,7 @@ Response, Schema, ) -from openapi_pydantic.v3.v3_0_3.util import ( +from openapi_pydantic.v3.v3_0.util import ( PydanticSchema, construct_open_api_with_schema_class, ) diff --git a/tests/v3_0_3/test_validated_schema.py b/tests/v3_0/test_validated_schema.py similarity index 96% rename from tests/v3_0_3/test_validated_schema.py rename to tests/v3_0/test_validated_schema.py index 6d9a3e0..113248f 100644 --- a/tests/v3_0_3/test_validated_schema.py +++ b/tests/v3_0/test_validated_schema.py @@ -7,7 +7,7 @@ from pydantic import BaseModel from openapi_pydantic.compat import PYDANTIC_V2 -from openapi_pydantic.v3.v3_0_3 import ( +from openapi_pydantic.v3.v3_0 import ( Components, DataType, Example, @@ -21,7 +21,7 @@ Response, Schema, ) -from openapi_pydantic.v3.v3_0_3.util import ( +from openapi_pydantic.v3.v3_0.util import ( PydanticSchema, construct_open_api_with_schema_class, ) diff --git a/tests/v3_1_0/__init__.py b/tests/v3_1/__init__.py similarity index 58% rename from tests/v3_1_0/__init__.py rename to tests/v3_1/__init__.py index 7ed1e71..0699444 100644 --- a/tests/v3_1_0/__init__.py +++ b/tests/v3_1/__init__.py @@ -1,4 +1,4 @@ -from openapi_pydantic.v3.v3_1_0.schema import Schema, schema_validate +from openapi_pydantic.v3.v3_1.schema import Schema, schema_validate def test_empty_schema() -> None: diff --git a/tests/v3_1_0/test_datatype.py b/tests/v3_1/test_datatype.py similarity index 93% rename from tests/v3_1_0/test_datatype.py rename to tests/v3_1/test_datatype.py index 237943e..242d05a 100644 --- a/tests/v3_1_0/test_datatype.py +++ b/tests/v3_1/test_datatype.py @@ -1,7 +1,7 @@ import pytest from pydantic import ValidationError -from openapi_pydantic.v3.v3_1_0 import Schema +from openapi_pydantic.v3.v3_1 import Schema @pytest.mark.parametrize(