jsontopydantic icon indicating copy to clipboard operation
jsontopydantic copied to clipboard

Include generated examples

Open bvanelli opened this issue 1 year ago • 1 comments

It it's extremely nice to load examples when building an API, since the OpenAPI specification is going to contain an example value from the actual response. If you are building a validator for an actual object, you know more or less how the data should look like. Here are the relevant docs for this feature: https://fastapi.tiangolo.com/tutorial/schema-extra-example/

This MR adds another customizer to include the examples when generating the model. Here is a preview:

jsontopydantic

Of course, when presented with multiple options, it will pick the first:

image

Closes #14

Suggested and implemented during a Hackergarten: https://www.meetup.com/pt-BR/hackergarten-stuttgart/, thanks everyone who participated 😃

bvanelli avatar Feb 09 '23 19:02 bvanelli