JSON schema cross file references using $anchor and $ref
Posted: Wed Nov 30, 2022 7:30 pm
I need to reference common definitions in a number for schema, but can get it working in oxygenxml v.25.0
I've created a common.jschema file with the common $defs definition with an $achor and $id. However when I try to reference this from another schema in a $ref it can't resolve the reference. The $ref in the file my_schema,jshema gives an error "#/properties/name/$ref: ro.sync.net.protocol.http.HttpExceptionWithDetails: 404 Not Found for: https://example.com/schemas/common"
Is this supported in oxygenxl v.25.0? How do is this done?
Here are the two examples; All files are in the same directory -
common.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/common",
"$defs": {
"non-empty-string": {
"$anchor": "non-empty-string",
"type": "string",
"minLength": 1
}
}
}
my_string.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/my_string",
"type": "object",
"properties": {
"name": {"$ref": "/schemas/common#non-empty_string"}
}
}
I've created a common.jschema file with the common $defs definition with an $achor and $id. However when I try to reference this from another schema in a $ref it can't resolve the reference. The $ref in the file my_schema,jshema gives an error "#/properties/name/$ref: ro.sync.net.protocol.http.HttpExceptionWithDetails: 404 Not Found for: https://example.com/schemas/common"
Is this supported in oxygenxl v.25.0? How do is this done?
Here are the two examples; All files are in the same directory -
common.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/common",
"$defs": {
"non-empty-string": {
"$anchor": "non-empty-string",
"type": "string",
"minLength": 1
}
}
}
my_string.jschema:
{
"$schema": "http://json-schema.org/draft/2020-12/schema#",
"$id": "https://example.com/schemas/my_string",
"type": "object",
"properties": {
"name": {"$ref": "/schemas/common#non-empty_string"}
}
}