Browse Source

Remove extra code.

pull/97/head
Mohammed 6 years ago
parent
commit
65568065e0
  1. 2
      fastapi/applications.py
  2. 2
      fastapi/openapi/models.py
  3. 6
      fastapi/routing.py

2
fastapi/applications.py

@ -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

2
fastapi/openapi/models.py

@ -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

6
fastapi/routing.py

@ -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…
Cancel
Save