import datetime
from degenson import SchemaBuilder
builder = SchemaBuilder()
builder.add_object(datetime.date(2018, 11, 13))
schema = builder.to_schema()
print(schema)
# ───────────────────────── Printed output ─────────────────────────
{'$schema': 'http://json-schema.org/schema#', 'type': 'string', 'format': 'date'}
Overview
DeGenSON is a fork of GenSON that adds additional schema strategies for Python types that map directly to JSON Schema formats.
Supported Additional Strategies
| Python Type | JSON Schema Type | JSON Schema Format |
|---|---|---|
datetime.datetime |
string |
date-time |
datetime.date |
string |
date |
datetime.time |
string |
time |
datetime.timedelta |
string |
duration |
ipaddress.IPv4Address |
string |
ipv4 |
ipaddress.IPv6Address |
string |
ipv6 |
uuid.UUID |
string |
uuid |
re.Pattern |
string |
regex |