|
|
@ -18,7 +18,7 @@ The first step is to disable the automatic docs, as by default, those use the de |
|
|
|
|
|
|
|
|
To disable them, set their URLs to `None` when creating your `FastAPI` app: |
|
|
To disable them, set their URLs to `None` when creating your `FastAPI` app: |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial001.py hl[8] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial001_py39.py hl[8] *} |
|
|
|
|
|
|
|
|
### Include the custom docs { #include-the-custom-docs } |
|
|
### Include the custom docs { #include-the-custom-docs } |
|
|
|
|
|
|
|
|
@ -34,7 +34,7 @@ You can reuse FastAPI's internal functions to create the HTML pages for the docs |
|
|
|
|
|
|
|
|
And similarly for ReDoc... |
|
|
And similarly for ReDoc... |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial001.py hl[2:6,11:19,22:24,27:33] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial001_py39.py hl[2:6,11:19,22:24,27:33] *} |
|
|
|
|
|
|
|
|
/// tip |
|
|
/// tip |
|
|
|
|
|
|
|
|
@ -50,7 +50,7 @@ Swagger UI will handle it behind the scenes for you, but it needs this "redirect |
|
|
|
|
|
|
|
|
Now, to be able to test that everything works, create a *path operation*: |
|
|
Now, to be able to test that everything works, create a *path operation*: |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial001.py hl[36:38] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial001_py39.py hl[36:38] *} |
|
|
|
|
|
|
|
|
### Test it { #test-it } |
|
|
### Test it { #test-it } |
|
|
|
|
|
|
|
|
@ -118,7 +118,7 @@ After that, your file structure could look like: |
|
|
* Import `StaticFiles`. |
|
|
* Import `StaticFiles`. |
|
|
* "Mount" a `StaticFiles()` instance in a specific path. |
|
|
* "Mount" a `StaticFiles()` instance in a specific path. |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[7,11] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[7,11] *} |
|
|
|
|
|
|
|
|
### Test the static files { #test-the-static-files } |
|
|
### Test the static files { #test-the-static-files } |
|
|
|
|
|
|
|
|
@ -144,7 +144,7 @@ The same as when using a custom CDN, the first step is to disable the automatic |
|
|
|
|
|
|
|
|
To disable them, set their URLs to `None` when creating your `FastAPI` app: |
|
|
To disable them, set their URLs to `None` when creating your `FastAPI` app: |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[9] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[9] *} |
|
|
|
|
|
|
|
|
### Include the custom docs for static files { #include-the-custom-docs-for-static-files } |
|
|
### Include the custom docs for static files { #include-the-custom-docs-for-static-files } |
|
|
|
|
|
|
|
|
@ -160,7 +160,7 @@ Again, you can reuse FastAPI's internal functions to create the HTML pages for t |
|
|
|
|
|
|
|
|
And similarly for ReDoc... |
|
|
And similarly for ReDoc... |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[2:6,14:22,25:27,30:36] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[2:6,14:22,25:27,30:36] *} |
|
|
|
|
|
|
|
|
/// tip |
|
|
/// tip |
|
|
|
|
|
|
|
|
@ -176,7 +176,7 @@ Swagger UI will handle it behind the scenes for you, but it needs this "redirect |
|
|
|
|
|
|
|
|
Now, to be able to test that everything works, create a *path operation*: |
|
|
Now, to be able to test that everything works, create a *path operation*: |
|
|
|
|
|
|
|
|
{* ../../docs_src/custom_docs_ui/tutorial002.py hl[39:41] *} |
|
|
{* ../../docs_src/custom_docs_ui/tutorial002_py39.py hl[39:41] *} |
|
|
|
|
|
|
|
|
### Test Static Files UI { #test-static-files-ui } |
|
|
### Test Static Files UI { #test-static-files-ui } |
|
|
|
|
|
|
|
|
|