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
The metadata["description"] field is used when using the apispec project to generate OpenAPI specifications. Marshmallow_dataclass sets this field to the type name when using NewType and that clashes, as I don't need nor want to give every field a description in the spec.
Can we please decide for ourselves if description should be set?
The text was updated successfully, but these errors were encountered:
I currently use this workaround, a class decorator I place above @marshmallow_dataclasses.dataclass:
fromtypingimportTypeVarT=TypeVar("T")
# slight annoyance: marshmallow-dataclasses sets a default `metadata["description"]`# value. This class decorator removes descriptions set to None, and I set# description: None on NewType fields to prevent the default values being set.def_no_default_description(cls: T, _sentinel=object()) ->T:
forfieldincls.Schema._declared_fields.values():
iffield.metadata.get("description", _sentinel) isNone:
delfield.metadata["description"]
returncls
The
metadata["description"]
field is used when using theapispec
project to generate OpenAPI specifications. Marshmallow_dataclass sets this field to the type name when usingNewType
and that clashes, as I don't need nor want to give every field a description in the spec.Can we please decide for ourselves if
description
should be set?The text was updated successfully, but these errors were encountered: