NEO-65: Replace deprecated RefResolver with referencing.Registry.
Use jsonschema 4.22+ registry API for cross-file recipe schema $ref resolution (Bugbot PR #99).pull/99/head
parent
d4a4795eb1
commit
27ec7c02a7
|
|
@ -18,8 +18,8 @@ import json
|
||||||
import sys
|
import sys
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
|
||||||
import jsonschema
|
|
||||||
from jsonschema import Draft202012Validator
|
from jsonschema import Draft202012Validator
|
||||||
|
from referencing import Registry, Resource
|
||||||
|
|
||||||
REPO_ROOT = Path(__file__).resolve().parent.parent
|
REPO_ROOT = Path(__file__).resolve().parent.parent
|
||||||
SKILL_SCHEMA = REPO_ROOT / "content/schemas/skill-def.schema.json"
|
SKILL_SCHEMA = REPO_ROOT / "content/schemas/skill-def.schema.json"
|
||||||
|
|
@ -576,9 +576,13 @@ def _recipe_def_validator() -> Draft202012Validator:
|
||||||
"""Build a validator that resolves recipe-def $ref to recipe-io-row schema."""
|
"""Build a validator that resolves recipe-def $ref to recipe-io-row schema."""
|
||||||
io_schema = json.loads(RECIPE_IO_ROW_SCHEMA.read_text(encoding="utf-8"))
|
io_schema = json.loads(RECIPE_IO_ROW_SCHEMA.read_text(encoding="utf-8"))
|
||||||
def_schema = json.loads(RECIPE_SCHEMA.read_text(encoding="utf-8"))
|
def_schema = json.loads(RECIPE_SCHEMA.read_text(encoding="utf-8"))
|
||||||
schema_store = {io_schema["$id"]: io_schema, def_schema["$id"]: def_schema}
|
registry = Registry().with_resources(
|
||||||
resolver = jsonschema.RefResolver.from_schema(def_schema, store=schema_store)
|
[
|
||||||
return Draft202012Validator(def_schema, resolver=resolver)
|
(def_schema["$id"], Resource.from_contents(def_schema)),
|
||||||
|
(io_schema["$id"], Resource.from_contents(io_schema)),
|
||||||
|
]
|
||||||
|
)
|
||||||
|
return Draft202012Validator(def_schema, registry=registry)
|
||||||
|
|
||||||
|
|
||||||
def _prototype_slice3_recipe_gate(
|
def _prototype_slice3_recipe_gate(
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue