Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3d628d8

Browse files
committed
Adjust spacing
1 parent 5db8b49 commit 3d628d8

3 files changed

Lines changed: 0 additions & 22 deletions

File tree

docs/en/docs/how-to/custom-request-and-route.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ That way, the same route class can handle gzip compressed or uncompressed reques
4444

4545
{* ../../docs_src/custom_request_and_route/tutorial001.py hl[8:15] *}
4646

47-
4847
### Create a custom `GzipRoute` class
4948

5049
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
5554

5655
Here we use it to create a `GzipRequest` from the original request.
5756

58-
5957
{* ../../docs_src/custom_request_and_route/tutorial001.py hl[18:26] *}
6058

61-
6259
/// note | "Technical Details"
6360

6461
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
9592

9693
All we need to do is handle the request inside a `try`/`except` block:
9794

98-
9995
{* ../../docs_src/custom_request_and_route/tutorial002.py hl[13,15] *}
10096

101-
10297
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:
10398

104-
10599
{* ../../docs_src/custom_request_and_route/tutorial002.py hl[16:18] *}
106100

107-
108-
109101
## Custom `APIRoute` class in a router
110102

111103
You can also set the `route_class` parameter of an `APIRouter`:
112104

113105
{* ../../docs_src/custom_request_and_route/tutorial003.py hl[26] *}
114106

115-
116107
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:
117108

118-
119109
{* ../../docs_src/custom_request_and_route/tutorial003.py hl[13:20] *}

docs/en/docs/how-to/extending-openapi.md

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,23 +45,18 @@ First, write all your **FastAPI** application as normally:
4545

4646
{* ../../docs_src/extending_openapi/tutorial001.py hl[1,4,7:9] *}
4747

48-
4948
### Generate the OpenAPI schema
5049

5150
Then, use the same utility function to generate the OpenAPI schema, inside a `custom_openapi()` function:
5251

53-
54-
5552
{* ../../docs_src/extending_openapi/tutorial001.py hl[2,15:21] *}
5653

57-
5854
### Modify the OpenAPI schema
5955

6056
Now you can add the ReDoc extension, adding a custom `x-logo` to the `info` "object" in the OpenAPI schema:
6157

6258
{* ../../docs_src/extending_openapi/tutorial001.py hl[22:24] *}
6359

64-
6560
### Cache the OpenAPI schema
6661

6762
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
7065

7166
It will be generated only once, and then the same cached schema will be used for the next requests.
7267

73-
7468
{* ../../docs_src/extending_openapi/tutorial001.py hl[13:14,25:26] *}
7569

76-
7770
### Override the method
7871

7972
Now you can replace the `.openapi()` method with your new function.
8073

81-
82-
8374
{* ../../docs_src/extending_openapi/tutorial001.py hl[29] *}
8475

85-
8676
### Check it
8777

8878
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):

docs/en/docs/how-to/graphql.md

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,8 @@ Depending on your use case, you might prefer to use a different library, but if
3535

3636
Here's a small preview of how you could integrate Strawberry with FastAPI:
3737

38-
3938
{* ../../docs_src/graphql/tutorial001.py hl[3,22,25:26] *}
4039

41-
4240
You can learn more about Strawberry in the <a href="https://strawberry.rocks/" class="external-link" target="_blank">Strawberry documentation</a>.
4341

4442
And also the docs about <a href="https://strawberry.rocks/docs/integrations/fastapi" class="external-link" target="_blank">Strawberry with FastAPI</a>.

0 commit comments

Comments
 (0)