diff --git a/src/python-fastui/fastui/components/__init__.py b/src/python-fastui/fastui/components/__init__.py index dfe370fc..692e57ac 100644 --- a/src/python-fastui/fastui/components/__init__.py +++ b/src/python-fastui/fastui/components/__init__.py @@ -231,30 +231,33 @@ class Custom(_p.BaseModel, extra='forbid'): type: _t.Literal['Custom'] = 'Custom' -AnyComponent = _t.Union[ - Text, - Paragraph, - PageTitle, - Div, - Page, - Heading, - Markdown, - Code, - Json, - Button, - Link, - LinkList, - Navbar, - Modal, - ServerLoad, - Image, - Iframe, - Custom, - Table, - Pagination, - Display, - Details, - Form, - FormField, - ModelForm, +AnyComponent = _te.Annotated[ + _t.Union[ + Text, + Paragraph, + PageTitle, + Div, + Page, + Heading, + Markdown, + Code, + Json, + Button, + Link, + LinkList, + Navbar, + Modal, + ServerLoad, + Image, + Iframe, + Custom, + Table, + Pagination, + Display, + Details, + Form, + FormField, + ModelForm, + ], + _p.Field(discriminator='type'), ] diff --git a/src/python-fastui/tests/test_json_schema_match.py b/src/python-fastui/tests/test_json_schema_match.py index 9a70bc2c..ecdfd04b 100644 --- a/src/python-fastui/tests/test_json_schema_match.py +++ b/src/python-fastui/tests/test_json_schema_match.py @@ -13,7 +13,7 @@ ta = TypeAdapter(AnyComponent) json_schema = ta.json_schema(by_alias=True, mode='serialization', ref_template='#/definitions/{model}') -components_union = json_schema['anyOf'] +components_union = json_schema['oneOf'] components_union_set = set(d['$ref'] for d in components_union)