mirror of
https://github.com/rjNemo/fastapi
synced 2026-06-11 21:16:45 +00:00
Remove extra code.
This commit is contained in:
parent
95679ca5e6
commit
65568065e0
3 changed files with 3 additions and 7 deletions
|
|
@ -2,7 +2,7 @@ from typing import Any, Callable, Dict, List, Optional, Type
|
||||||
|
|
||||||
from fastapi import routing
|
from fastapi import routing
|
||||||
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
|
from fastapi.openapi.docs import get_redoc_html, get_swagger_ui_html
|
||||||
from fastapi.openapi.models import AdditionalResponse, AdditionalResponseDescription
|
from fastapi.openapi.models import AdditionalResponse
|
||||||
from fastapi.openapi.utils import get_openapi
|
from fastapi.openapi.utils import get_openapi
|
||||||
from pydantic import BaseModel
|
from pydantic import BaseModel
|
||||||
from starlette.applications import Starlette
|
from starlette.applications import Starlette
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,6 @@
|
||||||
import logging
|
import logging
|
||||||
from enum import Enum
|
from enum import Enum
|
||||||
from typing import Any, Callable, ClassVar, Dict, List, Optional, Type, Union
|
from typing import Any, Dict, List, Optional, Union
|
||||||
|
|
||||||
from pydantic import BaseModel, Schema as PSchema
|
from pydantic import BaseModel, Schema as PSchema
|
||||||
from pydantic.fields import Field
|
from pydantic.fields import Field
|
||||||
|
|
|
||||||
|
|
@ -141,11 +141,7 @@ class APIRoute(routing.Route):
|
||||||
self.response_description = response_description
|
self.response_description = response_description
|
||||||
self.additional_responses: Dict[int, AdditionalResponseDescription] = {}
|
self.additional_responses: Dict[int, AdditionalResponseDescription] = {}
|
||||||
existed_codes = [self.status_code, 422]
|
existed_codes = [self.status_code, 422]
|
||||||
if isinstance(additional_responses, dict):
|
|
||||||
self.additional_responses = additional_responses.copy()
|
|
||||||
for add_response in additional_responses:
|
for add_response in additional_responses:
|
||||||
if isinstance(add_response, int):
|
|
||||||
continue
|
|
||||||
assert (
|
assert (
|
||||||
add_response.status_code not in existed_codes
|
add_response.status_code not in existed_codes
|
||||||
), f"(Duplicated Status Code): Response with status code [{add_response.status_code}] already defined!"
|
), f"(Duplicated Status Code): Response with status code [{add_response.status_code}] already defined!"
|
||||||
|
|
@ -156,7 +152,7 @@ class APIRoute(routing.Route):
|
||||||
valid_response_models = all(
|
valid_response_models = all(
|
||||||
[issubclass(m, BaseModel) for m in response_models]
|
[issubclass(m, BaseModel) for m in response_models]
|
||||||
)
|
)
|
||||||
except TypeError as te:
|
except TypeError:
|
||||||
valid_response_models = False
|
valid_response_models = False
|
||||||
if not valid_response_models:
|
if not valid_response_models:
|
||||||
raise ValueError(
|
raise ValueError(
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue