Browse Source

🎨 Auto format

pull/14408/head
pre-commit-ci-lite[bot] 8 months ago
committed by GitHub
parent
commit
5960ddebfa
No known key found for this signature in database GPG Key ID: B5690EEEBB952194
  1. 280
      fastapi/applications.py
  2. 280
      fastapi/routing.py
  3. 4
      tests/test_http_query_method.py

280
fastapi/applications.py

@ -4537,22 +4537,22 @@ class FastAPI(Starlette):
) )
def query( def query(
self, self,
path: Annotated[ path: Annotated[
str, str,
Doc( Doc(
""" """
The URL path to be used for this *path operation*. The URL path to be used for this *path operation*.
For example, in `http://example.com/items`, the path is `/items`. For example, in `http://example.com/items`, the path is `/items`.
""" """
), ),
], ],
*, *,
response_model: Annotated[ response_model: Annotated[
Any, Any,
Doc( Doc(
""" """
The type to use for the response. The type to use for the response.
It could be any valid Pydantic *field* type. So, it doesn't have to It could be any valid Pydantic *field* type. So, it doesn't have to
@ -4581,12 +4581,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model](https://fastapi.tiangolo.com/tutorial/response-model/). [FastAPI docs for Response Model](https://fastapi.tiangolo.com/tutorial/response-model/).
""" """
), ),
] = Default(None), ] = Default(None),
status_code: Annotated[ status_code: Annotated[
Optional[int], Optional[int],
Doc( Doc(
""" """
The default status code to be used for the response. The default status code to be used for the response.
You could override the status code by returning a response directly. You could override the status code by returning a response directly.
@ -4594,12 +4594,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/). [FastAPI docs for Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/).
""" """
), ),
] = None, ] = None,
tags: Annotated[ tags: Annotated[
Optional[List[Union[str, Enum]]], Optional[List[Union[str, Enum]]],
Doc( Doc(
""" """
A list of tags to be applied to the *path operation*. A list of tags to be applied to the *path operation*.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
@ -4607,24 +4607,24 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags). [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags).
""" """
), ),
] = None, ] = None,
dependencies: Annotated[ dependencies: Annotated[
Optional[Sequence[Depends]], Optional[Sequence[Depends]],
Doc( Doc(
""" """
A list of dependencies (using `Depends()`) to be applied to the A list of dependencies (using `Depends()`) to be applied to the
*path operation*. *path operation*.
Read more about it in the Read more about it in the
[FastAPI docs for Dependencies in path operation decorators](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-in-path-operation-decorators/). [FastAPI docs for Dependencies in path operation decorators](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-in-path-operation-decorators/).
""" """
), ),
] = None, ] = None,
summary: Annotated[ summary: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
A summary for the *path operation*. A summary for the *path operation*.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
@ -4632,12 +4632,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/). [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
""" """
), ),
] = None, ] = None,
description: Annotated[ description: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
A description for the *path operation*. A description for the *path operation*.
If not provided, it will be extracted automatically from the docstring If not provided, it will be extracted automatically from the docstring
@ -4650,42 +4650,42 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/). [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
""" """
), ),
] = None, ] = None,
response_description: Annotated[ response_description: Annotated[
str, str,
Doc( Doc(
""" """
The description for the default response. The description for the default response.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
""" """
), ),
] = "Successful Response", ] = "Successful Response",
responses: Annotated[ responses: Annotated[
Optional[Dict[Union[int, str], Dict[str, Any]]], Optional[Dict[Union[int, str], Dict[str, Any]]],
Doc( Doc(
""" """
Additional responses that could be returned by this *path operation*. Additional responses that could be returned by this *path operation*.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
""" """
), ),
] = None, ] = None,
deprecated: Annotated[ deprecated: Annotated[
Optional[bool], Optional[bool],
Doc( Doc(
""" """
Mark this *path operation* as deprecated. Mark this *path operation* as deprecated.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
""" """
), ),
] = None, ] = None,
operation_id: Annotated[ operation_id: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
Custom operation ID to be used by this *path operation*. Custom operation ID to be used by this *path operation*.
By default, it is generated automatically. By default, it is generated automatically.
@ -4700,48 +4700,48 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function). [FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function).
""" """
), ),
] = None, ] = None,
response_model_include: Annotated[ response_model_include: Annotated[
Optional[IncEx], Optional[IncEx],
Doc( Doc(
""" """
Configuration passed to Pydantic to include only certain fields in the Configuration passed to Pydantic to include only certain fields in the
response data. response data.
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude).
""" """
), ),
] = None, ] = None,
response_model_exclude: Annotated[ response_model_exclude: Annotated[
Optional[IncEx], Optional[IncEx],
Doc( Doc(
""" """
Configuration passed to Pydantic to exclude certain fields in the Configuration passed to Pydantic to exclude certain fields in the
response data. response data.
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude).
""" """
), ),
] = None, ] = None,
response_model_by_alias: Annotated[ response_model_by_alias: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response model Configuration passed to Pydantic to define if the response model
should be serialized by alias when an alias is used. should be serialized by alias when an alias is used.
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude).
""" """
), ),
] = True, ] = True,
response_model_exclude_unset: Annotated[ response_model_exclude_unset: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response data Configuration passed to Pydantic to define if the response data
should have all the fields, including the ones that were not set and should have all the fields, including the ones that were not set and
have their default values. This is different from have their default values. This is different from
@ -4754,12 +4754,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter).
""" """
), ),
] = False, ] = False,
response_model_exclude_defaults: Annotated[ response_model_exclude_defaults: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response data Configuration passed to Pydantic to define if the response data
should have all the fields, including the ones that have the same value should have all the fields, including the ones that have the same value
as the default. This is different from `response_model_exclude_unset` as the default. This is different from `response_model_exclude_unset`
@ -4771,12 +4771,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter).
""" """
), ),
] = False, ] = False,
response_model_exclude_none: Annotated[ response_model_exclude_none: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response data should Configuration passed to Pydantic to define if the response data should
exclude fields set to `None`. exclude fields set to `None`.
@ -4788,12 +4788,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_exclude_none). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_exclude_none).
""" """
), ),
] = False, ] = False,
include_in_schema: Annotated[ include_in_schema: Annotated[
bool, bool,
Doc( Doc(
""" """
Include this *path operation* in the generated OpenAPI schema. Include this *path operation* in the generated OpenAPI schema.
This affects the generated OpenAPI (e.g. visible at `/docs`). This affects the generated OpenAPI (e.g. visible at `/docs`).
@ -4801,12 +4801,12 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Query Parameters and String Validations](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-parameters-from-openapi). [FastAPI docs for Query Parameters and String Validations](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-parameters-from-openapi).
""" """
), ),
] = True, ] = True,
response_class: Annotated[ response_class: Annotated[
Type[Response], Type[Response],
Doc( Doc(
""" """
Response class to be used for this *path operation*. Response class to be used for this *path operation*.
This will not be used if you return a response directly. This will not be used if you return a response directly.
@ -4814,20 +4814,20 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#redirectresponse). [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#redirectresponse).
""" """
), ),
] = Default(JSONResponse), ] = Default(JSONResponse),
name: Annotated[ name: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
Name for this *path operation*. Only used internally. Name for this *path operation*. Only used internally.
""" """
), ),
] = None, ] = None,
callbacks: Annotated[ callbacks: Annotated[
Optional[List[BaseRoute]], Optional[List[BaseRoute]],
Doc( Doc(
""" """
List of *path operations* that will be used as OpenAPI callbacks. List of *path operations* that will be used as OpenAPI callbacks.
This is only for OpenAPI documentation, the callbacks won't be used This is only for OpenAPI documentation, the callbacks won't be used
@ -4838,24 +4838,24 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs for OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/). [FastAPI docs for OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/).
""" """
), ),
] = None, ] = None,
openapi_extra: Annotated[ openapi_extra: Annotated[
Optional[Dict[str, Any]], Optional[Dict[str, Any]],
Doc( Doc(
""" """
Extra metadata to be included in the OpenAPI schema for this *path Extra metadata to be included in the OpenAPI schema for this *path
operation*. operation*.
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Advanced Configuration](https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#custom-openapi-path-operation-schema). [FastAPI docs for Path Operation Advanced Configuration](https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#custom-openapi-path-operation-schema).
""" """
), ),
] = None, ] = None,
generate_unique_id_function: Annotated[ generate_unique_id_function: Annotated[
Callable[[routing.APIRoute], str], Callable[[routing.APIRoute], str],
Doc( Doc(
""" """
Customize the function used to generate unique IDs for the *path Customize the function used to generate unique IDs for the *path
operations* shown in the generated OpenAPI. operations* shown in the generated OpenAPI.
@ -4865,8 +4865,8 @@ class FastAPI(Starlette):
Read more about it in the Read more about it in the
[FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function). [FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function).
""" """
), ),
] = Default(generate_unique_id), ] = Default(generate_unique_id),
) -> Callable[[DecoratedCallable], DecoratedCallable]: ) -> Callable[[DecoratedCallable], DecoratedCallable]:
""" """
Add a *path operation* using an HTTP QUERY operation. Add a *path operation* using an HTTP QUERY operation.

