yera.runtime.form_widgets
Map JSON Schema nodes onto form input widgets.
Symbols
field_label
field_label(
node: Mapping[str, JsonValue],
path: str,
) → strReturn the label shown for a form field.
Parameters
The field's schema node.
Dotted path of the field within the form.
Returns
The node's explicit title, or the last path segment with underscores replaced by spaces.
form_schema
form_schema(
model_type: type[BaseModel],
) → dict[str, JsonValue]Describe a model's fields for form rendering.
Parameters
Pydantic model or struct class declaring the form fields.
Returns
The model's JSON Schema with references inlined, keeping only the titles declared explicitly on its fields.
Raises
If the model's fields refer back to the model itself.
inline_refs
inline_refs(
schema: Mapping[str, JsonValue],
) → dict[str, JsonValue]Replace local $ref pointers with the definitions they name.
Parameters
A JSON Schema whose references point into its $defs.
Returns
A copy of the schema without $defs in which every reference is replaced by its definition. Keys beside a reference take precedence, and a definition's type title is not copied onto the field.
Raises
If a definition refers back to itself.
redact_secrets
redact_secrets(
values: Mapping[str, JsonValue],
schema: Mapping[str, JsonValue],
) → dict[str, JsonValue]Mask every secret value in a submitted form.
Parameters
Submitted JSON values keyed by field name.
Inlined form schema describing those values.
Returns
A copy of the values in which every write-only field holds the mask.
repeat_item_label
repeat_item_label(
node: Mapping[str, JsonValue],
) → strReturn the noun for one row of a repeated field.
Parameters
A list field's schema node.
Returns
The field's ui.item_label, or "row" when it sets none.
struct_variants
struct_variants(
node: Mapping[str, JsonValue],
) → list[Mapping[str, JsonValue]]Return the struct members of a union field.
Parameters
An inlined schema node declaring oneOf or anyOf members.
Returns
The members that describe structs, in declaration order.
unwrap_optional
unwrap_optional(
node: Mapping[str, JsonValue],
) → Mapping[str, JsonValue] | NoneReturn the value schema of an optional field.
Parameters
A resolved JSON Schema property node.
Returns
The non-null member of a T | None union, or None when the node is not an optional single type.
variant_constant
variant_constant(
member: Mapping[str, JsonValue],
key: str,
) → JsonValueReturn the constant a struct union member fixes for a field.
Parameters
One struct member of a union field.
The discriminating field name.
Returns
The member's constant for that field, or None when it has none.
variant_discriminator
variant_discriminator(
members: list[Mapping[str, JsonValue]],
) → str | NoneReturn the constant field shared by every member of a struct union.
Parameters
Struct members of a union field.
Returns
The alphabetically first field that every member fixes to a constant, or None when the members share none.
widget_for
widget_for(
node: Mapping[str, JsonValue],
) → WidgetChoose the input widget presenting one schema property.
Parameters
A resolved JSON Schema property node.
Returns
The widget kind used to present the property.