maxfordham / ipyautoui

create ipywidgets user input form pydantic model or jsonschema
https://maxfordham.github.io/ipyautoui/
40 stars 4 forks source link

FEATURE add `examples` in schema maps to `Combobox` #161

Closed jgunstone closed 1 year ago

jgunstone commented 1 year ago

in https://github.com/rjsf-team/react-jsonschema-form - they use the examples keyword in schemas to tell the UI to use a Combobox. implement the same here

i.e.

from enum import Enum
from pydantic import Field, BaseModel

class FruitEnum(str, Enum):
    """fruit example."""

    apple = "apple"
    pear = "pear"
    banana = "banana"
    orange = "orange"

class CoreIpywidgets(BaseModel):
    combobox: str = Field(..., examples=FruitEnum._member_names_)

will automatically generate a combobox