From 1b34eaaccb9d123665e00d9eff17ccad6baadc78 Mon Sep 17 00:00:00 2001 From: Na'aman Hirschfeld Date: Thu, 4 Aug 2022 08:11:45 +0200 Subject: [PATCH] 1.8.0 --- .pre-commit-config.yaml | 6 +- CHANGELOG.md | 6 ++ docs/usage/3-parameters/0-path-parameters.md | 4 +- poetry.lock | 75 +++++++++++++++----- pyproject.toml | 4 +- starlite/app.py | 2 +- starlite/config.py | 27 ++++--- starlite/openapi/constants.py | 2 +- starlite/openapi/controller.py | 2 +- starlite/openapi/parameters.py | 4 +- starlite/openapi/path_item.py | 4 +- starlite/openapi/request_body.py | 4 +- starlite/openapi/responses.py | 10 +-- starlite/openapi/schema.py | 14 ++-- starlite/params.py | 6 +- starlite/response.py | 2 +- starlite/types.py | 2 +- tests/openapi/test_integration.py | 2 +- tests/openapi/test_parameters.py | 6 +- tests/openapi/test_schema.py | 4 +- tests/openapi/test_tags.py | 2 +- tests/openapi/utils.py | 2 +- 22 files changed, 114 insertions(+), 76 deletions(-) diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index dbd81ba7df..ff79e666b3 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -78,7 +78,7 @@ repos: exclude: "^(?!starlite/)" additional_dependencies: [ - openapi_schema_pydantic, + pydantic_openapi_schema, orjson, pydantic, pydantic_factories, @@ -97,7 +97,7 @@ repos: args: ["--unsafe-load-any-extension=y"] additional_dependencies: [ - openapi_schema_pydantic, + pydantic_openapi_schema, orjson, pydantic, pydantic_factories, @@ -115,7 +115,7 @@ repos: orjson, types-PyYAML, types-requests, - openapi_schema_pydantic, + pydantic_openapi_schema, pydantic, pydantic_factories, starlette, diff --git a/CHANGELOG.md b/CHANGELOG.md index 7388443d43..6236d9b02e 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -293,3 +293,9 @@ [1.7.3] - Fix to routes being allowed under static paths and improvements to path resolution @Dr-Emann + +[1.8.0] + +- Breaking: Replace [openapi-pydantic-schema](https://github.com/kuimono/openapi-schema-pydantic) + with [pydantic-openapi-schema](https://github.com/starlite-api/pydantic-openapi-schema). +- [Stoplights Elements](https://stoplight.io/open-source/elements) OpenAPI support @aedify-swi diff --git a/docs/usage/3-parameters/0-path-parameters.md b/docs/usage/3-parameters/0-path-parameters.md index 66a2075ac2..2b8cc95eda 100644 --- a/docs/usage/3-parameters/0-path-parameters.md +++ b/docs/usage/3-parameters/0-path-parameters.md @@ -68,8 +68,8 @@ If you want to add validation or enhance the OpenAPI documentation generated for so using the [Parameter function](./3-the-parameter-function.md): ```python -from openapi_schema_pydantic.v3.v3_1_0.example import Example -from openapi_schema_pydantic.v3.v3_1_0.external_documentation import ( +from pydantic_openapi_schema.v3_1_0.example import Example +from pydantic_openapi_schema.v3_1_0.external_documentation import ( ExternalDocumentation, ) from starlite import get, Parameter diff --git a/poetry.lock b/poetry.lock index e1a5eafc45..1f02b900f0 100644 --- a/poetry.lock +++ b/poetry.lock @@ -126,6 +126,34 @@ category = "dev" optional = false python-versions = "*" +[[package]] +name = "dnspython" +version = "2.2.1" +description = "DNS toolkit" +category = "main" +optional = false +python-versions = ">=3.6,<4.0" + +[package.extras] +dnssec = ["cryptography (>=2.6,<37.0)"] +curio = ["curio (>=1.2,<2.0)", "sniffio (>=1.1,<2.0)"] +doh = ["h2 (>=4.1.0)", "httpx (>=0.21.1)", "requests (>=2.23.0,<3.0.0)", "requests-toolbelt (>=0.9.1,<0.10.0)"] +idna = ["idna (>=2.1,<4.0)"] +trio = ["trio (>=0.14,<0.20)"] +wmi = ["wmi (>=1.5.1,<2.0.0)"] + +[[package]] +name = "email-validator" +version = "1.2.1" +description = "A robust email syntax and deliverability validation library." +category = "main" +optional = false +python-versions = "!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,>=2.7" + +[package.dependencies] +dnspython = ">=1.15.0" +idna = ">=2.0.0" + [[package]] name = "exceptiongroup" version = "1.0.0rc8" @@ -239,7 +267,7 @@ zoneinfo = ["backports.zoneinfo (>=0.2.1)", "tzdata (>=2022.1)"] [[package]] name = "identify" -version = "2.5.2" +version = "2.5.3" description = "File identification library for Python" category = "dev" optional = false @@ -432,17 +460,6 @@ category = "dev" optional = false python-versions = ">=2.7,!=3.0.*,!=3.1.*,!=3.2.*,!=3.3.*,!=3.4.*,!=3.5.*,!=3.6.*" -[[package]] -name = "openapi-schema-pydantic" -version = "1.2.4" -description = "OpenAPI (v3) specification schema as pydantic class" -category = "main" -optional = false -python-versions = ">=3.6.1" - -[package.dependencies] -pydantic = ">=1.8.2" - [[package]] name = "orjson" version = "3.7.11" @@ -543,6 +560,18 @@ pydantic = "*" typing-extensions = "*" xeger = ">=0.3.5,<0.4.0" +[[package]] +name = "pydantic-openapi-schema" +version = "1.0.0" +description = "OpenAPI Schema using pydantic. Forked for Starlite-API from 'openapi-schema-pydantic'." +category = "main" +optional = false +python-versions = ">=3.7" + +[package.dependencies] +email-validator = ">=1.2.1,<2.0.0" +pydantic = "*" + [[package]] name = "pygments" version = "2.12.0" @@ -961,7 +990,7 @@ testing = ["requests", "brotli"] [metadata] lock-version = "1.1" python-versions = ">=3.7,<4.0" -content-hash = "72e6c7b1555edb643142b3947703034d724d0e8eb66c48e0c571cf8e05d2c364" +content-hash = "668da632b6c5c45d46645a0cf6c984152972c34e678eecce562f25dd3fc49dbd" [metadata.files] aiosqlite = [ @@ -1110,6 +1139,14 @@ distlib = [ {file = "distlib-0.3.5-py2.py3-none-any.whl", hash = "sha256:b710088c59f06338ca514800ad795a132da19fda270e3ce4affc74abf955a26c"}, {file = "distlib-0.3.5.tar.gz", hash = "sha256:a7f75737c70be3b25e2bee06288cec4e4c221de18455b2dd037fe2a795cab2fe"}, ] +dnspython = [ + {file = "dnspython-2.2.1-py3-none-any.whl", hash = "sha256:a851e51367fb93e9e1361732c1d60dab63eff98712e503ea7d92e6eccb109b4f"}, + {file = "dnspython-2.2.1.tar.gz", hash = "sha256:0f7569a4a6ff151958b64304071d370daa3243d15941a7beedf0c9fe5105603e"}, +] +email-validator = [ + {file = "email_validator-1.2.1-py2.py3-none-any.whl", hash = "sha256:c8589e691cf73eb99eed8d10ce0e9cbb05a0886ba920c8bcb7c82873f4c5789c"}, + {file = "email_validator-1.2.1.tar.gz", hash = "sha256:6757aea012d40516357c0ac2b1a4c31219ab2f899d26831334c5d069e8b6c3d8"}, +] exceptiongroup = [ {file = "exceptiongroup-1.0.0rc8-py3-none-any.whl", hash = "sha256:ab0a968e1ef769e55d9a596f4a89f7be9ffedbc9fdefdb77cc68cf5c33ce1035"}, {file = "exceptiongroup-1.0.0rc8.tar.gz", hash = "sha256:6990c24f06b8d33c8065cfe43e5e8a4bfa384e0358be036af9cc60b6321bd11a"}, @@ -1196,8 +1233,8 @@ hypothesis = [ {file = "hypothesis-6.54.1.tar.gz", hash = "sha256:de63c34309181875e71d0f5d1c1051c9320a1fe0517ea6733af8cedf818191f4"}, ] identify = [ - {file = "identify-2.5.2-py2.py3-none-any.whl", hash = "sha256:feaa9db2dc0ce333b453ce171c0cf1247bbfde2c55fc6bb785022d411a1b78b5"}, - {file = "identify-2.5.2.tar.gz", hash = "sha256:a3d4c096b384d50d5e6dc5bc8b9bc44f1f61cefebd750a7b3e9f939b53fb214d"}, + {file = "identify-2.5.3-py2.py3-none-any.whl", hash = "sha256:25851c8c1370effb22aaa3c987b30449e9ff0cece408f810ae6ce408fdd20893"}, + {file = "identify-2.5.3.tar.gz", hash = "sha256:887e7b91a1be152b0d46bbf072130235a8117392b9f1828446079a816a05ef44"}, ] idna = [ {file = "idna-3.3-py3-none-any.whl", hash = "sha256:84d9dd047ffa80596e0f246e2eab0b391788b0503584e8945f2368256d2735ff"}, @@ -1318,10 +1355,6 @@ nodeenv = [ {file = "nodeenv-1.7.0-py2.py3-none-any.whl", hash = "sha256:27083a7b96a25f2f5e1d8cb4b6317ee8aeda3bdd121394e5ac54e498028a042e"}, {file = "nodeenv-1.7.0.tar.gz", hash = "sha256:e0e7f7dfb85fc5394c6fe1e8fa98131a2473e04311a45afb6508f7cf1836fa2b"}, ] -openapi-schema-pydantic = [ - {file = "openapi-schema-pydantic-1.2.4.tar.gz", hash = "sha256:3e22cf58b74a69f752cc7e5f1537f6e44164282db2700cbbcd3bb99ddd065196"}, - {file = "openapi_schema_pydantic-1.2.4-py3-none-any.whl", hash = "sha256:a932ecc5dcbb308950282088956e94dea069c9823c84e507d64f6b622222098c"}, -] orjson = [ {file = "orjson-3.7.11-cp310-cp310-macosx_10_7_x86_64.whl", hash = "sha256:51e00a59dd6486c40f395da07633718f50b85af414e1add751f007dde6248090"}, {file = "orjson-3.7.11-cp310-cp310-macosx_10_9_x86_64.macosx_11_0_arm64.macosx_10_9_universal2.whl", hash = "sha256:c84d096f800d8cf062f8f514bb89baa1f067259ad8f71889b1d204039c2e2dd7"}, @@ -1423,6 +1456,10 @@ pydantic-factories = [ {file = "pydantic-factories-1.4.1.tar.gz", hash = "sha256:0ac03224ba5677de3d43d304beb4648c0dcbdf0e997e5c6d34af0d09794ccb81"}, {file = "pydantic_factories-1.4.1-py3-none-any.whl", hash = "sha256:775e550c359ad32cb23e723dfba7b3bda2043880e5db7dd64d2d2948f87b894f"}, ] +pydantic-openapi-schema = [ + {file = "pydantic-openapi-schema-1.0.0.tar.gz", hash = "sha256:28cb8b52e18c66e04215ac3e150dd6f9ea8d5075069f08aaff8e1a1290e17f89"}, + {file = "pydantic_openapi_schema-1.0.0-py3-none-any.whl", hash = "sha256:f779cde0f49e15f18e82435a01e6218f39cfaa3a464b164dc1f6114b5cafcbbb"}, +] pygments = [ {file = "Pygments-2.12.0-py3-none-any.whl", hash = "sha256:dc9c10fb40944260f6ed4c688ece0cd2048414940f1cea51b8b226318411c519"}, {file = "Pygments-2.12.0.tar.gz", hash = "sha256:5eb116118f9612ff1ee89ac96437bb6b49e8f04d8a13b514ba26f620208e26eb"}, diff --git a/pyproject.toml b/pyproject.toml index 315e668a2e..9fd1989cea 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "starlite" -version = "1.7.3" +version = "1.8.0" description = "Light-weight and flexible ASGI API Framework" authors = ["Na'aman Hirschfeld "] maintainers = ["Na'aman Hirschfeld ", "Peter Schutt ", "Cody Fincher "] @@ -33,7 +33,6 @@ packages = [ [tool.poetry.dependencies] python = ">=3.7,<4.0" -openapi-schema-pydantic = "*" orjson = "*" pydantic = "*" pydantic-factories = "*" @@ -43,6 +42,7 @@ starlette = "*" typing-extensions = "*" requests = { version = "*", optional = true } brotli = { version = "*", optional = true } +pydantic-openapi-schema = "*" [tool.poetry.dev-dependencies] hypothesis = "*" diff --git a/starlite/app.py b/starlite/app.py index 0559e5799a..296b19d415 100644 --- a/starlite/app.py +++ b/starlite/app.py @@ -43,8 +43,8 @@ from starlite.utils.templates import create_template_engine if TYPE_CHECKING: - from openapi_schema_pydantic.v3.v3_1_0.open_api import OpenAPI from pydantic.typing import AnyCallable + from pydantic_openapi_schema.v3_1_0.open_api import OpenAPI from starlette.types import ASGIApp, Receive, Scope, Send from starlite.handlers.base import BaseRouteHandler diff --git a/starlite/config.py b/starlite/config.py index 3fdd344426..a5f798167e 100644 --- a/starlite/config.py +++ b/starlite/config.py @@ -9,24 +9,21 @@ Tuple, Type, Union, - cast, ) from urllib.parse import urlencode -from openapi_schema_pydantic.util import construct_open_api_with_schema_class -from openapi_schema_pydantic.v3.v3_1_0.contact import Contact -from openapi_schema_pydantic.v3.v3_1_0.external_documentation import ( - ExternalDocumentation, -) -from openapi_schema_pydantic.v3.v3_1_0.info import Info -from openapi_schema_pydantic.v3.v3_1_0.license import License -from openapi_schema_pydantic.v3.v3_1_0.open_api import OpenAPI -from openapi_schema_pydantic.v3.v3_1_0.path_item import PathItem -from openapi_schema_pydantic.v3.v3_1_0.reference import Reference -from openapi_schema_pydantic.v3.v3_1_0.security_requirement import SecurityRequirement -from openapi_schema_pydantic.v3.v3_1_0.server import Server -from openapi_schema_pydantic.v3.v3_1_0.tag import Tag from pydantic import AnyUrl, BaseModel, DirectoryPath, constr, validator +from pydantic_openapi_schema.utils import construct_open_api_with_schema_class +from pydantic_openapi_schema.v3_1_0.contact import Contact +from pydantic_openapi_schema.v3_1_0.external_documentation import ExternalDocumentation +from pydantic_openapi_schema.v3_1_0.info import Info +from pydantic_openapi_schema.v3_1_0.license import License +from pydantic_openapi_schema.v3_1_0.open_api import OpenAPI +from pydantic_openapi_schema.v3_1_0.path_item import PathItem +from pydantic_openapi_schema.v3_1_0.reference import Reference +from pydantic_openapi_schema.v3_1_0.security_requirement import SecurityRequirement +from pydantic_openapi_schema.v3_1_0.server import Server +from pydantic_openapi_schema.v3_1_0.tag import Tag from starlite.cache import CacheBackendProtocol, SimpleCacheBackend from starlite.openapi.controller import OpenAPIController @@ -207,7 +204,7 @@ def create_openapi_schema_model(self, app: "Starlite") -> OpenAPI: plugins=app.plugins, use_handler_docstrings=self.use_handler_docstrings, ) - return cast("OpenAPI", construct_open_api_with_schema_class(schema)) + return construct_open_api_with_schema_class(schema) class StaticFilesConfig(BaseModel): diff --git a/starlite/openapi/constants.py b/starlite/openapi/constants.py index 8efce6493c..4c49939b9b 100644 --- a/starlite/openapi/constants.py +++ b/starlite/openapi/constants.py @@ -3,7 +3,6 @@ from typing import Any, Dict, Pattern, Type, Union from uuid import UUID -from openapi_schema_pydantic.v3.v3_1_0.schema import Schema from pydantic import ( UUID1, UUID3, @@ -51,6 +50,7 @@ SHAPE_TUPLE, SHAPE_TUPLE_ELLIPSIS, ) +from pydantic_openapi_schema.v3_1_0.schema import Schema from starlite.openapi.enums import OpenAPIFormat, OpenAPIType diff --git a/starlite/openapi/controller.py b/starlite/openapi/controller.py index 7021fe513c..21af9c7d4f 100644 --- a/starlite/openapi/controller.py +++ b/starlite/openapi/controller.py @@ -9,7 +9,7 @@ from starlite.handlers import get if TYPE_CHECKING: - from openapi_schema_pydantic.v3.v3_1_0.open_api import OpenAPI + from pydantic_openapi_schema.v3_1_0.open_api import OpenAPI class OpenAPIController(Controller): diff --git a/starlite/openapi/parameters.py b/starlite/openapi/parameters.py index b2347cfda9..74eb78bba9 100644 --- a/starlite/openapi/parameters.py +++ b/starlite/openapi/parameters.py @@ -1,8 +1,8 @@ from copy import copy from typing import TYPE_CHECKING, Any, Dict, List, cast -from openapi_schema_pydantic.v3.v3_1_0.parameter import Parameter from pydantic.fields import Undefined +from pydantic_openapi_schema.v3_1_0.parameter import Parameter from starlite.constants import ( EXTRA_KEY_IS_PARAMETER, @@ -14,9 +14,9 @@ from starlite.openapi.schema import create_schema if TYPE_CHECKING: - from openapi_schema_pydantic.v3.v3_1_0.schema import Schema from pydantic import BaseModel from pydantic.fields import ModelField + from pydantic_openapi_schema.v3_1_0.schema import Schema from starlite.handlers import BaseRouteHandler from starlite.provide import Provide diff --git a/starlite/openapi/path_item.py b/starlite/openapi/path_item.py index aba5f70cc8..80a8e057a3 100644 --- a/starlite/openapi/path_item.py +++ b/starlite/openapi/path_item.py @@ -1,7 +1,7 @@ from typing import TYPE_CHECKING, List, Optional, cast -from openapi_schema_pydantic.v3.v3_1_0.operation import Operation -from openapi_schema_pydantic.v3.v3_1_0.path_item import PathItem +from pydantic_openapi_schema.v3_1_0.operation import Operation +from pydantic_openapi_schema.v3_1_0.path_item import PathItem from starlette.routing import get_name from starlite.openapi.parameters import create_parameter_for_handler diff --git a/starlite/openapi/request_body.py b/starlite/openapi/request_body.py index 6804775929..dd097124b3 100644 --- a/starlite/openapi/request_body.py +++ b/starlite/openapi/request_body.py @@ -1,9 +1,9 @@ from typing import TYPE_CHECKING, List, Optional -from openapi_schema_pydantic.v3.v3_1_0.media_type import ( +from pydantic_openapi_schema.v3_1_0.media_type import ( MediaType as OpenAPISchemaMediaType, ) -from openapi_schema_pydantic.v3.v3_1_0.request_body import RequestBody +from pydantic_openapi_schema.v3_1_0.request_body import RequestBody from starlite.enums import RequestEncodingType from starlite.openapi.schema import create_schema, update_schema_with_field_info diff --git a/starlite/openapi/responses.py b/starlite/openapi/responses.py index 302cb596c4..73ae63d2e2 100644 --- a/starlite/openapi/responses.py +++ b/starlite/openapi/responses.py @@ -2,12 +2,12 @@ from inspect import Signature from typing import TYPE_CHECKING, Any, Dict, Iterator, List, Optional, Tuple, Type, cast -from openapi_schema_pydantic.v3.v3_1_0.header import Header -from openapi_schema_pydantic.v3.v3_1_0.media_type import ( +from pydantic_openapi_schema.v3_1_0.header import Header +from pydantic_openapi_schema.v3_1_0.media_type import ( MediaType as OpenAPISchemaMediaType, ) -from openapi_schema_pydantic.v3.v3_1_0.response import Response -from openapi_schema_pydantic.v3.v3_1_0.schema import Schema +from pydantic_openapi_schema.v3_1_0.response import Response +from pydantic_openapi_schema.v3_1_0.schema import Schema from starlette.routing import get_name from starlite.datastructures import File, Redirect, Stream, Template @@ -19,8 +19,8 @@ from starlite.utils.model import create_parsed_model_field if TYPE_CHECKING: - from openapi_schema_pydantic.v3.v3_1_0.responses import Responses from pydantic.typing import AnyCallable + from pydantic_openapi_schema.v3_1_0.responses import Responses from starlite.handlers import HTTPRouteHandler from starlite.plugins.base import PluginProtocol diff --git a/starlite/openapi/schema.py b/starlite/openapi/schema.py index d37e52a8d7..c14ff3844a 100644 --- a/starlite/openapi/schema.py +++ b/starlite/openapi/schema.py @@ -3,9 +3,6 @@ from enum import Enum, EnumMeta from typing import TYPE_CHECKING, Any, List, Optional, Type, Union -from openapi_schema_pydantic.util import PydanticSchema -from openapi_schema_pydantic.v3.v3_1_0.example import Example -from openapi_schema_pydantic.v3.v3_1_0.schema import Schema from pydantic import ( BaseModel, ConstrainedBytes, @@ -19,6 +16,9 @@ from pydantic.fields import FieldInfo, ModelField, Undefined from pydantic_factories import ModelFactory from pydantic_factories.utils import is_optional, is_pydantic_model, is_union +from pydantic_openapi_schema.utils.utils import OpenAPI310PydanticSchema +from pydantic_openapi_schema.v3_1_0.example import Example +from pydantic_openapi_schema.v3_1_0.schema import Schema from starlite.openapi.constants import ( EXTRA_TO_OPENAPI_PROPERTY_MAP, @@ -170,16 +170,18 @@ def get_schema_for_field_type(field: ModelField, plugins: List["PluginProtocol"] if field_type in TYPE_MAP: return TYPE_MAP[field_type].copy() if is_pydantic_model(field_type): - return PydanticSchema(schema_class=field_type) + return OpenAPI310PydanticSchema(schema_class=field_type) if is_dataclass(field_type): - return PydanticSchema(schema_class=convert_dataclass_to_model(field_type)) + return OpenAPI310PydanticSchema(schema_class=convert_dataclass_to_model(field_type)) if isinstance(field_type, EnumMeta): enum_values: List[Union[str, int]] = [v.value for v in field_type] # type: ignore openapi_type = OpenAPIType.STRING if isinstance(enum_values[0], str) else OpenAPIType.INTEGER return Schema(type=openapi_type, enum=enum_values) if any(plugin.is_plugin_supported_type(field_type) for plugin in plugins): plugin = [plugin for plugin in plugins if plugin.is_plugin_supported_type(field_type)][0] - return PydanticSchema(schema_class=plugin.to_pydantic_model_class(field_type, parameter_name=field.name)) + return OpenAPI310PydanticSchema( + schema_class=plugin.to_pydantic_model_class(field_type, parameter_name=field.name) + ) # this is a failsafe to ensure we always return a value return Schema() # pragma: no cover diff --git a/starlite/params.py b/starlite/params.py index e7bda8d6e4..1b60f8343e 100644 --- a/starlite/params.py +++ b/starlite/params.py @@ -1,11 +1,9 @@ from typing import Any, Dict, List, Optional, Union -from openapi_schema_pydantic.v3.v3_1_0.example import Example -from openapi_schema_pydantic.v3.v3_1_0.external_documentation import ( - ExternalDocumentation, -) from pydantic import validate_arguments from pydantic.fields import Field, Undefined +from pydantic_openapi_schema.v3_1_0.example import Example +from pydantic_openapi_schema.v3_1_0.external_documentation import ExternalDocumentation from starlite.enums import RequestEncodingType diff --git a/starlite/response.py b/starlite/response.py index 7832a6ed4d..7215abbf9c 100644 --- a/starlite/response.py +++ b/starlite/response.py @@ -1,9 +1,9 @@ from typing import TYPE_CHECKING, Any, Dict, Optional, Union, cast import yaml -from openapi_schema_pydantic.v3.v3_1_0.open_api import OpenAPI from orjson import OPT_INDENT_2, OPT_OMIT_MICROSECONDS, OPT_SERIALIZE_NUMPY, dumps from pydantic import BaseModel +from pydantic_openapi_schema.v3_1_0.open_api import OpenAPI from starlette.responses import Response as StarletteResponse from starlette.status import HTTP_204_NO_CONTENT diff --git a/starlite/types.py b/starlite/types.py index 38ea40e7ce..41f9846fa3 100644 --- a/starlite/types.py +++ b/starlite/types.py @@ -14,9 +14,9 @@ get_type_hints, ) -from openapi_schema_pydantic.v3.v3_1_0.header import Header from pydantic import BaseModel, create_model from pydantic.typing import AnyCallable +from pydantic_openapi_schema.v3_1_0.header import Header from starlette.exceptions import HTTPException as StarletteHTTPException from starlette.middleware import Middleware as StarletteMiddleware from starlette.middleware.base import BaseHTTPMiddleware diff --git a/tests/openapi/test_integration.py b/tests/openapi/test_integration.py index c30aefe475..61b1b1b879 100644 --- a/tests/openapi/test_integration.py +++ b/tests/openapi/test_integration.py @@ -1,6 +1,6 @@ import yaml -from openapi_schema_pydantic.util import construct_open_api_with_schema_class from orjson import loads +from pydantic_openapi_schema.utils import construct_open_api_with_schema_class from starlette.status import HTTP_200_OK from starlite.app import DEFAULT_OPENAPI_CONFIG diff --git a/tests/openapi/test_parameters.py b/tests/openapi/test_parameters.py index f40d179642..5a9b322fa9 100644 --- a/tests/openapi/test_parameters.py +++ b/tests/openapi/test_parameters.py @@ -15,10 +15,8 @@ if TYPE_CHECKING: from typing import Callable - from openapi_schema_pydantic.v3.v3_1_0.open_api import OpenAPI - from openapi_schema_pydantic.v3.v3_1_0.parameter import ( - Parameter as OpenAPIParameter, - ) + from pydantic_openapi_schema.v3_1_0.open_api import OpenAPI + from pydantic_openapi_schema.v3_1_0.parameter import Parameter as OpenAPIParameter def _create_parameters(app: Starlite, path: str) -> List["OpenAPIParameter"]: diff --git a/tests/openapi/test_schema.py b/tests/openapi/test_schema.py index c9a8f08710..34cdb7ba4e 100644 --- a/tests/openapi/test_schema.py +++ b/tests/openapi/test_schema.py @@ -1,9 +1,9 @@ from typing import Generic, TypeVar import pytest -from openapi_schema_pydantic.v3.v3_1_0.example import Example -from openapi_schema_pydantic.v3.v3_1_0.schema import Schema from pydantic.fields import FieldInfo +from pydantic_openapi_schema.v3_1_0.example import Example +from pydantic_openapi_schema.v3_1_0.schema import Schema from starlite import Controller, MediaType, Parameter, Provide, Starlite, get from starlite.app import DEFAULT_OPENAPI_CONFIG diff --git a/tests/openapi/test_tags.py b/tests/openapi/test_tags.py index 18cf40f24c..542c8136cc 100644 --- a/tests/openapi/test_tags.py +++ b/tests/openapi/test_tags.py @@ -5,7 +5,7 @@ from starlite import Controller, HTTPRouteHandler, Router, Starlite, get if TYPE_CHECKING: - from openapi_schema_pydantic.v3.v3_1_0.open_api import OpenAPI + from pydantic_openapi_schema.v3_1_0.open_api import OpenAPI @pytest.fixture() diff --git a/tests/openapi/utils.py b/tests/openapi/utils.py index f885fc6a1a..42a21dd99d 100644 --- a/tests/openapi/utils.py +++ b/tests/openapi/utils.py @@ -3,8 +3,8 @@ from enum import Enum from typing import Any, Dict, List, Optional, Union -from openapi_schema_pydantic.v3.v3_1_0.example import Example from pydantic import conbytes, condecimal, confloat, conint, conlist, conset, constr +from pydantic_openapi_schema.v3_1_0.example import Example from starlite import ( Controller,