generated from json-schema-org/repo-template
-
-
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
Merged
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
12 changes: 12 additions & 0 deletions
12
rules/from-draft3/to-draft4/016-type-has-objects-and-strings-in-its-array.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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", {} ] } | ||
] | ||
} |
11 changes: 11 additions & 0 deletions
11
rules/from-draft3/to-draft4/017-type-has-boolean-in-its-array.json
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" ] } | ||
] | ||
} |
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
[ | ||
{ | ||
"title": "Reference to `type` when it has objects in its array", | ||
"from": { | ||
"type": [ {} ], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/type/0" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"anyOf": [ | ||
{} | ||
], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/anyOf/0" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `type` when it has objects and string in its array", | ||
"from": { | ||
"type": [ "string", {} ], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/type/1" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"anyOf": [ | ||
{ "type": ["string"] }, | ||
{} | ||
], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/anyOf/1" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"title":"Reference to `disallow` when it has objects in its array", | ||
"from": { | ||
"disallow": [ {} ], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/disallow/0" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ "not": {} } | ||
], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/allOf/0/not" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `disallow` when it has objects and string in its array", | ||
"from": { | ||
"disallow": [ "string", {} ], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/disallow/1" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ | ||
"not": {} | ||
}, | ||
{ | ||
"not": { | ||
"type": [ | ||
"string" | ||
] | ||
} | ||
} | ||
], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/allOf/0/not" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `extends` when its an array", | ||
"from": { | ||
"extends": [ {}, { "type": "object" } ], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/extends/0" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{ | ||
"type": "object" | ||
}, | ||
{} | ||
], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/allOf/0" | ||
} | ||
} | ||
} | ||
}, | ||
{ | ||
"title": "Reference to `extends` when its an object", | ||
"from": { | ||
"extends": {}, | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/extends" | ||
} | ||
} | ||
}, | ||
"to": { | ||
"allOf": [ | ||
{} | ||
], | ||
"properties": { | ||
"foo": { | ||
"$ref": "#/allOf/0" | ||
} | ||
} | ||
} | ||
} | ||
] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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" | ||
} | ||
} | ||
} | ||
} | ||
] |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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