Skip to content

Commit

Permalink
Draft 2 to 3, rules on optional, requires keyword (#43)
Browse files Browse the repository at this point in the history
  • Loading branch information
suprith-hub committed Aug 13, 2024
1 parent 4056e3c commit 7bcf16a
Show file tree
Hide file tree
Showing 7 changed files with 134 additions and 0 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
{
"vocabulary": "core",
"condition": [
{ "operation": "has-key", "path": [], "value": "properties" },
{ "operation": "has-key", "path": [ "properties", {} ], "value": "optional" },
{ "operation": "equals", "path": [ "properties", {}, "optional" ], "value": true }
],
"transform": [
{ "operation": "remove", "path": [ "properties", {}, "optional" ] }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
{
"vocabulary": "core",
"condition": [
{ "operation": "has-key", "path": [], "value": "properties" },
{ "operation": "has-key", "path": [ "properties", {} ], "value": "optional" },
{ "operation": "equals", "path": [ "properties", {}, "optional" ], "value": false },
{ "operation": "has-key", "path": [ "properties", {} ], "value": "required" }
],
"transform": [
{ "operation": "prefix-until-unique", "path": [ "properties", {}, "required" ], "value": "x-" }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
{
"vocabulary": "core",
"condition": [
{ "operation": "has-key", "path": [], "value": "properties" },
{ "operation": "has-key", "path": [ "properties", {} ], "value": "optional" },
{ "operation": "equals", "path": [ "properties", {}, "optional" ], "value": false },
{ "operation": "not-has-key", "path": [ "properties", {} ], "value": "required" }
],
"transform": [
{ "operation": "move", "to": [ "properties", {}, "required" ], "from": [ "properties", {}, "optional" ] },
{ "operation": "replace", "path": [ "properties", {}, "required" ], "value": true }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"vocabulary": "core",
"condition": [
{ "operation": "has-key", "path": [], "value": "properties" },
{ "operation": "has-key", "path": [ "properties", {} ], "value": "requires" }
],
"transform": [
{ "operation": "add", "path": [ "dependencies" ], "value": {} }
]
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"vocabulary": "core",
"condition": [
{ "operation": "has-key", "path": [], "value": "properties" },
{ "operation": "has-key", "path": [ "properties", {} ], "value": "requires" }
],
"transform": [
{ "operation": "move", "to": [ "dependencies", {} ], "from": [ "properties", {}, "requires" ] }
]
}
53 changes: 53 additions & 0 deletions test/from-draft2/to-draft3/optional-in-properties-children.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
[
{
"title": "properties has children who have optional:false and required is already present",
"from": {
"properties": {
"foo": {
"required": "string",
"optional": false
}
}
},
"to": {
"properties": {
"foo": {
"x-required": "string",
"required": true
}
}
}
},
{
"title": "properties has children who have optional:false",
"from": {
"properties": {
"foo": {
"optional": false
}
}
},
"to": {
"properties": {
"foo": {
"required": true
}
}
}
},
{
"title": "properties has children who have optional:true",
"from": {
"properties": {
"foo": {
"optional": true
}
}
},
"to": {
"properties": {
"foo": {}
}
}
}
]
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
[
{
"title": "properties has children who have `requires` keyword",
"from": {
"properties": {
"foo": {
"requires": "bar"
},
"bar": {
"requires": { "type": "string"}
}
}
},
"to": {
"properties": {
"foo": {},
"bar": {}
},
"dependencies": {
"foo": "bar",
"bar": { "type": "string"}
}
}
}
]

0 comments on commit 7bcf16a

Please sign in to comment.