feat: enhance extract_field_schema to support inline options for type inference

This commit is contained in:
donny committed 2026-01-14 23:02:41 -07:00
1 parent 82559292b1
commit 632ba7b32a
1 file changed
+5 -4
+5 -4
View File
@@ -203,9 +203,10 @@ def extract_field_schema(
# Extract component (NEW: explicit UI component key) # Extract component (NEW: explicit UI component key)
component = extra.pop("component", None) component = extra.pop("component", None)
# Extract options_source early - needed for type inference # Extract options_source and inline options early - needed for type inference
options_source = extra.get("options_source") options_source = extra.get("options_source")
inline_options = extra.get("options") # inline options array
# Handle List types # Handle List types
origin = get_origin(field_type) origin = get_origin(field_type)
inner_type = field_type inner_type = field_type
@@ -230,8 +231,8 @@ def extract_field_schema(
if not component: if not component:
component = inferred_source or field_name component = inferred_source or field_name
schema["params"] = get_model_params_schema(field_type) schema["params"] = get_model_params_schema(field_type)
elif options_source: elif options_source or inline_options:
# Selection from a list of options # Selection from a list of options (either dynamic from options_source or inline)
schema["type"] = "enum" schema["type"] = "enum"
else: else:
# Primitive type - infer from Python type # Primitive type - infer from Python type