datamodel-code-generator icon indicating copy to clipboard operation
datamodel-code-generator copied to clipboard

Add `model_config = ConfigDict(use_attribute_docstrings=True)` when the command option `--use-field-description` is used

Open 9ao9ai9ar opened this issue 6 months ago • 1 comments

The use_attribute_docstrings key is available in Pydantic v2.7+ that enables docstrings of attributes to be used for field descriptions. If the value is the default False, the examples in the linked documentation would print None. It'll be nice for the docstrings to still be accessible via Model.model_fields["x"].description, just like if it's defined using Field(description="Description in Field").

9ao9ai9ar avatar Jul 30 '24 12:07 9ao9ai9ar