pgjones / quart-schema

Quart-Schema is a Quart extension that provides schema validation and auto-generated API documentation.
MIT License
76 stars 24 forks source link

Support "examples" documentation #71

Open tyree731 opened 8 months ago

tyree731 commented 8 months ago

As far as I can tell, nothing in this module allows you to specify example responses for different models. It would be nice if, perhaps through some decorator applied to a method on a pydantic model, one could provide an example response that the API might return, having that example response propagated through to the openapi spec and documentation.

nkwade commented 3 months ago

I second this, I was searching for how to provide an example response. I have to put an example response in my docstring now which will just look weird and people would have to look thru 2 "example response" section. Just being able to edit this myself would be great.

pgjones commented 3 months ago

This is already possible with Pydantic models, but not with others see https://docs.pydantic.dev/latest/concepts/json_schema/#using-json_schema_extra-with-a-dict and 93f26200cd1af0650daa0fb75110b3691cc10f4a. I'll document this if msgspec also supports, see https://github.com/jcrist/msgspec/issues/689.