Use schema description to populate field docstring
See original GitHub issueSimilar to #274 I would like to add docstrings for each field based on the jsonschema description. Purpose is for my IDE (VSCode) to pick up the description and show in mouse-over
{
"type": "object",
"properties": {
"mykey": {
"type": "string",
"description": "Field description"
}
}
}
Would lead to:
class Model(BaseModel):
mykey: Optional[str] = Field(None, description='Field description')
"""
Field description
"""
Maybe I am missing something else that could solve this, so I welcome alternative solutions.
I can try to submit a PR for this, if you agree that it would be useful.
Issue Analytics
- State:
- Created a year ago
- Reactions:2
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Schemas - Django REST framework
The schema generation in REST framework uses docstrings to automatically populate descriptions in the schema document. These descriptions will be based on: The ......
Read more >Specify types with docstrings | PyCharm Documentation
Information about the arguments and return values obtained during the debugging session will be used to pre-populate type annotations in a docstring.
Read more >GraphQL schema basics
This schema defines a hierarchy of types with fields that are populated from your back-end data stores. The schema also specifies exactly which...
Read more >datamodel-code-generator - GitHub Pages
This code generator creates pydantic model from an openapi file and others.
Read more >apispec - Read the Docs
Our application will have a marshmallow Schema for gists. from marshmallow import Schema, fields class GistParameter(Schema):.
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Went ahead and implemented it on my fork. Feedback is more than welcome, I’m not too familiar with this project.
Note that the description appears in either the
Field()
statement or the docstring, unlike in the proposal above.I am using the command line option
--custom-template-dir <path>
. I found it a bit strange that I had to also copy theConfig.jinja2
file to that path, since it is included in the base template, but it is no big deal. I think it is something about search path not being passed along to jinja.