4 changed files with 37 additions and 0 deletions
@ -0,0 +1,20 @@ |
|||||
|
## OpenAPI operationId |
||||
|
|
||||
|
!!! danger |
||||
|
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. |
||||
|
|
||||
|
```Python hl_lines="6" |
||||
|
{!./tutorial/src/path-operation-advanced-configuration/tutorial001.py!} |
||||
|
``` |
||||
|
|
||||
|
## 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`; |
||||
|
|
||||
|
```Python hl_lines="6" |
||||
|
{!./tutorial/src/path-operation-advanced-configuration/tutorial002.py!} |
||||
|
``` |
@ -0,0 +1,8 @@ |
|||||
|
from fastapi import FastAPI |
||||
|
|
||||
|
app = FastAPI() |
||||
|
|
||||
|
|
||||
|
@app.get("/items/", operation_id="some_specific_id_you_define") |
||||
|
async def read_items(): |
||||
|
return [{"item_id": "Foo"}] |
@ -0,0 +1,8 @@ |
|||||
|
from fastapi import FastAPI |
||||
|
|
||||
|
app = FastAPI() |
||||
|
|
||||
|
|
||||
|
@app.get("/items/", include_in_schema=False) |
||||
|
async def read_items(): |
||||
|
return [{"item_id": "Foo"}] |
Loading…
Reference in new issue