diff --git a/fastapi/applications.py b/fastapi/applications.py index b6b4538d2..1cd0bcfed 100644 --- a/fastapi/applications.py +++ b/fastapi/applications.py @@ -106,11 +106,11 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, methods: List[str] = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> None: self.router.add_api_route( path, @@ -122,11 +122,11 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=methods, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def api_route( @@ -140,11 +140,11 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, methods: List[str] = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: def decorator(func: Callable) -> Callable: self.router.add_api_route( @@ -157,11 +157,11 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=methods, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) return func @@ -181,10 +181,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.get( path, @@ -195,10 +195,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def put( @@ -212,10 +212,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.put( path, @@ -226,10 +226,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def post( @@ -243,10 +243,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.post( path, @@ -257,10 +257,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def delete( @@ -274,10 +274,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.delete( path, @@ -288,10 +288,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def options( @@ -305,10 +305,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.options( path, @@ -319,10 +319,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def head( @@ -336,10 +336,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.head( path, @@ -350,10 +350,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def patch( @@ -367,10 +367,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.patch( path, @@ -381,10 +381,10 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def trace( @@ -398,10 +398,10 @@ class FastAPI(Starlette): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.router.trace( path, @@ -412,8 +412,8 @@ class FastAPI(Starlette): description=description, response_description=response_description, deprecated=deprecated, - name=name, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) diff --git a/fastapi/params.py b/fastapi/params.py index ab71954ea..499d17184 100644 --- a/fastapi/params.py +++ b/fastapi/params.py @@ -18,7 +18,6 @@ class Param(Schema): self, default: Any, *, - deprecated: bool = None, alias: str = None, title: str = None, description: str = None, @@ -29,6 +28,7 @@ class Param(Schema): min_length: int = None, max_length: int = None, regex: str = None, + deprecated: bool = None, **extra: Any, ): self.deprecated = deprecated @@ -55,7 +55,6 @@ class Path(Param): self, default: Any, *, - deprecated: bool = None, alias: str = None, title: str = None, description: str = None, @@ -66,13 +65,12 @@ class Path(Param): min_length: int = None, max_length: int = None, regex: str = None, + deprecated: bool = None, **extra: Any, ): - self.description = description - self.deprecated = deprecated self.in_ = self.in_ super().__init__( - default, + ..., alias=alias, title=title, description=description, @@ -83,6 +81,7 @@ class Path(Param): min_length=min_length, max_length=max_length, regex=regex, + deprecated=deprecated, **extra, ) @@ -94,7 +93,6 @@ class Query(Param): self, default: Any, *, - deprecated: bool = None, alias: str = None, title: str = None, description: str = None, @@ -105,10 +103,9 @@ class Query(Param): min_length: int = None, max_length: int = None, regex: str = None, + deprecated: bool = None, **extra: Any, ): - self.description = description - self.deprecated = deprecated super().__init__( default, alias=alias, @@ -121,6 +118,7 @@ class Query(Param): min_length=min_length, max_length=max_length, regex=regex, + deprecated=deprecated, **extra, ) @@ -132,7 +130,6 @@ class Header(Param): self, default: Any, *, - deprecated: bool = None, alias: str = None, convert_underscores: bool = True, title: str = None, @@ -144,10 +141,9 @@ class Header(Param): min_length: int = None, max_length: int = None, regex: str = None, + deprecated: bool = None, **extra: Any, ): - self.description = description - self.deprecated = deprecated self.convert_underscores = convert_underscores super().__init__( default, @@ -161,6 +157,7 @@ class Header(Param): min_length=min_length, max_length=max_length, regex=regex, + deprecated=deprecated, **extra, ) @@ -172,7 +169,6 @@ class Cookie(Param): self, default: Any, *, - deprecated: bool = None, alias: str = None, title: str = None, description: str = None, @@ -183,10 +179,9 @@ class Cookie(Param): min_length: int = None, max_length: int = None, regex: str = None, + deprecated: bool = None, **extra: Any, ): - self.description = description - self.deprecated = deprecated super().__init__( default, alias=alias, @@ -199,6 +194,7 @@ class Cookie(Param): min_length=min_length, max_length=max_length, regex=regex, + deprecated=deprecated, **extra, ) diff --git a/fastapi/routing.py b/fastapi/routing.py index ef6c13de7..80b8056aa 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -205,11 +205,11 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, methods: List[str] = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> None: route = APIRoute( path, @@ -221,11 +221,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=methods, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) self.routes.append(route) @@ -240,11 +240,11 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, methods: List[str] = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: def decorator(func: Callable) -> Callable: self.add_api_route( @@ -257,11 +257,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=methods, operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) return func @@ -285,19 +285,19 @@ class APIRouter(routing.Router): description=route.description, response_description=route.response_description, deprecated=route.deprecated, - name=route.name, methods=route.methods, operation_id=route.operation_id, include_in_schema=route.include_in_schema, content_type=route.content_type, + name=route.name, ) elif isinstance(route, routing.Route): self.add_route( prefix + route.path, route.endpoint, methods=route.methods, - name=route.name, include_in_schema=route.include_in_schema, + name=route.name, ) def get( @@ -311,10 +311,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -325,11 +325,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["GET"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def put( @@ -343,10 +343,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -357,11 +357,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["PUT"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def post( @@ -375,10 +375,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -389,11 +389,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["POST"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def delete( @@ -407,10 +407,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -421,11 +421,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["DELETE"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def options( @@ -439,10 +439,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -453,11 +453,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["OPTIONS"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def head( @@ -471,10 +471,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -485,11 +485,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["HEAD"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def patch( @@ -503,10 +503,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -517,11 +517,11 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["PATCH"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, ) def trace( @@ -535,10 +535,10 @@ class APIRouter(routing.Router): description: str = None, response_description: str = "Successful Response", deprecated: bool = None, - name: str = None, operation_id: str = None, include_in_schema: bool = True, content_type: Type[Response] = JSONResponse, + name: str = None, ) -> Callable: return self.api_route( path=path, @@ -549,9 +549,9 @@ class APIRouter(routing.Router): description=description, response_description=response_description, deprecated=deprecated, - name=name, methods=["TRACE"], operation_id=operation_id, include_in_schema=include_in_schema, content_type=content_type, + name=name, )