Skip to content
Projects
Groups
Snippets
Help
Loading...
Sign in / Register
Toggle navigation
R
rapidjson
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Packages
Packages
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
submodule
rapidjson
Commits
f586edd3
Commit
f586edd3
authored
Apr 19, 2016
by
Milo Yip
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Fix required for duplicated keys
Fix #608
parent
c8a1d517
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
20 additions
and
9 deletions
+20
-9
schema.h
include/rapidjson/schema.h
+20
-9
No files found.
include/rapidjson/schema.h
View file @
f586edd3
...
...
@@ -290,6 +290,7 @@ struct SchemaValidationContext {
patternPropertiesSchemaCount
(),
valuePatternValidatorType
(
kPatternValidatorOnly
),
objectDependencies
(),
objectRequired
(),
inArray
(
false
),
valueUniqueness
(
false
),
arrayUniqueness
(
false
)
...
...
@@ -313,6 +314,8 @@ struct SchemaValidationContext {
factory
.
FreeState
(
patternPropertiesSchemas
);
if
(
objectDependencies
)
factory
.
FreeState
(
objectDependencies
);
if
(
objectRequired
)
factory
.
FreeState
(
objectRequired
);
}
SchemaValidatorFactoryType
&
factory
;
...
...
@@ -329,9 +332,9 @@ struct SchemaValidationContext {
SizeType
patternPropertiesSchemaCount
;
PatternValidatorType
valuePatternValidatorType
;
PatternValidatorType
objectPatternValidatorType
;
SizeType
objectRequiredCount
;
SizeType
arrayElementIndex
;
bool
*
objectDependencies
;
bool
*
objectRequired
;
bool
inArray
;
bool
valueUniqueness
;
bool
arrayUniqueness
;
...
...
@@ -365,11 +368,11 @@ public:
patternProperties_
(),
patternPropertyCount_
(),
propertyCount_
(),
requiredCount_
(),
minProperties_
(),
maxProperties_
(
SizeType
(
~
0
)),
additionalProperties_
(
true
),
hasDependencies_
(),
hasRequired_
(),
hasSchemaDependencies_
(),
additionalItemsSchema_
(),
itemsList_
(),
...
...
@@ -490,7 +493,7 @@ public:
SizeType
index
;
if
(
FindPropertyIndex
(
*
itr
,
&
index
))
{
properties_
[
index
].
required
=
true
;
requiredCount_
++
;
hasRequired_
=
true
;
}
}
...
...
@@ -767,7 +770,11 @@ public:
if
(
!
(
type_
&
(
1
<<
kObjectSchemaType
)))
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetTypeString
());
context
.
objectRequiredCount
=
0
;
if
(
hasRequired_
)
{
context
.
objectRequired
=
static_cast
<
bool
*>
(
context
.
factory
.
MallocState
(
sizeof
(
bool
)
*
propertyCount_
));
std
::
memset
(
context
.
objectRequired
,
0
,
sizeof
(
bool
)
*
propertyCount_
);
}
if
(
hasDependencies_
)
{
context
.
objectDependencies
=
static_cast
<
bool
*>
(
context
.
factory
.
MallocState
(
sizeof
(
bool
)
*
propertyCount_
));
std
::
memset
(
context
.
objectDependencies
,
0
,
sizeof
(
bool
)
*
propertyCount_
);
...
...
@@ -801,8 +808,8 @@ public:
else
context
.
valueSchema
=
properties_
[
index
].
schema
;
if
(
properties_
[
index
].
required
)
context
.
objectRequired
Count
++
;
if
(
hasRequired_
)
context
.
objectRequired
[
index
]
=
true
;
if
(
hasDependencies_
)
context
.
objectDependencies
[
index
]
=
true
;
...
...
@@ -832,8 +839,12 @@ public:
}
bool
EndObject
(
Context
&
context
,
SizeType
memberCount
)
const
{
if
(
context
.
objectRequiredCount
!=
requiredCount_
)
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetRequiredString
());
if
(
hasRequired_
)
for
(
SizeType
index
=
0
;
index
<
propertyCount_
;
index
++
)
{
if
(
properties_
[
index
].
required
)
if
(
!
context
.
objectRequired
[
index
])
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetRequiredString
());
}
if
(
memberCount
<
minProperties_
)
RAPIDJSON_INVALID_KEYWORD_RETURN
(
GetMinPropertiesString
());
...
...
@@ -1236,11 +1247,11 @@ private:
PatternProperty
*
patternProperties_
;
SizeType
patternPropertyCount_
;
SizeType
propertyCount_
;
SizeType
requiredCount_
;
SizeType
minProperties_
;
SizeType
maxProperties_
;
bool
additionalProperties_
;
bool
hasDependencies_
;
bool
hasRequired_
;
bool
hasSchemaDependencies_
;
const
SchemaType
*
additionalItemsSchema_
;
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment