Remove code examples for Python 3.8 in `extending_openapi`

This commit is contained in:
Yurii Motov 2025-12-10 21:24:53 +01:00
parent 370f02f6d6
commit bdb6756f38
3 changed files with 6 additions and 6 deletions

View File

@ -43,19 +43,19 @@ For example, let's add <a href="https://github.com/Rebilly/ReDoc/blob/master/doc
First, write all your **FastAPI** application as normally: First, write all your **FastAPI** application as normally:
{* ../../docs_src/extending_openapi/tutorial001.py hl[1,4,7:9] *} {* ../../docs_src/extending_openapi/tutorial001_py39.py hl[1,4,7:9] *}
### Generate the OpenAPI schema { #generate-the-openapi-schema } ### Generate the OpenAPI schema { #generate-the-openapi-schema }
Then, use the same utility function to generate the OpenAPI schema, inside a `custom_openapi()` function: 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] *} {* ../../docs_src/extending_openapi/tutorial001_py39.py hl[2,15:21] *}
### Modify the OpenAPI schema { #modify-the-openapi-schema } ### Modify the OpenAPI schema { #modify-the-openapi-schema }
Now you can add the ReDoc extension, adding a custom `x-logo` to the `info` "object" in 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] *} {* ../../docs_src/extending_openapi/tutorial001_py39.py hl[22:24] *}
### Cache the OpenAPI schema { #cache-the-openapi-schema } ### Cache the OpenAPI schema { #cache-the-openapi-schema }
@ -65,13 +65,13 @@ 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. 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] *} {* ../../docs_src/extending_openapi/tutorial001_py39.py hl[13:14,25:26] *}
### Override the method { #override-the-method } ### Override the method { #override-the-method }
Now you can replace the `.openapi()` method with your new function. Now you can replace the `.openapi()` method with your new function.
{* ../../docs_src/extending_openapi/tutorial001.py hl[29] *} {* ../../docs_src/extending_openapi/tutorial001_py39.py hl[29] *}
### Check it { #check-it } ### Check it { #check-it }

View File

@ -1,6 +1,6 @@
from fastapi.testclient import TestClient from fastapi.testclient import TestClient
from docs_src.extending_openapi.tutorial001 import app from docs_src.extending_openapi.tutorial001_py39 import app
client = TestClient(app) client = TestClient(app)