* 🌐 Refactor file structure to support internationalization * ✅ Update tests changed after i18n * 🔀 Merge Typer style from master * 🔧 Update MkConfig with Typer-styles * 🎨 Format mkdocs.yml with cannonical form * 🎨 Format mkdocs.yml * 🔧 Update MkDocs config * ➕ Add docs translation scripts dependencies * ✨ Add Typer scripts to handle translations * ✨ Add missing translation snippet to include * ✨ Update contributing docs, add docs for translations * 🙈 Add docs_build to gitignore * 🔧 Update scripts with new locations and docs scripts * 👷 Update docs deploy action with translations * 📝 Add note about languages not supported in the theme * ✨ Add first translation, for Spanish
1.9 KiB
Path Operation Advanced Configuration
OpenAPI operationId
!!! warning If you are not an "expert" in OpenAPI, you probably don't need this.
You can set the OpenAPI operationId to be used in your path operation with the parameter operation_id.
You would have to make sure that it is unique for each operation.
{!../../../docs_src/path_operation_advanced_configuration/tutorial001.py!}
Using the path operation function name as the operationId
If you want to use your APIs' function names as operationIds, you can iterate over all of them and override each path operation's operation_id using their APIRoute.name.
You should do it after adding all your path operations.
{!../../../docs_src/path_operation_advanced_configuration/tutorial002.py!}
!!! tip
If you manually call app.openapi(), you should update the operationIds before that.
!!! warning If you do this, you have to make sure each one of your path operation functions has a unique name.
Even if they are in different modules (Python files).
Exclude from OpenAPI
To exclude a path operation from the generated OpenAPI schema (and thus, from the automatic documentation systems), use the parameter include_in_schema and set it to False;
{!../../../docs_src/path_operation_advanced_configuration/tutorial003.py!}
Advanced description from docstring
You can limit the lines used from the docstring of a path operation function for OpenAPI.
Adding an \f (an escaped "form feed" character) causes FastAPI to truncate the output used for OpenAPI at this point.
It won't show up in the documentation, but other tools (such as Sphinx) will be able to use the rest.
{!../../../docs_src/path_operation_advanced_configuration/tutorial004.py!}