-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Description
Hello,
Taking the two following schemas, /schemas/customer and /schemas/address as example:
{
"$id": "https://example.com/schemas/customer",
"type": "object",
"properties": {
"first_name": { "$ref": "#/$defs/name" },
"last_name": { "$ref": "#/$defs/name" },
"shipping_address": { "$ref": "/schemas/address" },
"billing_address": { "$ref": "/schemas/address" }
},
"required": ["first_name", "last_name", "shipping_address"],
"$defs": {
"name": { "type": "string" }
}
}{
"$id": "https://example.com/schemas/address",
"type": "object",
"properties": {
"street_address":
{
"$anchor": "street_address",
"type": "string"
},
"city": { "type": "string" },
"state": { "type": "string" }
},
"required": ["street_address", "city", "state"]
}When creating the defaults from the /schemas/customer schema, which has some $refs to /schemas/address, results in the following error:
root@789f1de62c83:/workspace-local# python default_json.py
Traceback (most recent call last):
File "/workspace-local/default_json.py", line 58, in <module>
sys.exit(main())
File "/workspace-local/default_json.py", line 49, in main
default_dev = jsonschema_default.create_from(schema_path)
File "/usr/local/lib/python3.10/site-packages/jsonschema_default/__init__.py", line 7, in create_from
return main.JsonSchemaDefault(schema, parent=None).generate()
File "/usr/local/lib/python3.10/site-packages/jsonschema_default/main.py", line 148, in generate
result = self._object()
File "/usr/local/lib/python3.10/site-packages/jsonschema_default/main.py", line 80, in _object
default[name] = JsonSchemaDefault(schema, parent=self).generate()
File "/usr/local/lib/python3.10/site-packages/jsonschema_default/main.py", line 121, in generate
return self.ref(ref)
File "/usr/local/lib/python3.10/site-packages/jsonschema_default/main.py", line 94, in ref
file, path = ref.split("#")
ValueError: not enough values to unpack (expected 2, got 1)
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
No labels