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 }}
This repository has been archived by the owner on Aug 19, 2023. It is now read-only.
Currently, you can use field metadata for custom descriptions, examples. But to do more custom validation (like constraints for integers), you have to use NewType and registering this type. While NewType is good for things like Email, and Enum-like things, it's cumbersome for numeric things, since you have to create newtype for each restriction (i.e. for restricting by 1 and 0 you need separate types). Instead, metadata from field could be used, as like this:
>>@dataclass
class Box(JsonSchemaMixin):
"""A box."""
width: int = field(metadata={"description": "Some desctiption", "schema": {"minimum": 1}})
The text was updated successfully, but these errors were encountered:
Currently, you can use field metadata for custom descriptions, examples. But to do more custom validation (like constraints for integers), you have to use NewType and registering this type. While NewType is good for things like Email, and Enum-like things, it's cumbersome for numeric things, since you have to create newtype for each restriction (i.e. for restricting by 1 and 0 you need separate types). Instead, metadata from field could be used, as like this:
The text was updated successfully, but these errors were encountered: