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

Use docstring as schema description #238

Open
antonagestam opened this issue Sep 26, 2022 · 3 comments
Open

Use docstring as schema description #238

antonagestam opened this issue Sep 26, 2022 · 3 comments
Labels
enhancement New feature or request help wanted Extra attention is needed

Comments

@antonagestam
Copy link
Owner

See #202 (comment).

@antonagestam antonagestam added enhancement New feature or request help wanted Extra attention is needed labels Sep 26, 2022
@antonagestam
Copy link
Owner Author

@apirogov Would you like to work on this feature?

@apirogov
Copy link

I digged a bit into the source and at looks to me that the __schema__ definitions everywhere just override the __schema__ method in SchemaField, and the only place where its connected to pydantic is __modify_schema__ in SchemaField, using that __schema__.

If this is the case, then would it not be enough to simply adapt __modify_schema__, so that it first getting the dict for the class returned by __schema__, and override / add the description from cls.__doc__, if it is defined?

If that's about it and I did not miss anything substantial, I surely can do it.

@antonagestam
Copy link
Owner Author

@apirogov I think that's it, should probably go next to the default for "title" here:

return {"title": cls.__name__}

A few tests will probably also need to be updated.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request help wanted Extra attention is needed
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants