Files
pydantic/docs/examples/schema4.py
T
2019-08-05 09:47:15 -05:00

27 lines
584 B
Python

from pydantic import BaseModel
class Person(BaseModel):
name: str
age: int
class Config:
schema_extra = {
'examples': [
{
'name': 'John Doe',
'age': 25,
}
]
}
print(Person.schema())
# {'title': 'Person',
# 'type': 'object',
# 'properties': {'name': {'title': 'Name', 'type': 'string'},
# 'age': {'title': 'Age', 'type': 'integer'}},
# 'required': ['name', 'age'],
# 'examples': [{'name': 'John Doe', 'age': 25}]}
print(Person.schema_json(indent=2))