Skip to content

Schema validation with subschema and internal reference #596

Closed Answered by danielaparker
nicomuns asked this question in Q&A
Discussion options

You must be logged in to vote

Okay, from jsoncons's point of view, $ref in payload is accessing an external resource (one outside a schema resource.) Therefore, I think you should substitute

"$ref": "/key_A/key_A_2/bar"  

for

"$ref": "#/key_A/key_A_2/bar"  

Note that we write the reference with a leading slash to prevent URI resolution from merging '/key_A/key_A_2/bar' with the default base URI path '/this/is/my/folder/file' (which we don't want.)

Then all references should be resolved in the usual way:

#include <jsoncons/json.hpp>
#include <jsoncons_ext/jsonschema/jsonschema.hpp>
#include <jsoncons_ext/jsonpointer/jsonpointer.hpp>
#include <iostream>

namespace jsonschema = jsoncons::jsonschema;
namespace jsonpointer 

Replies: 1 comment 1 reply

Comment options

You must be logged in to vote
1 reply
@nicomuns
Comment options

Answer selected by nicomuns
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants