Skip to content

More thorough docstrings on APIs and models #503

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

Closed
rtaycher opened this issue Sep 27, 2021 · 2 comments · Fixed by #551
Closed

More thorough docstrings on APIs and models #503

rtaycher opened this issue Sep 27, 2021 · 2 comments · Fixed by #551
Labels
✨ enhancement New feature or improvement
Milestone

Comments

@rtaycher
Copy link
Contributor

rtaycher commented Sep 27, 2021

Is your feature request related to a problem? Please describe.

Openapi documents can have a lot of information about apis and types and the client isn't currently adding
a good chunk of that information tothe docstring

Leading to people needing to refer back to the openapi file instead of the library.

Describe the solution you'd like
I think we could improve this situation. We should add as much context as is relevant to the docstrings.
From there they would be visible in the IDE and visible in any generated module documentation.

It would be nice if they were well formatted and maybe cross-refrenced but that's not the point of this issue.
The point is to have as much information as possible in the docstrings (inside the IDE or generated module documentation without looking at the openapi document)

currently API and model generation only uses the description field.

It looks like the api has at least a description and summary attribute which documents may or may not use

The models have attrs which have a description and example field. I can't find a way for attrs to get per attr documentation but at the very least it could be added to the class.

Additional context
I was thinking of starting with something like
def sync(
{{ arguments(endpoint) | indent(4) }}
) -> Optional[{{ return_string }}]:
"""{% if endpoint.summary %}{{ endpoint.summary | wordwrap(73)}}
{% else %}
{{ endpoint.title | wordwrap(73)}}
{% endif %}
{{ endpoint.description | wordwrap(73)}}"""

for endpoint_module.py.jinja. Well that plus if we have query fields instead of a model also including description and example for each of them

@rtaycher rtaycher added the ✨ enhancement New feature or improvement label Sep 27, 2021
@rtaycher
Copy link
Contributor Author

P.S. Is there a way to run the tool in place without installation or editable installation?
Trying to make changes and having to pip uninstall/re pip install every time is annoying.
--editable doesn't seem to work for pyproject.toml based packages

@dbanty dbanty linked a pull request Oct 17, 2021 that will close this issue
@dbanty dbanty added this to the 0.10.7 milestone Oct 17, 2021
@dbanty
Copy link
Collaborator

dbanty commented Oct 17, 2021

P.S. Is there a way to run the tool in place without installation or editable installation?
Trying to make changes and having to pip uninstall/re pip install every time is annoying.
--editable doesn't seem to work for pyproject.toml based packages

Sorry I didn't see this comment before now! I've been bombarded with GitHub notifications lately so a lot of them slip through the cracks :/. The best way is to use Poetry to manage the environment. Then if you're in a poetry shell running the command openapi-python-client will just use whatever the latest source is.

I tried to lay that out in CONTRIBUTING.md but please let me know how I can make it more clear to prospective contributors!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
✨ enhancement New feature or improvement
Projects
None yet
2 participants