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
8c182e51
Commit
8c182e51
authored
Sep 30, 2017
by
Yuri Khan
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Flatten allOf keyword violations
parent
8353e868
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
49 additions
and
103 deletions
+49
-103
schema.h
include/rapidjson/schema.h
+3
-1
schematest.cpp
test/unittest/schematest.cpp
+46
-102
No files found.
include/rapidjson/schema.h
View file @
8c182e51
...
...
@@ -2011,7 +2011,9 @@ public:
AddCurrentError
(
SchemaType
::
GetTypeString
());
}
void
NotAllOf
(
ISchemaValidator
**
subvalidators
,
SizeType
count
)
{
AddErrorArray
(
SchemaType
::
GetAllOfString
(),
subvalidators
,
count
);
for
(
SizeType
i
=
0
;
i
<
count
;
++
i
)
{
MergeError
(
static_cast
<
GenericSchemaValidator
*>
(
subvalidators
[
i
])
->
GetError
());
}
}
void
NoneOf
(
ISchemaValidator
**
subvalidators
,
SizeType
count
)
{
AddErrorArray
(
SchemaType
::
GetAnyOfString
(),
subvalidators
,
count
);
...
...
test/unittest/schematest.cpp
View file @
8c182e51
...
...
@@ -236,15 +236,9 @@ TEST(SchemaValidator, AllOf) {
VALIDATE
(
s
,
"
\"
ok
\"
"
,
true
);
INVALIDATE
(
s
,
"
\"
too long
\"
"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {},"
" {
\"
maxLength
\"
: { "
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/1
\"
, "
"
\"
expected
\"
: 5,
\"
actual
\"
:
\"
too long
\"
"
" }}"
" ]"
"{
\"
maxLength
\"
: { "
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/1
\"
, "
"
\"
expected
\"
: 5,
\"
actual
\"
:
\"
too long
\"
"
"}}"
);
}
{
...
...
@@ -254,14 +248,8 @@ TEST(SchemaValidator, AllOf) {
VALIDATE
(
s
,
"
\"
No way
\"
"
,
false
);
INVALIDATE
(
s
,
"-1"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {
\"
type
\"
: {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: [
\"
string
\"
],
\"
actual
\"
:
\"
integer
\"
"
" }},"
" {}"
" ]"
"{
\"
type
\"
: {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: [
\"
string
\"
],
\"
actual
\"
:
\"
integer
\"
"
"}}"
);
}
}
...
...
@@ -387,16 +375,11 @@ TEST(SchemaValidator, Ref_AllOf) {
SchemaDocument
s
(
sd
);
INVALIDATE
(
s
,
"{
\"
shipping_address
\"
: {
\"
street_address
\"
:
\"
1600 Pennsylvania Avenue NW
\"
,
\"
city
\"
:
\"
Washington
\"
,
\"
state
\"
:
\"
DC
\"
} }"
,
"/properties/shipping_address"
,
"allOf"
,
"/shipping_address"
,
"{
\"
allOf
\"
: {"
"{
\"
required
\"
: {"
"
\"
instanceRef
\"
:
\"
#/shipping_address
\"
,"
"
\"
schemaRef
\"
:
\"
#/properties/shipping_address
\"
,"
"
\"
errors
\"
: ["
" {},"
" {
\"
required
\"
: {"
"
\"
instanceRef
\"
:
\"
#/shipping_address
\"
,"
"
\"
schemaRef
\"
:
\"
#/properties/shipping_address/allOf/1
\"
,"
"
\"
missing
\"
: [
\"
type
\"
]"
"}} ] }}"
);
"
\"
schemaRef
\"
:
\"
#/properties/shipping_address/allOf/1
\"
,"
"
\"
missing
\"
: [
\"
type
\"
]"
"}}"
);
VALIDATE
(
s
,
"{
\"
shipping_address
\"
: {
\"
street_address
\"
:
\"
1600 Pennsylvania Avenue NW
\"
,
\"
city
\"
:
\"
Washington
\"
,
\"
state
\"
:
\"
DC
\"
,
\"
type
\"
:
\"
business
\"
} }"
,
true
);
}
...
...
@@ -1537,87 +1520,48 @@ TEST(SchemaValidator, AllOf_Nested) {
VALIDATE
(
s
,
"
\"
ok
\"
"
,
true
);
VALIDATE
(
s
,
"
\"
OK
\"
"
,
true
);
INVALIDATE
(
s
,
"
\"
okay
\"
"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {}, "
" {}, "
" {
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2
\"
,"
"
\"
errors
\"
: ["
" {}, "
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
"
"}} ] }} ] }}"
);
"{
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
"
"}}"
);
INVALIDATE
(
s
,
"
\"
o
\"
"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {
\"
minLength
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: 2,
\"
actual
\"
:
\"
o
\"
"
" }},"
" {},"
" {}"
" ]"
"{
\"
minLength
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: 2,
\"
actual
\"
:
\"
o
\"
"
"}}"
);
INVALIDATE
(
s
,
"
\"
n
\"
"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {
\"
minLength
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: 2,
\"
actual
\"
:
\"
n
\"
"
" }},"
" {}, "
" {
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2
\"
,"
"
\"
errors
\"
: ["
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/0
\"
"
" }},"
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
"
"}} ] }} ] }}"
);
"{
\"
minLength
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: 2,
\"
actual
\"
:
\"
n
\"
"
" },"
"
\"
enum
\"
: ["
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/0
\"
},"
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
}"
" ]"
"}"
)
INVALIDATE
(
s
,
"
\"
too long
\"
"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {}, "
" {
\"
maxLength
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/1
\"
,"
"
\"
expected
\"
: 5,
\"
actual
\"
:
\"
too long
\"
"
" }},"
" {
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2
\"
,"
"
\"
errors
\"
: ["
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/0
\"
"
" }},"
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
"
"}} ] }} ] }}"
);
"{
\"
maxLength
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/1
\"
,"
"
\"
expected
\"
: 5,
\"
actual
\"
:
\"
too long
\"
"
" },"
"
\"
enum
\"
: ["
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/0
\"
},"
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
}"
" ]"
"}"
);
INVALIDATE
(
s
,
"123"
,
""
,
"allOf"
,
""
,
"{
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#
\"
,"
"
\"
errors
\"
: ["
" {
\"
type
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: [
\"
string
\"
],
\"
actual
\"
:
\"
integer
\"
"
" }},"
" {
\"
type
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/1
\"
,"
"
\"
expected
\"
: [
\"
string
\"
],
\"
actual
\"
:
\"
integer
\"
"
" }},"
" {
\"
allOf
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2
\"
,"
"
\"
errors
\"
: ["
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/0
\"
"
" }}, "
" {
\"
enum
\"
: {"
"
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
"
"}} ] }} ] }}"
);
"{
\"
type
\"
: ["
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/0
\"
,"
"
\"
expected
\"
: [
\"
string
\"
],
\"
actual
\"
:
\"
integer
\"
"
" },"
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/1
\"
,"
"
\"
expected
\"
: [
\"
string
\"
],
\"
actual
\"
:
\"
integer
\"
"
" }"
" ],"
"
\"
enum
\"
: ["
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/0
\"
},"
" {
\"
instanceRef
\"
:
\"
#
\"
,
\"
schemaRef
\"
:
\"
#/allOf/2/allOf/1
\"
}"
" ]"
"}"
);
}
TEST
(
SchemaValidator
,
EscapedPointer
)
{
...
...
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