Skip to content

Commit

Permalink
fix: Use "$defs" for "definitions"
Browse files Browse the repository at this point in the history
  • Loading branch information
ketozhang committed Aug 26, 2024
1 parent f7dfd39 commit ed9f9db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions asdf_pydantic/schema.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"allOf",
"anyOf",
"required",
"$defs",
"definitions",
)


Expand Down Expand Up @@ -45,6 +45,10 @@ def generate(self, schema, mode="validation"):
json_schema["$schema"] = self.schema_dialect
json_schema["id"] = f"{self.tag_uri}/schema"

# TODO: Convert jsonschema 2020-12 to ASDF schema
if "$defs" in json_schema:
json_schema["definitions"] = json_schema.pop("$defs")

# Order keys
json_schema = {
**{
Expand All @@ -55,5 +59,4 @@ def generate(self, schema, mode="validation"):
**json_schema, # Rest of the keys not in order list
}

# TODO: Convert jsonschema 2020-12 to ASDF schema
return json_schema
2 changes: 1 addition & 1 deletion tests/examples/test_node.py
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ def test_errors_reading_invalid_asdf_file(tmp_path):
software: !core/software-1.0.0 {name: asdf, version: 3.4.0}
- !core/extension_metadata-1.0.0 {extension_class: tests.examples.test_node.setup_module.<locals>.TestExtension,
extension_uri: 'asdf://asdf-pydantic/examples/extensions/test-1.0.0'}
root: !<asdf://asdf-pydantic/examples/tags/node-1.0.0>
root: !<asdf://asdf-pydantic/examples/tags/node-2.0.0>
name: foo
child: 1
...
Expand Down

0 comments on commit ed9f9db

Please sign in to comment.