diff --git a/fastapi/applications.py b/fastapi/applications.py index db0c85169..9e9cf7126 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -2,7 +2,7 @@ from typing import Any, Callable, Dict, List, Optional, Type from fastapi import routing 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 pydantic import BaseModel from starlette.applications import Starlette diff --git a/fastapi/openapi/models.py b/fastapi/openapi/models.py index 613285930..1be51a1a5 100644 --- a/fastapi/openapi/models.py +++ b/fastapi/openapi/models.py @@ -1,6 +1,6 @@ import logging 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.fields import Field diff --git a/fastapi/routing.py b/fastapi/routing.py index 062df5645..187a8faf6 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -141,11 +141,7 @@ class APIRoute(routing.Route): self.response_description = response_description self.additional_responses: Dict[int, AdditionalResponseDescription] = {} existed_codes = [self.status_code, 422] - if isinstance(additional_responses, dict): - self.additional_responses = additional_responses.copy() for add_response in additional_responses: - if isinstance(add_response, int): - continue assert ( add_response.status_code not in existed_codes ), 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( [issubclass(m, BaseModel) for m in response_models] ) - except TypeError as te: + except TypeError: valid_response_models = False if not valid_response_models: raise ValueError(