mirror of https://github.com/tiangolo/fastapi.git
📝 Simplify example for docs for Additional Responses, remove unnecessary `else` (#4693)
This commit is contained in:
parent
96c3f44a0e
commit
dde140d8e3
|
|
@ -23,7 +23,7 @@ Each of those response `dict`s can have a key `model`, containing a Pydantic mod
|
||||||
|
|
||||||
For example, to declare another response with a status code `404` and a Pydantic model `Message`, you can write:
|
For example, to declare another response with a status code `404` and a Pydantic model `Message`, you can write:
|
||||||
|
|
||||||
```Python hl_lines="18 23"
|
```Python hl_lines="18 22"
|
||||||
{!../../../docs_src/additional_responses/tutorial001.py!}
|
{!../../../docs_src/additional_responses/tutorial001.py!}
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -19,5 +19,4 @@ app = FastAPI()
|
||||||
async def read_item(item_id: str):
|
async def read_item(item_id: str):
|
||||||
if item_id == "foo":
|
if item_id == "foo":
|
||||||
return {"id": "foo", "value": "there goes my hero"}
|
return {"id": "foo", "value": "there goes my hero"}
|
||||||
else:
|
return JSONResponse(status_code=404, content={"message": "Item not found"})
|
||||||
return JSONResponse(status_code=404, content={"message": "Item not found"})
|
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue