]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
📝 Clarify `response_class` parameter, validations, and returning a response directly...
authorSebastián Ramírez <tiangolo@gmail.com>
Sun, 25 Aug 2024 00:01:04 +0000 (19:01 -0500)
committerGitHub <noreply@github.com>
Sun, 25 Aug 2024 00:01:04 +0000 (19:01 -0500)
docs/en/docs/advanced/custom-response.md

index 8a6555dba189a89ef873b3b9853ae12bf00704ff..79f755815309de2fd73b8cc44ca87546bc39ddff 100644 (file)
@@ -4,9 +4,9 @@ By default, **FastAPI** will return the responses using `JSONResponse`.
 
 You can override it by returning a `Response` directly as seen in [Return a Response directly](response-directly.md){.internal-link target=_blank}.
 
-But if you return a `Response` directly, the data won't be automatically converted, and the documentation won't be automatically generated (for example, including the specific "media type", in the HTTP header `Content-Type` as part of the generated OpenAPI).
+But if you return a `Response` directly (or any subclass, like `JSONResponse`), the data won't be automatically converted (even if you declare a `response_model`), and the documentation won't be automatically generated (for example, including the specific "media type", in the HTTP header `Content-Type` as part of the generated OpenAPI).
 
-But you can also declare the `Response` that you want to be used, in the *path operation decorator*.
+But you can also declare the `Response` that you want to be used (e.g. any `Response` subclass), in the *path operation decorator* using the `response_class` parameter.
 
 The contents that you return from your *path operation function* will be put inside of that `Response`.