When using a single Body parameter (with embed=True) and example=, the openapi doc shows a nested entry, which differs with what actually works.
Following code:
@app.post("/")
def read_root(status: str = Body(..., embed=True, example={'status': 'allGood'}):
return status
Openapi docs "Example Value"
{
"status": {
"status": "allGood"
}
}
Working request will actually be:
{ "status": "allGood" }
openapi example should match the actual working request
Just do example='allGood'?
thank you, this does work.
Would this be considered a workaround or is this the proper way to handle this?
Thanks for the help @amacfie ! :bow:
@taoofshawn embed=True would be, more or less, for something simple and quick. If you need to add more custom examples or other things, it would probably be better to declare a Pydantic model with a status field.
You can see more details about adding examples in the docs: https://fastapi.tiangolo.com/tutorial/schema-extra-example/
understood, thanks!