mirror of
https://github.com/fastapi/fastapi.git
synced 2026-01-26 14:58:42 -05:00
Compare commits
4 Commits
point-to-d
...
additional
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
841c5c3189 | ||
|
|
fa7a5d38a7 | ||
|
|
cf7d4fe7b7 | ||
|
|
02d8c6e258 |
@@ -60,8 +60,7 @@ FastAPI also includes these JavaScript-only `presets` settings:
|
||||
|
||||
```JavaScript
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||
SwaggerUIBundle.presets.apis
|
||||
]
|
||||
```
|
||||
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
You can declare a parameter in a *path operation function* or dependency to be of type `Request` and then you can access the raw request object directly, without any validation, etc.
|
||||
|
||||
Read more about it in the [FastAPI docs about using Request directly](https://fastapi.tiangolo.com/advanced/using-request-directly/)
|
||||
|
||||
You can import it directly from `fastapi`:
|
||||
|
||||
```python
|
||||
|
||||
@@ -4,8 +4,6 @@ You can declare a parameter in a *path operation function* or dependency to be o
|
||||
|
||||
You can also use it directly to create an instance of it and return it from your *path operations*.
|
||||
|
||||
Read more about it in the [FastAPI docs about returning a custom Response](https://fastapi.tiangolo.com/advanced/response-directly/#returning-a-custom-response)
|
||||
|
||||
You can import it directly from `fastapi`:
|
||||
|
||||
```python
|
||||
|
||||
@@ -56,8 +56,6 @@ There are a couple of custom FastAPI response classes, you can use them to optim
|
||||
|
||||
## Starlette Responses
|
||||
|
||||
You can read more about all of them in the [FastAPI docs for Custom Response](https://fastapi.tiangolo.com/advanced/custom-response/) and in the [Starlette docs about Responses](https://starlette.dev/responses/).
|
||||
|
||||
::: fastapi.responses.FileResponse
|
||||
options:
|
||||
members:
|
||||
|
||||
@@ -28,8 +28,6 @@ from fastapi.security import (
|
||||
)
|
||||
```
|
||||
|
||||
Read more about them in the [FastAPI docs about Security](https://fastapi.tiangolo.com/tutorial/security/).
|
||||
|
||||
## API Key Security Schemes
|
||||
|
||||
::: fastapi.security.APIKeyCookie
|
||||
|
||||
@@ -2,8 +2,6 @@
|
||||
|
||||
When defining WebSockets, you normally declare a parameter of type `WebSocket` and with it you can read data from the client and send data to it.
|
||||
|
||||
Read more about it in the [FastAPI docs for WebSockets](https://fastapi.tiangolo.com/advanced/websockets/)
|
||||
|
||||
It is provided directly by Starlette, but you can import it from `fastapi`:
|
||||
|
||||
```python
|
||||
@@ -46,6 +44,16 @@ When you want to define dependencies that should be compatible with both HTTP an
|
||||
- send_json
|
||||
- close
|
||||
|
||||
When a client disconnects, a `WebSocketDisconnect` exception is raised, you can catch it.
|
||||
|
||||
You can import it directly form `fastapi`:
|
||||
|
||||
```python
|
||||
from fastapi import WebSocketDisconnect
|
||||
```
|
||||
|
||||
::: fastapi.WebSocketDisconnect
|
||||
|
||||
## WebSockets - additional classes
|
||||
|
||||
Additional classes for handling WebSockets.
|
||||
@@ -58,16 +66,4 @@ from fastapi.websockets import WebSocketDisconnect, WebSocketState
|
||||
|
||||
::: fastapi.websockets.WebSocketDisconnect
|
||||
|
||||
When a client disconnects, a `WebSocketDisconnect` exception is raised, you can catch it.
|
||||
|
||||
You can import it directly form `fastapi`:
|
||||
|
||||
```python
|
||||
from fastapi import WebSocketDisconnect
|
||||
```
|
||||
|
||||
Read more about it in the [FastAPI docs for WebSockets](https://fastapi.tiangolo.com/advanced/websockets/#handling-disconnections-and-multiple-clients)
|
||||
|
||||
::: fastapi.websockets.WebSocketState
|
||||
|
||||
`WebSocketState` is an enumeration of the possible states of a WebSocket connection.
|
||||
|
||||
@@ -672,7 +672,7 @@ class FastAPI(Starlette):
|
||||
in the autogenerated OpenAPI using the `root_path`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Behind a Proxy](https://fastapi.tiangolo.com/advanced/behind-a-proxy/#disable-automatic-server-from-root-path).
|
||||
[FastAPI docs for Behind a Proxy](https://fastapi.tiangolo.com/advanced/behind-a-proxy/#disable-automatic-server-from-root_path).
|
||||
|
||||
**Example**
|
||||
|
||||
@@ -739,7 +739,7 @@ class FastAPI(Starlette):
|
||||
It will be added to the generated OpenAPI (e.g. visible at `/docs`).
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/#deprecate-a-path-operation).
|
||||
[FastAPI docs for Path Operation Configuration](https://fastapi.tiangolo.com/tutorial/path-operation-configuration/).
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -812,9 +812,6 @@ class FastAPI(Starlette):
|
||||
|
||||
In this case, there would be two different schemas, one for input and
|
||||
another one for output.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about how to separate schemas for input and output](https://fastapi.tiangolo.com/how-to/separate-openapi-schemas)
|
||||
"""
|
||||
),
|
||||
] = True,
|
||||
|
||||
@@ -49,9 +49,6 @@ class HTTPException(StarletteHTTPException):
|
||||
Doc(
|
||||
"""
|
||||
HTTP status code to send to the client.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#use-httpexception)
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -61,9 +58,6 @@ class HTTPException(StarletteHTTPException):
|
||||
"""
|
||||
Any data to be sent to the client in the `detail` key of the JSON
|
||||
response.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#use-httpexception)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -72,10 +66,6 @@ class HTTPException(StarletteHTTPException):
|
||||
Doc(
|
||||
"""
|
||||
Any headers to send to the client in the response.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Handling Errors](https://fastapi.tiangolo.com/tutorial/handling-errors/#add-custom-headers)
|
||||
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
|
||||
@@ -33,9 +33,6 @@ def get_swagger_ui_html(
|
||||
|
||||
This is normally done automatically by FastAPI using the default URL
|
||||
`/openapi.json`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Conditional OpenAPI](https://fastapi.tiangolo.com/how-to/conditional-openapi/#conditional-openapi-from-settings-and-env-vars)
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -44,9 +41,6 @@ def get_swagger_ui_html(
|
||||
Doc(
|
||||
"""
|
||||
The HTML `<title>` content, normally shown in the browser tab.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -57,12 +51,17 @@ def get_swagger_ui_html(
|
||||
The URL to use to load the Swagger UI JavaScript.
|
||||
|
||||
It is normally set to a CDN URL.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
|
||||
"""
|
||||
),
|
||||
] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js",
|
||||
swagger_extra_js_urls: Annotated[
|
||||
Optional[list[str]],
|
||||
Doc(
|
||||
"""
|
||||
The URLs of additional JavaScript files to include.
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
swagger_css_url: Annotated[
|
||||
str,
|
||||
Doc(
|
||||
@@ -70,9 +69,6 @@ def get_swagger_ui_html(
|
||||
The URL to use to load the Swagger UI CSS.
|
||||
|
||||
It is normally set to a CDN URL.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
|
||||
"""
|
||||
),
|
||||
] = "https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css",
|
||||
@@ -89,9 +85,6 @@ def get_swagger_ui_html(
|
||||
Doc(
|
||||
"""
|
||||
The OAuth2 redirect URL, it is normally automatically handled by FastAPI.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -100,9 +93,6 @@ def get_swagger_ui_html(
|
||||
Doc(
|
||||
"""
|
||||
A dictionary with Swagger UI OAuth2 initialization configurations.
|
||||
|
||||
Read more about the available configuration options in the
|
||||
[Swagger UI docs](https://swagger.io/docs/open-source-tools/swagger-ui/usage/oauth2/).
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -113,9 +103,14 @@ def get_swagger_ui_html(
|
||||
Configuration parameters for Swagger UI.
|
||||
|
||||
It defaults to [swagger_ui_default_parameters][fastapi.openapi.docs.swagger_ui_default_parameters].
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about how to Configure Swagger UI](https://fastapi.tiangolo.com/how-to/configure-swagger-ui/).
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
swagger_extra_presets: Annotated[
|
||||
Optional[list[str]],
|
||||
Doc(
|
||||
"""
|
||||
Extra presets to add to Swagger UI.
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -135,6 +130,13 @@ def get_swagger_ui_html(
|
||||
if swagger_ui_parameters:
|
||||
current_swagger_ui_parameters.update(swagger_ui_parameters)
|
||||
|
||||
js_urls = [swagger_js_url]
|
||||
if swagger_extra_js_urls:
|
||||
js_urls.extend(swagger_extra_js_urls)
|
||||
scripts_str = "\n ".join(
|
||||
f'<script src="{js_url}"></script>' for js_url in js_urls
|
||||
)
|
||||
|
||||
html = f"""
|
||||
<!DOCTYPE html>
|
||||
<html>
|
||||
@@ -146,7 +148,7 @@ def get_swagger_ui_html(
|
||||
<body>
|
||||
<div id="swagger-ui">
|
||||
</div>
|
||||
<script src="{swagger_js_url}"></script>
|
||||
{scripts_str}
|
||||
<!-- `SwaggerUIBundle` is now available on the page -->
|
||||
<script>
|
||||
const ui = SwaggerUIBundle({{
|
||||
@@ -159,12 +161,18 @@ def get_swagger_ui_html(
|
||||
if oauth2_redirect_url:
|
||||
html += f"oauth2RedirectUrl: window.location.origin + '{oauth2_redirect_url}',"
|
||||
|
||||
html += """
|
||||
presets = ["SwaggerUIBundle.presets.apis"]
|
||||
if swagger_extra_presets:
|
||||
presets.extend(swagger_extra_presets)
|
||||
presets_str = ",\n ".join(presets)
|
||||
|
||||
html += f"""
|
||||
presets: [
|
||||
SwaggerUIBundle.presets.apis,
|
||||
SwaggerUIBundle.SwaggerUIStandalonePreset
|
||||
{presets_str},
|
||||
],
|
||||
})"""
|
||||
"""
|
||||
|
||||
html += " })"
|
||||
|
||||
if init_oauth:
|
||||
html += f"""
|
||||
@@ -189,9 +197,6 @@ def get_redoc_html(
|
||||
|
||||
This is normally done automatically by FastAPI using the default URL
|
||||
`/openapi.json`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Conditional OpenAPI](https://fastapi.tiangolo.com/how-to/conditional-openapi/#conditional-openapi-from-settings-and-env-vars)
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -200,9 +205,6 @@ def get_redoc_html(
|
||||
Doc(
|
||||
"""
|
||||
The HTML `<title>` content, normally shown in the browser tab.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -213,9 +215,6 @@ def get_redoc_html(
|
||||
The URL to use to load the ReDoc JavaScript.
|
||||
|
||||
It is normally set to a CDN URL.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Custom Docs UI Static Assets](https://fastapi.tiangolo.com/how-to/custom-docs-ui-assets/)
|
||||
"""
|
||||
),
|
||||
] = "https://cdn.jsdelivr.net/npm/redoc@2/bundles/redoc.standalone.js",
|
||||
|
||||
@@ -79,9 +79,6 @@ def Path( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Human-readable title.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Path Parameters and Numeric Validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#declare-metadata)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -99,9 +96,6 @@ def Path( # noqa: N802
|
||||
"""
|
||||
Greater than. If set, value must be greater than this. Only applicable to
|
||||
numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -111,9 +105,6 @@ def Path( # noqa: N802
|
||||
"""
|
||||
Greater than or equal. If set, value must be greater than or equal to
|
||||
this. Only applicable to numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -122,9 +113,6 @@ def Path( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Less than. If set, value must be less than this. Only applicable to numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -134,9 +122,6 @@ def Path( # noqa: N802
|
||||
"""
|
||||
Less than or equal. If set, value must be less than or equal to this.
|
||||
Only applicable to numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -228,9 +213,6 @@ def Path( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -361,9 +343,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Default value if the parameter field is not set.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#alternative-old-query-as-the-default-value)
|
||||
"""
|
||||
),
|
||||
] = Undefined,
|
||||
@@ -388,9 +367,6 @@ def Query( # noqa: N802
|
||||
This will be used to extract the data and for the generated OpenAPI.
|
||||
It is particularly useful when you can't use the name you want because it
|
||||
is a Python reserved keyword or similar.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#alias-parameters)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -426,9 +402,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Human-readable title.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#declare-more-metadata)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -437,9 +410,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Human-readable description.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#declare-more-metadata)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -449,9 +419,6 @@ def Query( # noqa: N802
|
||||
"""
|
||||
Greater than. If set, value must be greater than this. Only applicable to
|
||||
numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -461,9 +428,6 @@ def Query( # noqa: N802
|
||||
"""
|
||||
Greater than or equal. If set, value must be greater than or equal to
|
||||
this. Only applicable to numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -472,9 +436,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Less than. If set, value must be less than this. Only applicable to numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -484,9 +445,6 @@ def Query( # noqa: N802
|
||||
"""
|
||||
Less than or equal. If set, value must be less than or equal to this.
|
||||
Only applicable to numbers.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Path parameters numeric validations](https://fastapi.tiangolo.com/tutorial/path-params-numeric-validations/#number-validations-greater-than-and-less-than-or-equal)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -495,9 +453,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Minimum length for strings.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -506,9 +461,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Maximum length for strings.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -517,9 +469,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
RegEx pattern for strings.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#add-regular-expressions
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -587,9 +536,6 @@ def Query( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -624,9 +570,6 @@ def Query( # noqa: N802
|
||||
Mark this parameter field as deprecated.
|
||||
|
||||
It will affect the generated OpenAPI (e.g. visible at `/docs`).
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#deprecating-parameters)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -638,9 +581,6 @@ def Query( # noqa: N802
|
||||
You probably don't need it, but it's available.
|
||||
|
||||
This affects the generated OpenAPI (e.g. visible at `/docs`).
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-parameters-from-openapi
|
||||
"""
|
||||
),
|
||||
] = True,
|
||||
@@ -909,9 +849,6 @@ def Header( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -1215,9 +1152,6 @@ def Cookie( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -1543,9 +1477,6 @@ def Body( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -1859,9 +1790,6 @@ def Form( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -2174,9 +2102,6 @@ def File( # noqa: N802
|
||||
Doc(
|
||||
"""
|
||||
Example values for this field.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Declare Request Example Data](https://fastapi.tiangolo.com/tutorial/schema-extra-example/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -2290,9 +2215,6 @@ def Depends( # noqa: N802
|
||||
|
||||
Don't call it directly, FastAPI will call it for you, just pass the object
|
||||
directly.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -2308,9 +2230,6 @@ def Depends( # noqa: N802
|
||||
|
||||
Set `use_cache` to `False` to disable this behavior and ensure the
|
||||
dependency is called again (if declared more than once) in the same request.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about sub-dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/sub-dependencies/#using-the-same-dependency-multiple-times)
|
||||
"""
|
||||
),
|
||||
] = True,
|
||||
@@ -2331,9 +2250,6 @@ def Depends( # noqa: N802
|
||||
that handles the request (similar to when using `"function"`), but end
|
||||
**after** the response is sent back to the client. So, the dependency
|
||||
function will be executed **around** the **request** and response cycle.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for FastAPI Dependencies with yield](https://fastapi.tiangolo.com/tutorial/dependencies/dependencies-with-yield/#early-exit-and-scope)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -2379,9 +2295,6 @@ def Security( # noqa: N802
|
||||
|
||||
Don't call it directly, FastAPI will call it for you, just pass the object
|
||||
directly.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -2399,9 +2312,7 @@ def Security( # noqa: N802
|
||||
|
||||
These scopes are integrated with OpenAPI (and the API docs at `/docs`).
|
||||
So they are visible in the OpenAPI specification.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about OAuth2 scopes](https://fastapi.tiangolo.com/advanced/security/oauth2-scopes/)
|
||||
)
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -2416,9 +2327,6 @@ def Security( # noqa: N802
|
||||
|
||||
Set `use_cache` to `False` to disable this behavior and ensure the
|
||||
dependency is called again (if declared more than once) in the same request.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs about sub-dependencies](https://fastapi.tiangolo.com/tutorial/dependencies/sub-dependencies/#using-the-same-dependency-multiple-times)
|
||||
"""
|
||||
),
|
||||
] = True,
|
||||
|
||||
@@ -68,9 +68,6 @@ class OAuth2PasswordRequestForm:
|
||||
"password". Nevertheless, this dependency class is permissive and
|
||||
allows not passing it. If you want to enforce it, use instead the
|
||||
`OAuth2PasswordRequestFormStrict` dependency.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
@@ -81,9 +78,6 @@ class OAuth2PasswordRequestForm:
|
||||
"""
|
||||
`username` string. The OAuth2 spec requires the exact field name
|
||||
`username`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -94,9 +88,6 @@ class OAuth2PasswordRequestForm:
|
||||
"""
|
||||
`password` string. The OAuth2 spec requires the exact field name
|
||||
`password`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -121,9 +112,6 @@ class OAuth2PasswordRequestForm:
|
||||
* `users:read`
|
||||
* `profile`
|
||||
* `openid`
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
] = "",
|
||||
@@ -234,9 +222,6 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm):
|
||||
"password". This dependency is strict about it. If you want to be
|
||||
permissive, use instead the `OAuth2PasswordRequestForm` dependency
|
||||
class.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -247,9 +232,6 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm):
|
||||
"""
|
||||
`username` string. The OAuth2 spec requires the exact field name
|
||||
`username`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -260,9 +242,6 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm):
|
||||
"""
|
||||
`password` string. The OAuth2 spec requires the exact field name
|
||||
`password`.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -287,9 +266,6 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm):
|
||||
* `users:read`
|
||||
* `profile`
|
||||
* `openid`
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
] = "",
|
||||
@@ -447,9 +423,6 @@ class OAuth2PasswordBearer(OAuth2):
|
||||
"""
|
||||
The URL to obtain the OAuth2 token. This would be the *path operation*
|
||||
that has `OAuth2PasswordRequestForm` as a dependency.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
],
|
||||
@@ -469,9 +442,6 @@ class OAuth2PasswordBearer(OAuth2):
|
||||
"""
|
||||
The OAuth2 scopes that would be required by the *path operations* that
|
||||
use this dependency.
|
||||
|
||||
Read more about it in the
|
||||
[FastAPI docs for Simple OAuth2 with Password and Bearer](https://fastapi.tiangolo.com/tutorial/security/simple-oauth2/).
|
||||
"""
|
||||
),
|
||||
] = None,
|
||||
|
||||
@@ -18,9 +18,6 @@ def test_swagger_ui():
|
||||
assert "SwaggerUIBundle.presets.apis," in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"layout": "BaseLayout",' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
|
||||
@@ -21,9 +21,6 @@ def test_swagger_ui():
|
||||
assert "SwaggerUIBundle.presets.apis," in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"layout": "BaseLayout",' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
|
||||
@@ -24,9 +24,6 @@ def test_swagger_ui():
|
||||
assert "SwaggerUIBundle.presets.apis," in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert "SwaggerUIBundle.SwaggerUIStandalonePreset" in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
assert '"layout": "BaseLayout",' in response.text, (
|
||||
"default configs should be preserved"
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user