mirror of
https://github.com/kennethreitz/pydantic.git
synced 2026-06-05 23:00:18 +00:00
21 lines
408 B
Python
21 lines
408 B
Python
import json
|
|
from pydantic import BaseModel
|
|
from pydantic.schema import schema
|
|
|
|
class Foo(BaseModel):
|
|
a: int
|
|
|
|
class Model(BaseModel):
|
|
a: Foo
|
|
|
|
|
|
top_level_schema = schema([Model], ref_prefix='#/components/schemas/') # Default location for OpenAPI
|
|
print(json.dumps(top_level_schema, indent=2))
|
|
|
|
#> {
|
|
#> "definitions": {
|
|
#> "Foo": {
|
|
#> "title": "Foo",
|
|
#> "type": "object",
|
|
#> ...
|