diff --git a/docs/en/docs/deployment/https.md b/docs/en/docs/deployment/https.md index a77678be92..886dfbe788 100644 --- a/docs/en/docs/deployment/https.md +++ b/docs/en/docs/deployment/https.md @@ -192,7 +192,7 @@ All this renewal process, while still serving the app, is one of the main reason ## Proxy Forwarded Headers { #proxy-forwarded-headers } -When using a proxy to handle HTTPS, your **application server** (for example Uvicorn via FastAPI CLI) doesn't known anything about the HTTPS process, it communicates with plain HTTP with the **TLS Termination Proxy**. +When using a proxy to handle HTTPS, your **application server** (for example Uvicorn via FastAPI CLI) doesn't know anything about the HTTPS process, it communicates with plain HTTP with the **TLS Termination Proxy**. This **proxy** would normally set some HTTP headers on the fly before transmitting the request to the **application server**, to let the application server know that the request is being **forwarded** by the proxy. diff --git a/docs/en/docs/environment-variables.md b/docs/en/docs/environment-variables.md index 010e27c37e..91bc25671a 100644 --- a/docs/en/docs/environment-variables.md +++ b/docs/en/docs/environment-variables.md @@ -291,7 +291,7 @@ This information will be useful when learning about [Virtual Environments](virtu With this you should have a basic understanding of what **environment variables** are and how to use them in Python. -You can also read more about them in the [Wikipedia for Environment Variable](https://en.wikipedia.org/wiki/Environment_variable). +You can also read more about them in the [Wikipedia for Environment Variables](https://en.wikipedia.org/wiki/Environment_variable). In many cases it's not very obvious how environment variables would be useful and applicable right away. But they keep showing up in many different scenarios when you are developing, so it's good to know about them. diff --git a/docs/en/docs/project-generation.md b/docs/en/docs/project-generation.md index aa579af5ef..23e798ba98 100644 --- a/docs/en/docs/project-generation.md +++ b/docs/en/docs/project-generation.md @@ -1,6 +1,6 @@ # Full Stack FastAPI Template { #full-stack-fastapi-template } -Templates, while typically come with a specific setup, are designed to be flexible and customizable. This allows you to modify and adapt them to your project's requirements, making them an excellent starting point. 🏁 +Templates, while they typically come with a specific setup, are designed to be flexible and customizable. This allows you to modify and adapt them to your project's requirements, making them an excellent starting point. 🏁 You can use this template to get started, as it includes a lot of the initial set up, security, database and some API endpoints already done for you. diff --git a/docs/en/docs/tutorial/body.md b/docs/en/docs/tutorial/body.md index dda9798d8b..1cc0aff492 100644 --- a/docs/en/docs/tutorial/body.md +++ b/docs/en/docs/tutorial/body.md @@ -12,7 +12,7 @@ To declare a **request** body, you use [Pydantic](https://docs.pydantic.dev/) mo To send data, you should use one of: `POST` (the more common), `PUT`, `DELETE` or `PATCH`. -Sending a body with a `GET` request has an undefined behavior in the specifications, nevertheless, it is supported by FastAPI, only for very complex/extreme use cases. +Sending a body with a `GET` request has undefined behavior in the specifications, nevertheless, it is supported by FastAPI, only for very complex/extreme use cases. As it is discouraged, the interactive docs with Swagger UI won't show the documentation for the body when using `GET`, and proxies in the middle might not support it. diff --git a/fastapi/datastructures.py b/fastapi/datastructures.py index 1da784cf09..dfb23bdede 100644 --- a/fastapi/datastructures.py +++ b/fastapi/datastructures.py @@ -182,5 +182,5 @@ def Default(value: DefaultType) -> DefaultType: # Sentinel for "parameter not provided" in Param/FieldInfo. -# Typed as None to satisfy ty +# Typed as None to satisfy type checkers _Unset = Default(None) diff --git a/fastapi/openapi/docs.py b/fastapi/openapi/docs.py index 0d9242f9fa..b764728e84 100644 --- a/fastapi/openapi/docs.py +++ b/fastapi/openapi/docs.py @@ -135,7 +135,7 @@ def get_swagger_ui_html( ] = None, ) -> HTMLResponse: """ - Generate and return the HTML that loads Swagger UI for the interactive + Generate and return the HTML that loads Swagger UI for the interactive API docs (normally served at `/docs`). You would only call this function yourself if you needed to override some parts, diff --git a/fastapi/param_functions.py b/fastapi/param_functions.py index 1856178fcb..331e354f65 100644 --- a/fastapi/param_functions.py +++ b/fastapi/param_functions.py @@ -518,7 +518,7 @@ def Query( # noqa: N802 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 + [FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#add-regular-expressions) """ ), ] = None, @@ -639,7 +639,7 @@ def Query( # noqa: N802 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 + [FastAPI docs about Query parameters](https://fastapi.tiangolo.com/tutorial/query-params-str-validations/#exclude-parameters-from-openapi) """ ), ] = True, diff --git a/fastapi/routing.py b/fastapi/routing.py index 21a1385a27..c72212d0d6 100644 --- a/fastapi/routing.py +++ b/fastapi/routing.py @@ -338,12 +338,9 @@ def _build_response_args( } # If status_code was set, use it, otherwise use the default from the # response class, in the case of redirect it's 307 - current_status_code = ( - status_code if status_code else solved_result.response.status_code - ) - if current_status_code is not None: - response_args["status_code"] = current_status_code - if solved_result.response.status_code: + if status_code is not None: + response_args["status_code"] = status_code + elif solved_result.response.status_code: response_args["status_code"] = solved_result.response.status_code return response_args diff --git a/fastapi/security/oauth2.py b/fastapi/security/oauth2.py index 3fd9e41eb3..53a114831f 100644 --- a/fastapi/security/oauth2.py +++ b/fastapi/security/oauth2.py @@ -112,7 +112,7 @@ class OAuth2PasswordRequestForm: ```python "items:read items:write users:read profile openid" - ```` + ``` would represent the scopes: @@ -278,7 +278,7 @@ class OAuth2PasswordRequestFormStrict(OAuth2PasswordRequestForm): ```python "items:read items:write users:read profile openid" - ```` + ``` would represent the scopes: diff --git a/tests/test_custom_swagger_ui_redirect.py b/tests/test_custom_swagger_ui_redirect.py index 996734be21..dee7aad08d 100644 --- a/tests/test_custom_swagger_ui_redirect.py +++ b/tests/test_custom_swagger_ui_redirect.py @@ -19,7 +19,6 @@ def test_swagger_ui(): assert response.status_code == 200, response.text assert response.headers["content-type"] == "text/html; charset=utf-8" assert "swagger-ui-dist" in response.text - print(client.base_url) assert ( f"oauth2RedirectUrl: window.location.origin + '{swagger_ui_oauth2_redirect_url}'" in response.text diff --git a/tests/test_no_swagger_ui_redirect.py b/tests/test_no_swagger_ui_redirect.py index 0df9a46e57..6031c3a1fc 100644 --- a/tests/test_no_swagger_ui_redirect.py +++ b/tests/test_no_swagger_ui_redirect.py @@ -17,7 +17,6 @@ def test_swagger_ui(): assert response.status_code == 200, response.text assert response.headers["content-type"] == "text/html; charset=utf-8" assert "swagger-ui-dist" in response.text - print(client.base_url) assert "oauth2RedirectUrl" not in response.text