-
-
Notifications
You must be signed in to change notification settings - Fork 1
Add tests for references and change in rules for draft3 to 4 #54
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
{ | ||
"vocabulary": "core", | ||
"condition": [ | ||
{ "operation": "has-key", "path": [], "value": "type" }, | ||
{ "operation": "type-is", "path": [ "type" ], "value": "array" }, | ||
{ "operation": "contains-type", "path": [ "type" ], "value": "object" }, | ||
{ "operation": "type-is", "path": [ "type", {} ], "value": "string" } | ||
], | ||
"transform": [ | ||
{ "operation": "remove", "path": [ "type", {} ] } | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
{ | ||
"vocabulary": "core", | ||
"condition": [ | ||
{ "operation": "has-key", "path": [], "value": "type" }, | ||
{ "operation": "type-is", "path": [ "type" ], "value": "array" }, | ||
{ "operation": "contains-type", "path": [ "type" ], "value": "boolean" } | ||
], | ||
"transform": [ | ||
{ "operation": "remove", "path": [ "type" ] } | ||
] | ||
} |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
[ | ||
{ | ||
"title": "Reference to contains", | ||
"from": { | ||
"$ref": "#/contains", | ||
"contains": { | ||
"type": "string" | ||
} | ||
}, | ||
"to": { | ||
"$ref": "#/allOf/0/not/not/contains", | ||
"allOf": [ | ||
{ | ||
"not": { | ||
"not": { | ||
"contains": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"title":"Reference to items is an array", | ||
"from": { | ||
"$ref": "#/items/0", | ||
"items": [ | ||
{ | ||
"type": "string" | ||
} | ||
] | ||
}, | ||
"to": { | ||
"$ref": "#/prefixItems/0", | ||
"prefixItems": [ | ||
{ | ||
"type": "string" | ||
} | ||
] | ||
} | ||
}, | ||
{ | ||
"title":"Reference to items is an object", | ||
"from": { | ||
"$ref": "#/items", | ||
"items": { | ||
"type": "string" | ||
} | ||
}, | ||
"to": { | ||
"$ref": "#/items", | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
{ | ||
"title":"Reference to additionalItems is an object, items is an array", | ||
"from": { | ||
"$ref": "#/additionalItems", | ||
"items": [ {} ], | ||
"additionalItems": { | ||
"type": "string" | ||
} | ||
}, | ||
"to": { | ||
"$ref": "#/items", | ||
"prefixItems": [ {} ], | ||
"items": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,89 @@ | ||
[ | ||
{ | ||
"title": "Reference to `type` when it has objects in its array", | ||
"from": { | ||
"type": [ {} ], | ||
"$ref": "#/type/0" | ||
}, | ||
"to": { | ||
"$ref": "#/anyOf/0", | ||
"anyOf": [ | ||
{} | ||
] | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `type` when it has objects and string in its array", | ||
"from": { | ||
"type": [ "string", {} ], | ||
"$ref": "#/type/1" | ||
}, | ||
"to": { | ||
"anyOf": [ | ||
{ "type": ["string"] }, | ||
{} | ||
] | ||
} | ||
}, | ||
{ | ||
"title":"Reference to `disallow` when it has objects in its array", | ||
"from": { | ||
"disallow": [ {} ], | ||
"$ref": "#/disallow/0" | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ "not": {} } | ||
], | ||
"$ref": "#/allOf/0/not" | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `disallow` when it has objects and string in its array", | ||
"from": { | ||
"disallow": [ "string", {} ], | ||
"$ref": "#/disallow/1" | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ | ||
"not": {} | ||
}, | ||
{ | ||
"not": { | ||
"type": [ | ||
"string" | ||
] | ||
} | ||
} | ||
], | ||
"$ref": "#/allOf/0/not" | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `extends` when its an array", | ||
"from": { | ||
"extends": [ {}, { "type": "object" } ], | ||
"$ref": "#/extends/0" | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{} | ||
], | ||
"$ref": "#/allOf/1" | ||
|
||
} | ||
}, | ||
{ | ||
"title": "Reference to `extends` when its an object", | ||
"from": { | ||
"extends": {}, | ||
"$ref": "#/extends" | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{} | ||
], | ||
"$ref": "#/allOf/0" | ||
} | ||
} | ||
] |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
[ | ||
{ | ||
"title": "Reference to definitions", | ||
"from": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/definitions/foo" | ||
} | ||
], | ||
"definitions": { | ||
"foo": {} | ||
} | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/$defs/foo" | ||
} | ||
], | ||
"$defs": { | ||
"foo": {} | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Reference to dependencies, child is a schema", | ||
"from": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/dependencies/foo" | ||
} | ||
], | ||
"dependencies": { | ||
"foo": { | ||
"type": "string" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ | ||
"$ref": "#/dependentSchemas/foo" | ||
} | ||
], | ||
"dependentSchemas": { | ||
"foo": { | ||
"type": "string" | ||
} | ||
} | ||
} | ||
} | ||
] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It is valid, but shouldn't the subschemas in
allOf
be in the opposite order? i.e. thedisallow
keyword first disallowsstring
, so shouldn't the type stringnot
be first in the array?There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah! by doing it this way I can get the indexes of objects, like
If I choose to upgrade index 0:
string
... Then I will lose track of the index where the object was present.If
string
is popped first, then array will be[{}]
, then I lose track that it was in index 1, because now its in index 0