mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
cleanup
This commit is contained in:
@@ -1,43 +0,0 @@
|
||||
# output-json
|
||||
from __future__ import annotations
|
||||
from pydantic import BaseModel, Field
|
||||
from typing import Optional
|
||||
|
||||
|
||||
class Person(BaseModel):
|
||||
name: str
|
||||
age: int = Field(lt=100, gt=0)
|
||||
test: Optional[int] = 0
|
||||
|
||||
# class Config:
|
||||
# schema_extra = {
|
||||
# 'examples': [
|
||||
# {
|
||||
# 'name': 'John Doe',
|
||||
# 'age': 25,
|
||||
# }
|
||||
# ]
|
||||
# }
|
||||
|
||||
data = {
|
||||
'name': 'Kenneth Reitz',
|
||||
'age': 34,
|
||||
}
|
||||
|
||||
# 'inner_schema': {'fields': {'age': {'required': True,
|
||||
# 'schema': {'type': 'int'}},
|
||||
# 'metadata': {'required': True,
|
||||
# 'schema': {'type': 'dict'}},
|
||||
# 'name': {'required': True,
|
||||
# 'schema': {'type': 'str'}}},
|
||||
# Person.model_rebuild()
|
||||
p = Person(**data)
|
||||
|
||||
|
||||
# print(p)
|
||||
from pprint import pprint
|
||||
|
||||
pprint(p.json_schema())
|
||||
|
||||
|
||||
# print(Person.schema_json(indent=2))
|
||||
Reference in New Issue
Block a user