version=1.7.2 fix oas.spec schema is broken after reloading the page

This commit is contained in:
Vincent Maillol
2021-02-27 08:08:12 +01:00
parent 4ff9739293
commit c6b979dcaf
3 changed files with 21 additions and 8 deletions

View File

@@ -1,5 +1,5 @@
from .view import PydanticView
__version__ = "1.7.1"
__version__ = "1.7.2"
__all__ = ("PydanticView", "__version__")

View File

@@ -44,7 +44,9 @@ class _OASResponseBuilder:
def _handle_pydantic_base_model(self, obj):
if is_pydantic_base_model(obj):
response_schema = obj.schema(ref_template="#/components/schemas/{model}")
response_schema = obj.schema(
ref_template="#/components/schemas/{model}"
).copy()
if def_sub_schemas := response_schema.pop("definitions", None):
self._oas.components.schemas.update(def_sub_schemas)
return response_schema
@@ -104,8 +106,10 @@ def _add_http_method_to_oas(
status_code_descriptions = {}
if body_args:
body_schema = next(iter(body_args.values())).schema(
ref_template="#/components/schemas/{model}"
body_schema = (
next(iter(body_args.values()))
.schema(ref_template="#/components/schemas/{model}")
.copy()
)
if def_sub_schemas := body_schema.pop("definitions", None):
oas.components.schemas.update(def_sub_schemas)