feat(webui): enhance ConfigSchemaGenerator with field_docs and UI metadata
- Add AttrDocBase.get_class_field_docs() classmethod for class-level field docs extraction - Merge json_schema_extra (x-widget, x-icon, step) into schema output - Map Pydantic constraints (ge/le) to minValue/maxValue for frontend compatibility - Add ge=0, le=1 constraints to ChatConfig.talk_value for validation Completes Task 1 (including subtasks 1a, 1b, 1c, 1d) of webui-config-visualization-refactor plan.
This commit is contained in:
@@ -77,6 +77,18 @@ class ConfigSchemaGenerator:
|
||||
if options:
|
||||
schema["options"] = options
|
||||
|
||||
# Task 1c: Merge json_schema_extra (x-widget, x-icon, step, etc.)
|
||||
if hasattr(field_info, "json_schema_extra") and field_info.json_schema_extra:
|
||||
schema.update(field_info.json_schema_extra)
|
||||
|
||||
# Task 1d: Map Pydantic constraints to minValue/maxValue (frontend naming convention)
|
||||
if hasattr(field_info, "metadata") and field_info.metadata:
|
||||
for constraint in field_info.metadata:
|
||||
if hasattr(constraint, "ge"):
|
||||
schema["minValue"] = constraint.ge
|
||||
if hasattr(constraint, "le"):
|
||||
schema["maxValue"] = constraint.le
|
||||
|
||||
return schema
|
||||
|
||||
@staticmethod
|
||||
|
||||
Reference in New Issue
Block a user