Browse Source

Remove code examples for Python 3.8 in `extending_openapi`

pull/14510/head
Yurii Motov 7 months ago
parent
commit
bdb6756f38
  1. 10
      docs/en/docs/how-to/extending-openapi.md
  2. 0
      docs_src/extending_openapi/tutorial001_py39.py
  3. 2
      tests/test_tutorial/test_extending_openapi/test_tutorial001.py

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

@ -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 }

0
docs_src/extending_openapi/tutorial001.py → docs_src/extending_openapi/tutorial001_py39.py

2
tests/test_tutorial/test_extending_openapi/test_tutorial001.py

@ -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)

Loading…
Cancel
Save