@@ -2004,6 +2004,35 @@ TEST(SchemaValidator, Ref_remote) {
2004
2004
SchemaValidatorType, PointerType);
2005
2005
}
2006
2006
2007
+ TEST (SchemaValidator, Ref_remote_issue1210) {
2008
+ class SchemaDocumentProvider : public IRemoteSchemaDocumentProvider {
2009
+ SchemaDocument** collection;
2010
+ public:
2011
+ SchemaDocumentProvider (SchemaDocument** collection) : collection(collection) { }
2012
+ virtual const SchemaDocument* GetRemoteDocument (const char * uri, SizeType length) {
2013
+ int i = 0 ;
2014
+ while (collection[i] && typename SchemaDocument::URIType (uri, length) != collection[i]->GetURI ()) ++i;
2015
+ return collection[i];
2016
+ }
2017
+ };
2018
+ SchemaDocument* collection[] { 0 , 0 , 0 };
2019
+ SchemaDocumentProvider provider (collection);
2020
+
2021
+ Document x, y, z;
2022
+ x.Parse (" {\" properties\" :{\" country\" :{\" $ref\" :\" y.json#/definitions/country_remote\" }},\" type\" :\" object\" }" );
2023
+ y.Parse (" {\" definitions\" :{\" country_remote\" :{\" $ref\" :\" z.json#/definitions/country_list\" }}}" );
2024
+ z.Parse (" {\" definitions\" :{\" country_list\" :{\" enum\" :[\" US\" ]}}}" );
2025
+
2026
+ SchemaDocument sz (z, " z.json" , 6 , &provider);
2027
+ collection[0 ] = &sz;
2028
+ SchemaDocument sy (y, " y.json" , 6 , &provider);
2029
+ collection[1 ] = &sy;
2030
+ SchemaDocument sx (x, " x.json" , 6 , &provider);
2031
+
2032
+ VALIDATE (sx, " {\" country\" :\" UK\" }" , false );
2033
+ VALIDATE (sx, " {\" country\" :\" US\" }" , true );
2034
+ }
2035
+
2007
2036
#ifdef __clang__
2008
2037
RAPIDJSON_DIAG_POP
2009
2038
#endif
0 commit comments