This is a feature release.
Changing behavior
- Default values of pydantic fields such as `UndefinedPydantic` and
`Ellipsis` will now be shown as `None`.
Bugfix
- Fix missing validator-field references in
`model-show-validator-summary` in case a single validator method
process multiple fields.
Feature
- Add `autodoc_pydantic_field_show_optional` configuration which
provides `[Optional]` marker for pydantic fields with
`default_factory`. This configuration is activated by default. If
deactivated, default values might be displayed incorrectly. For
more, see
[114](https://github.com/mansenfranzen/autodoc_pydantic/issues/114)
- Add `autodoc_pydantic_field_swap_name_and_alias` configuration which
allows to use a field\'s alias as a name instead of the original
field name
[99](https://github.com/mansenfranzen/autodoc_pydantic/issues/99) .
- Respect interaction between
`autodoc_pydantic_field_swap_name_and_alias` with
`model-show-validator-summary`, `model-show-field-summary`,
`validator-replace-signature` and `validator-list-fields` by
replacing the field name with field alias in rendered documentation.
Internals
- Determining default values of pydantic fields no longer use
`Field.field_info.default` but `Field.default`. As a consequence,
default values such as `UndefinedPydantic` and `Ellipsis` will now
be shown as `None`.
- Autodocumenter `PydanticFieldDocumenter` now passes
`field-show-alias` and `alias` to `PydanticField` directive. Before,
only `alias` was passed with value to denote `field-show-alias`.
However, since `field-swap-name-and-alias` was added, the value of
the alias might be required even without `field-show-alias` being
activated.
- Refactor and split `PydanticModelDocumenter.add_validators_summary`
in multiple methods for better readability and maintainability.
- Add `get_field_name_or_alias` to `PydanticAutoDoc` to centrally
manage the determination of field name/alias for all
auto-documenters.
- Rename `sanitize_configuration_option_name` into
`determine_app_cfg_name` in `directives/options/composites.py` for
better clarity.
- Add `configuration_names` to `AutoDocOptions` to distinguish foreign
directive options in `determine_app_cfg_name` which is required
because `field-swap-name-and-alias` is also used by model/validator
auto-documenters.
Documentation
- Add example section for `field-swap-name-and-alias`.
- Add configuration description for `field-swap-name-and-alias`.
Contributors
- Thanks to [spacemanspiff2007](https://github.com/spacemanspiff2007)
for providing and supporting a feature request to show `[Optional]`
marker
[114](https://github.com/mansenfranzen/autodoc_pydantic/issues/114)
and a feature request to swap name and alias
[99](https://github.com/mansenfranzen/autodoc_pydantic/issues/99) .