Fix meta schema validation

This commit is contained in:
Milo Yip 2015-05-16 15:51:36 +08:00
parent 11f666a793
commit 5b6061c7e6
2 changed files with 7 additions and 8 deletions

View File

@ -60,11 +60,11 @@ RAPIDJSON_MULTILINEMACRO_END
#endif
#define RAPIDJSON_INVALID_KEYWORD_RETURN(keyword)\
RAPIDJSON_MULTILINEMACRO_BEGIN\
RAPIDJSON_MULTILINEMACRO_BEGIN\
context.invalidKeyword = keyword;\
RAPIDJSON_INVALID_KEYWORD_VERBOSE(keyword);\
return false;\
RAPIDJSON_MULTILINEMACRO_END
RAPIDJSON_MULTILINEMACRO_END
RAPIDJSON_NAMESPACE_BEGIN
@ -460,10 +460,10 @@ public:
// Array
if (const ValueType* v = GetMember(value, "items")) {
PointerType q = p.Append("items");
if (v->IsObject()) // List validation
document->CreateSchema(&itemsList_, p, *v);
document->CreateSchema(&itemsList_, q, *v);
else if (v->IsArray()) { // Tuple validation
PointerType q = p.Append("items");
itemsTuple_ = static_cast<const Schema**>(allocator_->Malloc(sizeof(const Schema*) * v->Size()));
SizeType index = 0;
for (ConstValueIterator itr = v->Begin(); itr != v->End(); ++itr, index++)
@ -1126,7 +1126,6 @@ private:
SValue minimum_;
SValue maximum_;
SValue multipleOf_;
bool hasMultipleOf_;
bool exclusiveMinimum_;
bool exclusiveMaximum_;
};

View File

@ -659,7 +659,7 @@ TEST(SchemaValidator, Array_ItemsList) {
SchemaDocument s(sd);
VALIDATE(s, "[1, 2, 3, 4, 5]", true);
INVALIDATE(s, "[1, 2, \"3\", 4, 5]", "", "type", "/2");
INVALIDATE(s, "[1, 2, \"3\", 4, 5]", "/items", "type", "/2");
VALIDATE(s, "[]", true);
}
@ -776,8 +776,8 @@ TEST(SchemaValidator, ObjectInArray) {
SchemaDocument s(sd);
VALIDATE(s, "[\"a\"]", true);
INVALIDATE(s, "[1]", "", "type", "/0");
INVALIDATE(s, "[{}]", "", "type", "/0");
INVALIDATE(s, "[1]", "/items", "type", "/0");
INVALIDATE(s, "[{}]", "/items", "type", "/0");
}
TEST(SchemaValidator, MultiTypeInObject) {