You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Use Pydantic BaseModel description for documentation #281
There are three main ways to document Pydantic BaseModel fields:
Using Field(description="a nice description")
Using Annotated[T, "a nice description"]
Using docstrings below each field """a nice description""".
Example:
frompydanticimportBaseModelclassColor(BaseModel):
"""General Color class docstring."""r: int=Field(description="Amount of red.")
g: Annotated[int, "Amount of green."]
b: int"""Amount of blue."""
As of now, only option 3 generates documentation with great-docs.
Would it be possible to use the Field(description"...") or the Annotated patterns to generate documentation?
I know Pydantic allows setting the config use_attribute_docstrings so docstrings get turned into field descriptions, but most of my code has descriptions using the Field notation.
If that's technicallly not feasible, would it be possible to at least show all fields of a Pydantic BaseModel in docs, even if they don't have documentation docstrings?
Activity