-
-
Notifications
You must be signed in to change notification settings - Fork 2.4k
Closed
Description
Thanks @pilosus for fixing the dataclass-based schema. This is a follow up for #408.
It raises a ValueError excpetion on dataclass-based schema that uses another dataclass-based model. For example,
from pydantic import UrlStr
from pydantic.dataclasses import dataclass
@dataclass
class NavbarButton:
href: UrlStr
@dataclass
class Navbar:
button: NavbarButton
print(Navbar.__pydantic_model__.schema())It raises the following exception,
Traceback (most recent call last):
File "demo_dataclass.py", line 14, in <module>
print(Navbar.__pydantic_model__.schema())
File "E:\Python36\lib\site-packages\pydantic\main.py", line 406, in schema
s = model_schema(cls, by_alias=by_alias)
File "E:\Python36\lib\site-packages\pydantic\schema.py", line 206, in model_schema
model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix
File "E:\Python36\lib\site-packages\pydantic\schema.py", line 490, in model_process_schema
model, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix
File "E:\Python36\lib\site-packages\pydantic\schema.py", line 516, in model_type_schema
f, by_alias=by_alias, model_name_map=model_name_map, ref_prefix=ref_prefix
File "E:\Python36\lib\site-packages\pydantic\schema.py", line 258, in field_schema
ref_prefix=ref_prefix,
File "E:\Python36\lib\site-packages\pydantic\schema.py", line 465, in field_type_schema
ref_prefix=ref_prefix,
File "E:\Python36\lib\site-packages\pydantic\schema.py", line 685, in field_singleton_schema
raise ValueError(f'Value not declarable with JSON Schema, field: {field}')
ValueError: Value not declarable with JSON Schema, field: button type=NavbarButton requiredMetadata
Metadata
Assignees
Labels
No labels