sanic-org / sanic-openapi

Easily document your Sanic API with a UI
https://sanic-openapi.readthedocs.io/
MIT License
505 stars 108 forks source link

feat: docstring parsing #208

Closed artcg closed 3 years ago

artcg commented 3 years ago

Closes https://github.com/sanic-org/sanic-openapi/issues/203

I decided to go with an approach where the user can specify their own yaml instead of going with a more complex parsing approach.

This has the upsides:

this has the downside:

Implementation notes:

For the future:

Somebody could add functools.wraps to the doc decorators if they would like to use them in conjunction with the docstring

I am not using those decorators so didnt look into that, actually the main point I wanted this feature was to avoid having to use the decorators

Heres a usage example: https://i.imgur.com/ViynuNY.png https://i.imgur.com/oORSqRa.png

Feedback welcome, tagging people who could be interested @denisovkv @ruckc @ioggstream

denisovkiv commented 3 years ago

Awesome feature! Suppose it should support every eligible yaml not only simple struct with one response and description as in example, am I right?

artcg commented 3 years ago

Yep, could be anything in the path operation spec :)

denisovkiv commented 3 years ago

Looks good for me