flask-openapi3
flask-openapi3 copied to clipboard
How to add examples to swagger
Hi! I'm trying to find out how to properly create swagger examples. I have tried a number of different things but I haven't gotten it to work and I don't see any mention of this anywhere in here.
code
Here you can see I am attempting to add the kwarg examples to my pydantic Field.
Field(..., examples='John Doe')
I see that the pydantic FieldInfo object annotates this argument as a list (here) examples: list[Any] | None and tried that in various ways to no avail:
examples=[{'test': 'John Doe'}]examples=[{'test': {'value': 'John Doe'}}]
result
And here you can see that in swagger it does add the field key to the example but not the value.
What I see
{
"driver_fullname": "string"
}
What I expected
{
"driver_fullname": "John Doe"
}
You can refer to the documentation here:
https://luolingchun.github.io/flask-openapi3/v3.x/Usage/Model_Config/