]> git.ipfire.org Git - thirdparty/fastapi/fastapi.git/commitdiff
🎨 Adjust spacing (#12635)
authorAlejandra <90076947+alejsdev@users.noreply.github.com>
Sun, 27 Oct 2024 22:39:38 +0000 (22:39 +0000)
committerGitHub <noreply@github.com>
Sun, 27 Oct 2024 22:39:38 +0000 (22:39 +0000)
docs/en/docs/how-to/custom-request-and-route.md
docs/en/docs/how-to/extending-openapi.md
docs/en/docs/how-to/graphql.md

index f80887c0dbc344b35e1ee205675a5a7de1135304..25ec0a3350c5be43e2fb98048ca623229014e583 100644 (file)
@@ -44,7 +44,6 @@ That way, the same route class can handle gzip compressed or uncompressed reques
 
 {* ../../docs_src/custom_request_and_route/tutorial001.py hl[8:15] *}
 
-
 ### Create a custom `GzipRoute` class
 
 Next, we create a custom subclass of `fastapi.routing.APIRoute` that will make use of the `GzipRequest`.
@@ -55,10 +54,8 @@ This method returns a function. And that function is what will receive a request
 
 Here we use it to create a `GzipRequest` from the original request.
 
-
 {* ../../docs_src/custom_request_and_route/tutorial001.py hl[18:26] *}
 
-
 /// note | "Technical Details"
 
 A `Request` has a `request.scope` attribute, that's just a Python `dict` containing the metadata related to the request.
@@ -95,25 +92,18 @@ We can also use this same approach to access the request body in an exception ha
 
 All we need to do is handle the request inside a `try`/`except` block:
 
-
 {* ../../docs_src/custom_request_and_route/tutorial002.py hl[13,15] *}
 
-
 If an exception occurs, the`Request` instance will still be in scope, so we can read and make use of the request body when handling the error:
 
-
 {* ../../docs_src/custom_request_and_route/tutorial002.py hl[16:18] *}
 
-
-
 ## Custom `APIRoute` class in a router
 
 You can also set the `route_class` parameter of an `APIRouter`:
 
 {* ../../docs_src/custom_request_and_route/tutorial003.py hl[26] *}
 
-
 In this example, the *path operations* under the `router` will use the custom `TimedRoute` class, and will have an extra `X-Response-Time` header in the response with the time it took to generate the response:
 
-
 {* ../../docs_src/custom_request_and_route/tutorial003.py hl[13:20] *}
index 8c77907255cd2d9a23119c4ef3770a77eaa47870..26c742c203cecaad3c5fcdda577888ef2358bc6b 100644 (file)
@@ -45,23 +45,18 @@ First, write all your **FastAPI** application as normally:
 
 {* ../../docs_src/extending_openapi/tutorial001.py hl[1,4,7:9] *}
 
-
 ### Generate the OpenAPI schema
 
 Then, use the same utility function to generate the OpenAPI schema, inside a `custom_openapi()` function:
 
-
-
 {* ../../docs_src/extending_openapi/tutorial001.py hl[2,15:21] *}
 
-
 ### Modify the OpenAPI schema
 
 Now you can add the ReDoc extension, adding a custom `x-logo` to the `info` "object" in the OpenAPI schema:
 
 {* ../../docs_src/extending_openapi/tutorial001.py hl[22:24] *}
 
-
 ### Cache the OpenAPI schema
 
 You can use the property `.openapi_schema` as a "cache", to store your generated schema.
@@ -70,19 +65,14 @@ That way, your application won't have to generate the schema every time a user o
 
 It will be generated only once, and then the same cached schema will be used for the next requests.
 
-
 {* ../../docs_src/extending_openapi/tutorial001.py hl[13:14,25:26] *}
 
-
 ### Override the method
 
 Now you can replace the `.openapi()` method with your new function.
 
-
-
 {* ../../docs_src/extending_openapi/tutorial001.py hl[29] *}
 
-
 ### Check it
 
 Once you go to <a href="http://127.0.0.1:8000/redoc" class="external-link" target="_blank">http://127.0.0.1:8000/redoc</a> you will see that you are using your custom logo (in this example, **FastAPI**'s logo):
index 5d8f879d174ac3b34ee1640253d80871c87cc82c..a6219e481d6506a8626ea1d14b77a26b51d11e21 100644 (file)
@@ -35,10 +35,8 @@ Depending on your use case, you might prefer to use a different library, but if
 
 Here's a small preview of how you could integrate Strawberry with FastAPI:
 
-
 {* ../../docs_src/graphql/tutorial001.py hl[3,22,25:26] *}
 
-
 You can learn more about Strawberry in the <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry documentation</a>.
 
 And also the docs about <a href="https://strawberry.rocks/docs/integrations/fastapi" class="external-link" target="_blank">Strawberry with FastAPI</a>.