fix bugs, new type
This commit is contained in:
@@ -262,6 +262,7 @@ def _iter_state_field_declarations(
|
||||
for key, value in resolved_schema.items()
|
||||
if key not in {"reducer", "trace"}
|
||||
}
|
||||
_attach_root_schema_context(validation_schema, root_schema)
|
||||
yield (
|
||||
path,
|
||||
StateFieldDecl.model_validate(
|
||||
@@ -392,6 +393,24 @@ def _resolve_local_ref(
|
||||
return resolved if isinstance(resolved, Mapping) else property_schema
|
||||
|
||||
|
||||
def _attach_root_schema_context(
|
||||
field_schema: dict[str, Any],
|
||||
root_schema: Mapping[str, Any],
|
||||
) -> None:
|
||||
"""Keep local JSON Schema refs valid after extracting one state field.
|
||||
|
||||
Runtime state writes validate one declared state path at a time. If a field
|
||||
schema contains a Pydantic-style local ref such as ``#/$defs/Thing``, the
|
||||
extracted subschema still needs the root ``$defs`` table to resolve it.
|
||||
"""
|
||||
definitions = root_schema.get("$defs")
|
||||
if isinstance(definitions, Mapping):
|
||||
field_schema.setdefault("$defs", dict(definitions))
|
||||
schema_dialect = root_schema.get("$schema")
|
||||
if isinstance(schema_dialect, str):
|
||||
field_schema.setdefault("$schema", schema_dialect)
|
||||
|
||||
|
||||
class NodeDef(BaseModel):
|
||||
"""Reusable node contract referenced by one or more node uses."""
|
||||
|
||||
|
||||
Reference in New Issue
Block a user