mirror of
https://github.com/Tencent/rapidjson.git
synced 2025-03-10 03:29:59 +01:00
Fix "additional items do not match schema"
This commit is contained in:
parent
f19a1b6abc
commit
9c0e409ff2
@ -123,7 +123,7 @@ public:
|
|||||||
not_(),
|
not_(),
|
||||||
type_((1 << kTotalSchemaType) - 1), // typeless
|
type_((1 << kTotalSchemaType) - 1), // typeless
|
||||||
properties_(),
|
properties_(),
|
||||||
additionalPropertySchema_(),
|
additionalPropertiesSchema_(),
|
||||||
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
||||||
patternProperties_(),
|
patternProperties_(),
|
||||||
patternPropertyCount_(),
|
patternPropertyCount_(),
|
||||||
@ -132,8 +132,9 @@ public:
|
|||||||
requiredCount_(),
|
requiredCount_(),
|
||||||
minProperties_(),
|
minProperties_(),
|
||||||
maxProperties_(SizeType(~0)),
|
maxProperties_(SizeType(~0)),
|
||||||
additionalProperty_(true),
|
additionalProperties_(true),
|
||||||
hasDependencies_(),
|
hasDependencies_(),
|
||||||
|
additionalItemsSchema_(),
|
||||||
itemsList_(),
|
itemsList_(),
|
||||||
itemsTuple_(),
|
itemsTuple_(),
|
||||||
itemsTupleCount_(),
|
itemsTupleCount_(),
|
||||||
@ -238,9 +239,9 @@ public:
|
|||||||
|
|
||||||
if (const ValueType* v = GetMember(value, "additionalProperties")) {
|
if (const ValueType* v = GetMember(value, "additionalProperties")) {
|
||||||
if (v->IsBool())
|
if (v->IsBool())
|
||||||
additionalProperty_ = v->GetBool();
|
additionalProperties_ = v->GetBool();
|
||||||
else if (v->IsObject())
|
else if (v->IsObject())
|
||||||
additionalPropertySchema_ = new BaseSchema<Encoding>(*v);
|
additionalPropertiesSchema_ = new BaseSchema<Encoding>(*v);
|
||||||
}
|
}
|
||||||
|
|
||||||
AssignIfExist(minProperties_, value, "minProperties");
|
AssignIfExist(minProperties_, value, "minProperties");
|
||||||
@ -259,7 +260,13 @@ public:
|
|||||||
|
|
||||||
AssignIfExist(minItems_, value, "minItems");
|
AssignIfExist(minItems_, value, "minItems");
|
||||||
AssignIfExist(maxItems_, value, "maxItems");
|
AssignIfExist(maxItems_, value, "maxItems");
|
||||||
AssignIfExist(additionalItems_, value, "additionalItems");
|
|
||||||
|
if (const ValueType* v = GetMember(value, "additionalItems")) {
|
||||||
|
if (v->IsBool())
|
||||||
|
additionalItems_ = v->GetBool();
|
||||||
|
else if (v->IsObject())
|
||||||
|
additionalItemsSchema_ = new BaseSchema<Encoding>(*v);
|
||||||
|
}
|
||||||
|
|
||||||
// String
|
// String
|
||||||
AssignIfExist(minLength_, value, "minLength");
|
AssignIfExist(minLength_, value, "minLength");
|
||||||
@ -296,7 +303,7 @@ public:
|
|||||||
~BaseSchema() {
|
~BaseSchema() {
|
||||||
delete not_;
|
delete not_;
|
||||||
delete [] properties_;
|
delete [] properties_;
|
||||||
delete additionalPropertySchema_;
|
delete additionalPropertiesSchema_;
|
||||||
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
||||||
delete [] patternProperties_;
|
delete [] patternProperties_;
|
||||||
#endif
|
#endif
|
||||||
@ -316,6 +323,8 @@ public:
|
|||||||
else if (itemsTuple_) {
|
else if (itemsTuple_) {
|
||||||
if (context.arrayElementIndex < itemsTupleCount_)
|
if (context.arrayElementIndex < itemsTupleCount_)
|
||||||
context.valueSchema = itemsTuple_[context.arrayElementIndex];
|
context.valueSchema = itemsTuple_[context.arrayElementIndex];
|
||||||
|
else if (additionalItemsSchema_)
|
||||||
|
context.valueSchema = additionalItemsSchema_;
|
||||||
else if (additionalItems_)
|
else if (additionalItems_)
|
||||||
context.valueSchema = GetTypeless();
|
context.valueSchema = GetTypeless();
|
||||||
else
|
else
|
||||||
@ -470,11 +479,11 @@ public:
|
|||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
if (additionalPropertySchema_) {
|
if (additionalPropertiesSchema_) {
|
||||||
context.valueSchema = additionalPropertySchema_;
|
context.valueSchema = additionalPropertiesSchema_;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
else if (additionalProperty_) {
|
else if (additionalProperties_) {
|
||||||
context.valueSchema = GetTypeless();
|
context.valueSchema = GetTypeless();
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@ -674,7 +683,7 @@ private:
|
|||||||
unsigned type_; // bitmask of kSchemaType
|
unsigned type_; // bitmask of kSchemaType
|
||||||
|
|
||||||
Property* properties_;
|
Property* properties_;
|
||||||
BaseSchema<Encoding>* additionalPropertySchema_;
|
BaseSchema<Encoding>* additionalPropertiesSchema_;
|
||||||
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
#if RAPIDJSON_SCHEMA_HAS_REGEX
|
||||||
PatternProperty* patternProperties_;
|
PatternProperty* patternProperties_;
|
||||||
SizeType patternPropertyCount_;
|
SizeType patternPropertyCount_;
|
||||||
@ -683,9 +692,10 @@ private:
|
|||||||
SizeType requiredCount_;
|
SizeType requiredCount_;
|
||||||
SizeType minProperties_;
|
SizeType minProperties_;
|
||||||
SizeType maxProperties_;
|
SizeType maxProperties_;
|
||||||
bool additionalProperty_;
|
bool additionalProperties_;
|
||||||
bool hasDependencies_;
|
bool hasDependencies_;
|
||||||
|
|
||||||
|
BaseSchema<Encoding>* additionalItemsSchema_;
|
||||||
BaseSchema<Encoding>* itemsList_;
|
BaseSchema<Encoding>* itemsList_;
|
||||||
BaseSchema<Encoding>** itemsTuple_;
|
BaseSchema<Encoding>** itemsTuple_;
|
||||||
SizeType itemsTupleCount_;
|
SizeType itemsTupleCount_;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user