Merge pull request #1210 from foxtacles/fix-missing-remote-ref-p
add remote ref pointer to schemaMap_
This commit is contained in:
commit
8022a5f79c
@ -1673,6 +1673,7 @@ private:
|
||||
if (const SchemaType* sc = remoteDocument->GetSchema(pointer)) {
|
||||
if (schema)
|
||||
*schema = sc;
|
||||
new (schemaMap_.template Push<SchemaEntry>()) SchemaEntry(source, const_cast<SchemaType*>(sc), false, allocator_);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -2004,6 +2004,35 @@ TEST(SchemaValidator, Ref_remote) {
|
||||
SchemaValidatorType, PointerType);
|
||||
}
|
||||
|
||||
TEST(SchemaValidator, Ref_remote_issue1210) {
|
||||
class SchemaDocumentProvider : public IRemoteSchemaDocumentProvider {
|
||||
SchemaDocument** collection;
|
||||
public:
|
||||
SchemaDocumentProvider(SchemaDocument** collection) : collection(collection) { }
|
||||
virtual const SchemaDocument* GetRemoteDocument(const char* uri, SizeType length) {
|
||||
int i = 0;
|
||||
while (collection[i] && SchemaDocument::URIType(uri, length) != collection[i]->GetURI()) ++i;
|
||||
return collection[i];
|
||||
}
|
||||
};
|
||||
SchemaDocument* collection[] = { 0, 0, 0 };
|
||||
SchemaDocumentProvider provider(collection);
|
||||
|
||||
Document x, y, z;
|
||||
x.Parse("{\"properties\":{\"country\":{\"$ref\":\"y.json#/definitions/country_remote\"}},\"type\":\"object\"}");
|
||||
y.Parse("{\"definitions\":{\"country_remote\":{\"$ref\":\"z.json#/definitions/country_list\"}}}");
|
||||
z.Parse("{\"definitions\":{\"country_list\":{\"enum\":[\"US\"]}}}");
|
||||
|
||||
SchemaDocument sz(z, "z.json", 6, &provider);
|
||||
collection[0] = &sz;
|
||||
SchemaDocument sy(y, "y.json", 6, &provider);
|
||||
collection[1] = &sy;
|
||||
SchemaDocument sx(x, "x.json", 6, &provider);
|
||||
|
||||
VALIDATE(sx, "{\"country\":\"UK\"}", false);
|
||||
VALIDATE(sx, "{\"country\":\"US\"}", true);
|
||||
}
|
||||
|
||||
#ifdef __clang__
|
||||
RAPIDJSON_DIAG_POP
|
||||
#endif
|
||||
|
Loading…
x
Reference in New Issue
Block a user