|
|
@ -430,7 +430,7 @@ class APIRoute(routing.Route): |
|
|
|
self, |
|
|
|
path: str, |
|
|
|
endpoint: Callable[..., Any], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Any = Default(None), |
|
|
|
status_code: Optional[int] = None, |
|
|
|
tags: Optional[List[Union[str, Enum]]] = None, |
|
|
@ -459,6 +459,7 @@ class APIRoute(routing.Route): |
|
|
|
generate_unique_id_function: Union[ |
|
|
|
Callable[["APIRoute"], str], DefaultPlaceholder |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> None: |
|
|
|
self.path = path |
|
|
|
self.endpoint = endpoint |
|
|
@ -621,7 +622,7 @@ class APIRouter(routing.Router): |
|
|
|
|
|
|
|
def __init__( |
|
|
|
self, |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
prefix: Annotated[str, Doc("An optional path prefix for the router.")] = "", |
|
|
|
tags: Annotated[ |
|
|
|
Optional[List[Union[str, Enum]]], |
|
|
@ -833,6 +834,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> None: |
|
|
|
super().__init__( |
|
|
|
routes=routes, |
|
|
@ -882,7 +884,7 @@ class APIRouter(routing.Router): |
|
|
|
self, |
|
|
|
path: str, |
|
|
|
endpoint: Callable[..., Any], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Any = Default(None), |
|
|
|
status_code: Optional[int] = None, |
|
|
|
tags: Optional[List[Union[str, Enum]]] = None, |
|
|
@ -911,6 +913,7 @@ class APIRouter(routing.Router): |
|
|
|
generate_unique_id_function: Union[ |
|
|
|
Callable[[APIRoute], str], DefaultPlaceholder |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> None: |
|
|
|
route_class = route_class_override or self.route_class |
|
|
|
responses = responses or {} |
|
|
@ -932,7 +935,8 @@ class APIRouter(routing.Router): |
|
|
|
) |
|
|
|
route = route_class( |
|
|
|
self.prefix + path, |
|
|
|
endpoint=endpoint, |
|
|
|
endpoint, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=current_tags, |
|
|
@ -957,13 +961,14 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=current_callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=current_generate_unique_id, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
self.routes.append(route) |
|
|
|
|
|
|
|
def api_route( |
|
|
|
self, |
|
|
|
path: str, |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Any = Default(None), |
|
|
|
status_code: Optional[int] = None, |
|
|
|
tags: Optional[List[Union[str, Enum]]] = None, |
|
|
@ -989,11 +994,13 @@ class APIRouter(routing.Router): |
|
|
|
generate_unique_id_function: Callable[[APIRoute], str] = Default( |
|
|
|
generate_unique_id |
|
|
|
), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
def decorator(func: DecoratedCallable) -> DecoratedCallable: |
|
|
|
self.add_api_route( |
|
|
|
path, |
|
|
|
func, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -1017,6 +1024,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
return func |
|
|
|
|
|
|
@ -1122,7 +1130,7 @@ class APIRouter(routing.Router): |
|
|
|
def include_router( |
|
|
|
self, |
|
|
|
router: Annotated["APIRouter", Doc("The `APIRouter` to include.")], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
prefix: Annotated[str, Doc("An optional path prefix for the router.")] = "", |
|
|
|
tags: Annotated[ |
|
|
|
Optional[List[Union[str, Enum]]], |
|
|
@ -1230,6 +1238,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> None: |
|
|
|
""" |
|
|
|
Include another `APIRouter` in the same current `APIRouter`. |
|
|
@ -1302,6 +1311,7 @@ class APIRouter(routing.Router): |
|
|
|
self.add_api_route( |
|
|
|
prefix + route.path, |
|
|
|
route.endpoint, |
|
|
|
*args, |
|
|
|
response_model=route.response_model, |
|
|
|
status_code=route.status_code, |
|
|
|
tags=current_tags, |
|
|
@ -1328,6 +1338,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=current_callbacks, |
|
|
|
openapi_extra=route.openapi_extra, |
|
|
|
generate_unique_id_function=current_generate_unique_id, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
elif isinstance(route, routing.Route): |
|
|
|
methods = list(route.methods or []) |
|
|
@ -1375,7 +1386,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -1694,6 +1705,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP GET operation. |
|
|
@ -1714,7 +1726,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -1738,6 +1751,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def put( |
|
|
@ -1752,7 +1766,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -2071,6 +2085,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP PUT operation. |
|
|
@ -2096,7 +2111,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -2120,6 +2136,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def post( |
|
|
@ -2134,7 +2151,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -2453,6 +2470,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP POST operation. |
|
|
@ -2478,7 +2496,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -2502,6 +2521,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def delete( |
|
|
@ -2516,7 +2536,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -2835,6 +2855,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP DELETE operation. |
|
|
@ -2855,7 +2876,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -2879,6 +2901,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def options( |
|
|
@ -2893,7 +2916,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -3212,6 +3235,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP OPTIONS operation. |
|
|
@ -3232,7 +3256,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -3256,6 +3281,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def head( |
|
|
@ -3270,7 +3296,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -3589,6 +3615,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP HEAD operation. |
|
|
@ -3614,7 +3641,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -3638,6 +3666,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def patch( |
|
|
@ -3652,7 +3681,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -3971,6 +4000,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP PATCH operation. |
|
|
@ -3996,7 +4026,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -4020,6 +4051,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
def trace( |
|
|
@ -4034,7 +4066,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
], |
|
|
|
*, |
|
|
|
*args: Any, |
|
|
|
response_model: Annotated[ |
|
|
|
Any, |
|
|
|
Doc( |
|
|
@ -4353,6 +4385,7 @@ class APIRouter(routing.Router): |
|
|
|
""" |
|
|
|
), |
|
|
|
] = Default(generate_unique_id), |
|
|
|
**kwargs: Any, |
|
|
|
) -> Callable[[DecoratedCallable], DecoratedCallable]: |
|
|
|
""" |
|
|
|
Add a *path operation* using an HTTP TRACE operation. |
|
|
@ -4378,7 +4411,8 @@ class APIRouter(routing.Router): |
|
|
|
``` |
|
|
|
""" |
|
|
|
return self.api_route( |
|
|
|
path=path, |
|
|
|
path, |
|
|
|
*args, |
|
|
|
response_model=response_model, |
|
|
|
status_code=status_code, |
|
|
|
tags=tags, |
|
|
@ -4402,6 +4436,7 @@ class APIRouter(routing.Router): |
|
|
|
callbacks=callbacks, |
|
|
|
openapi_extra=openapi_extra, |
|
|
|
generate_unique_id_function=generate_unique_id_function, |
|
|
|
**kwargs, |
|
|
|
) |
|
|
|
|
|
|
|
@deprecated( |
|
|
|