maxfordham / ipyautoui

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

update handling of nullable fields for pydantic v2 #186

Closed jgunstone closed 1 year ago

jgunstone commented 1 year ago

refs:

https://github.com/pydantic/pydantic/discussions/7208 https://docs.pydantic.dev/latest/migration/#required-optional-and-nullable-fields

currently it is inferred if a field is nullable by whether it is required and if the default=None.

https://github.com/maxfordham/ipyautoui/blob/782955ed379cd2b4f53b0ec0de74557813c2e80e/src/ipyautoui/automapschema.py#L128-L147

pydantic v2 is more explicit about whether null fields are allowed

jgunstone commented 1 year ago

https://github.com/pydantic/pydantic/discussions/7208

options:

add a show / hide button that hides not required fields

logic:

defining types:

https://json-schema.org/understanding-json-schema/reference/combining.html#factoring-schemas

jgunstone commented 1 year ago

merged to main in this PR https://github.com/maxfordham/ipyautoui/pull/199