280
fastapi/routing.py

@ -4489,22 +4489,22 @@ class APIRouter(routing.Router):
) )
def query( def query(
self, self,
path: Annotated[ path: Annotated[
str, str,
Doc( Doc(
""" """
The URL path to be used for this *path operation*. The URL path to be used for this *path operation*.
For example, in `http://example.com/items`, the path is `/items`. For example, in `http://example.com/items`, the path is `/items`.
""" """
), ),
], ],
*, *,
response_model: Annotated[ response_model: Annotated[
Any, Any,
Doc( Doc(
""" """
The type to use for the response. The type to use for the response.
It could be any valid Pydantic *field* type. So, it doesn't have to It could be any valid Pydantic *field* type. So, it doesn't have to
@ -4533,12 +4533,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model](https://fastapi.tiangolo.com/tutorial/response-model/). [FastAPI docs for Response Model](https://fastapi.tiangolo.com/tutorial/response-model/).
""" """
), ),
] = Default(None), ] = Default(None),
status_code: Annotated[ status_code: Annotated[
Optional[int], Optional[int],
Doc( Doc(
""" """
The default status code to be used for the response. The default status code to be used for the response.
You could override the status code by returning a response directly. You could override the status code by returning a response directly.
@ -4546,12 +4546,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/). [FastAPI docs for Response Status Code](https://fastapi.tiangolo.com/tutorial/response-status-code/).
""" """
), ),
] = None, ] = None,
tags: Annotated[ tags: Annotated[
Optional[List[Union[str, Enum]]], Optional[List[Union[str, Enum]]],
Doc( Doc(
""" """
A list of tags to be applied to the *path operation*. A list of tags to be applied to the *path operation*.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
@ -4559,24 +4559,24 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags). [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#tags).
""" """
), ),
] = None, ] = None,
dependencies: Annotated[ dependencies: Annotated[
Optional[Sequence[params.Depends]], Optional[Sequence[params.Depends]],
Doc( Doc(
""" """
A list of dependencies (using `Depends()`) to be applied to the A list of dependencies (using `Depends()`) to be applied to the
*path operation*. *path operation*.
Read more about it in the Read more about it in the
[FastAPI docs for Dependencies in path operation decorators](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-in-path-operation-decorators/). [FastAPI docs for Dependencies in path operation decorators](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-in-path-operation-decorators/).
""" """
), ),
] = None, ] = None,
summary: Annotated[ summary: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
A summary for the *path operation*. A summary for the *path operation*.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
@ -4584,12 +4584,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/). [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
""" """
), ),
] = None, ] = None,
description: Annotated[ description: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
A description for the *path operation*. A description for the *path operation*.
If not provided, it will be extracted automatically from the docstring If not provided, it will be extracted automatically from the docstring
@ -4602,42 +4602,42 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/). [FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
""" """
), ),
] = None, ] = None,
response_description: Annotated[ response_description: Annotated[
str, str,
Doc( Doc(
""" """
The description for the default response. The description for the default response.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
""" """
), ),
] = "Successful Response", ] = "Successful Response",
responses: Annotated[ responses: Annotated[
Optional[Dict[Union[int, str], Dict[str, Any]]], Optional[Dict[Union[int, str], Dict[str, Any]]],
Doc( Doc(
""" """
Additional responses that could be returned by this *path operation*. Additional responses that could be returned by this *path operation*.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
""" """
), ),
] = None, ] = None,
deprecated: Annotated[ deprecated: Annotated[
Optional[bool], Optional[bool],
Doc( Doc(
""" """
Mark this *path operation* as deprecated. Mark this *path operation* as deprecated.
It will be added to the generated OpenAPI (e.g. visible at `/docs`). It will be added to the generated OpenAPI (e.g. visible at `/docs`).
""" """
), ),
] = None, ] = None,
operation_id: Annotated[ operation_id: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
Custom operation ID to be used by this *path operation*. Custom operation ID to be used by this *path operation*.
By default, it is generated automatically. By default, it is generated automatically.
@ -4652,48 +4652,48 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function). [FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function).
""" """
), ),
] = None, ] = None,
response_model_include: Annotated[ response_model_include: Annotated[
Optional[IncEx], Optional[IncEx],
Doc( Doc(
""" """
Configuration passed to Pydantic to include only certain fields in the Configuration passed to Pydantic to include only certain fields in the
response data. response data.
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude).
""" """
), ),
] = None, ] = None,
response_model_exclude: Annotated[ response_model_exclude: Annotated[
Optional[IncEx], Optional[IncEx],
Doc( Doc(
""" """
Configuration passed to Pydantic to exclude certain fields in the Configuration passed to Pydantic to exclude certain fields in the
response data. response data.
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude).
""" """
), ),
] = None, ] = None,
response_model_by_alias: Annotated[ response_model_by_alias: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response model Configuration passed to Pydantic to define if the response model
should be serialized by alias when an alias is used. should be serialized by alias when an alias is used.
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_include-and-response_model_exclude).
""" """
), ),
] = True, ] = True,
response_model_exclude_unset: Annotated[ response_model_exclude_unset: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response data Configuration passed to Pydantic to define if the response data
should have all the fields, including the ones that were not set and should have all the fields, including the ones that were not set and
have their default values. This is different from have their default values. This is different from
@ -4706,12 +4706,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter).
""" """
), ),
] = False, ] = False,
response_model_exclude_defaults: Annotated[ response_model_exclude_defaults: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response data Configuration passed to Pydantic to define if the response data
should have all the fields, including the ones that have the same value should have all the fields, including the ones that have the same value
as the default. This is different from `response_model_exclude_unset` as the default. This is different from `response_model_exclude_unset`
@ -4723,12 +4723,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#use-the-response_model_exclude_unset-parameter).
""" """
), ),
] = False, ] = False,
response_model_exclude_none: Annotated[ response_model_exclude_none: Annotated[
bool, bool,
Doc( Doc(
""" """
Configuration passed to Pydantic to define if the response data should Configuration passed to Pydantic to define if the response data should
exclude fields set to `None`. exclude fields set to `None`.
@ -4740,12 +4740,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_exclude_none). [FastAPI docs for Response Model - Return Type](https://fastapi.tiangolo.com/tutorial/response-model/#response_model_exclude_none).
""" """
), ),
] = False, ] = False,
include_in_schema: Annotated[ include_in_schema: Annotated[
bool, bool,
Doc( Doc(
""" """
Include this *path operation* in the generated OpenAPI schema. Include this *path operation* in the generated OpenAPI schema.
This affects the generated OpenAPI (e.g. visible at `/docs`). This affects the generated OpenAPI (e.g. visible at `/docs`).
@ -4753,12 +4753,12 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Query Parameters and String Validations](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-parameters-from-openapi). [FastAPI docs for Query Parameters and String Validations](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-parameters-from-openapi).
""" """
), ),
] = True, ] = True,
response_class: Annotated[ response_class: Annotated[
Type[Response], Type[Response],
Doc( Doc(
""" """
Response class to be used for this *path operation*. Response class to be used for this *path operation*.
This will not be used if you return a response directly. This will not be used if you return a response directly.
@ -4766,20 +4766,20 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#redirectresponse). [FastAPI docs for Custom Response - HTML, Stream, File, others](https://fastapi.tiangolo.com/advanced/custom-response/#redirectresponse).
""" """
), ),
] = Default(JSONResponse), ] = Default(JSONResponse),
name: Annotated[ name: Annotated[
Optional[str], Optional[str],
Doc( Doc(
""" """
Name for this *path operation*. Only used internally. Name for this *path operation*. Only used internally.
""" """
), ),
] = None, ] = None,
callbacks: Annotated[ callbacks: Annotated[
Optional[List[BaseRoute]], Optional[List[BaseRoute]],
Doc( Doc(
""" """
List of *path operations* that will be used as OpenAPI callbacks. List of *path operations* that will be used as OpenAPI callbacks.
This is only for OpenAPI documentation, the callbacks won't be used This is only for OpenAPI documentation, the callbacks won't be used
@ -4790,24 +4790,24 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs for OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/). [FastAPI docs for OpenAPI Callbacks](https://fastapi.tiangolo.com/advanced/openapi-callbacks/).
""" """
), ),
] = None, ] = None,
openapi_extra: Annotated[ openapi_extra: Annotated[
Optional[Dict[str, Any]], Optional[Dict[str, Any]],
Doc( Doc(
""" """
Extra metadata to be included in the OpenAPI schema for this *path Extra metadata to be included in the OpenAPI schema for this *path
operation*. operation*.
Read more about it in the Read more about it in the
[FastAPI docs for Path Operation Advanced Configuration](https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#custom-openapi-path-operation-schema). [FastAPI docs for Path Operation Advanced Configuration](https://fastapi.tiangolo.com/advanced/path-operation-advanced-configuration/#custom-openapi-path-operation-schema).
""" """
), ),
] = None, ] = None,
generate_unique_id_function: Annotated[ generate_unique_id_function: Annotated[
Callable[[APIRoute], str], Callable[[APIRoute], str],
Doc( Doc(
""" """
Customize the function used to generate unique IDs for the *path Customize the function used to generate unique IDs for the *path
operations* shown in the generated OpenAPI. operations* shown in the generated OpenAPI.
@ -4817,8 +4817,8 @@ class APIRouter(routing.Router):
Read more about it in the Read more about it in the
[FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function). [FastAPI docs about how to Generate Clients](https://fastapi.tiangolo.com/advanced/generate-clients/#custom-generate-unique-id-function).
""" """
), ),
] = Default(generate_unique_id), ] = Default(generate_unique_id),
) -> Callable[[DecoratedCallable], DecoratedCallable]: ) -> Callable[[DecoratedCallable], DecoratedCallable]:
""" """
Add a *path operation* using an HTTP QUERY operation. Add a *path operation* using an HTTP QUERY operation.

4
tests/test_http_query_method.py

@ -37,9 +37,7 @@ client = TestClient(app)
def test_query_item(): def test_query_item():
response = client.request( response = client.request("QUERY", "/items/", json={"name": "Foo", "price": 50.5})
"QUERY", "/items/", json={"name": "Foo", "price": 50.5}
)
assert response.status_code == 200 assert response.status_code == 200
assert response.json() == { assert response.json() == {
"name": "Foo", "name": "Foo",

Loading…
Cancel
Save