Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: docstring parsing #208

Merged
merged 5 commits into from Mar 16, 2021
Merged

feat: docstring parsing #208

merged 5 commits into from Mar 16, 2021

Conversation

artcg
Copy link
Contributor

@artcg artcg commented Mar 13, 2021

Closes #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:

  • https://github.com/flasgger/flasgger (openapi for flask) does something similar so users coming from there will be able to migrate easily
  • enables user to modify the yaml however they want, no restrictions
  • openapi3 compatibility straight away

this has the downside:

  • corrupted yaml could be hard to debug for beginner users

Implementation notes:

  • if yaml parsing fails, raises a warning and then ignores the yaml
  • if user uses doc decorators, it will use those first and then the yaml second

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

setup.py Outdated Show resolved Hide resolved
sanic_openapi/autodoc.py Outdated Show resolved Hide resolved
@denisovkv
Copy link
Contributor

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
Copy link
Contributor Author

artcg commented Mar 13, 2021

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

@denisovkv
Copy link
Contributor

Looks good for me

@ahopkins ahopkins merged commit 1eb0ce5 into sanic-org:master Mar 16, 2021
@artcg artcg deleted the autodoc branch March 17, 2021 08:20
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feature Request] Docstring parsing
3 participants