Fix #22: update undefined-schema set after child-schema-insertation
It can well be that a child schema is including a grand-child-schema which is considered undefined by a parent schema. Before this fix, this failed because when the parent schema tried to insert the child-child-schema as child-schema it was already present. Now this is fixed by updating the undefined references after each schema insertion.
This commit is contained in:
parent
7e8737e85d
commit
5f199477d4
@ -60,7 +60,7 @@ class resolver
|
|||||||
throw std::invalid_argument("schema " + id.to_string() + " already present in local resolver");
|
throw std::invalid_argument("schema " + id.to_string() + " already present in local resolver");
|
||||||
|
|
||||||
// store a raw pointer to this (sub-)schema referenced by its absolute json_uri
|
// store a raw pointer to this (sub-)schema referenced by its absolute json_uri
|
||||||
// this (sub-)schema is part of a schema stored inside schema_store_ so we can the a raw-pointer-ref
|
// this (sub-)schema is part of a schema stored inside schema_store_ so we can use the a raw-pointer-ref
|
||||||
schema_refs[id] = &schema;
|
schema_refs[id] = &schema;
|
||||||
|
|
||||||
for (auto i = schema.begin(), end = schema.end(); i != end; ++i) {
|
for (auto i = schema.begin(), end = schema.end(); i != end; ++i) {
|
||||||
@ -295,8 +295,12 @@ void json_validator::insert_schema(const json &input, const json_uri &id)
|
|||||||
for (auto undef : undefined) {
|
for (auto undef : undefined) {
|
||||||
json ext;
|
json ext;
|
||||||
|
|
||||||
|
// check whether a recursive-call has already insert this schema in the meantime
|
||||||
|
if (schema_refs_.find(undef) != schema_refs_.end())
|
||||||
|
continue;
|
||||||
|
|
||||||
schema_loader_(undef, ext);
|
schema_loader_(undef, ext);
|
||||||
insert_schema(ext, undef.url());
|
insert_schema(ext, undef.url()); // recursively call insert_schema to fill in new external references
|
||||||
}
|
}
|
||||||
} while (1);
|
} while (1);
|
||||||
|
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user