Skip to content

Commit

Permalink
Upgrade draft3 type: any
Browse files Browse the repository at this point in the history
See: #83
Signed-off-by: Juan Cruz Viotti <jv@jviotti.com>
  • Loading branch information
jviotti committed Nov 5, 2022
1 parent 94ecf0e commit 35b3112
Show file tree
Hide file tree
Showing 6 changed files with 219 additions and 6 deletions.
60 changes: 59 additions & 1 deletion rules/jsonschema-draft3-to-draft4.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,62 @@
{
"walker": "jsonschema-draft3",
"rules": []
"rules": [
{
"vocabulary": "core",
"condition": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/sourcemeta/alterschema/rules/jsonschema-draft3-to-draft4/upgrade-official-metaschema",
"type": "object",
"required": [ "$schema" ],
"properties": {
"$schema": {
"const": "http://json-schema.org/draft-03/schema#"
}
}
},
"transform": {
"$merge": [
{ "$eval": "schema" },
{ "$$schema": "http://json-schema.org/draft-04/schema#" }
]
}
},
{
"vocabulary": "core",
"condition": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/sourcemeta/alterschema/rules/jsonschema-draft4-to-draft6/type-any",
"type": "object",
"required": [ "type" ],
"properties": {
"type": {
"const": "any"
}
}
},
"transform": {
"$eval": "omit(schema, 'type')"
}
},
{
"vocabulary": "core",
"condition": {
"$schema": "https://json-schema.org/draft/2020-12/schema",
"$id": "https://github.com/sourcemeta/alterschema/rules/jsonschema-draft4-to-draft6/type-any",
"type": "object",
"required": [ "type" ],
"properties": {
"type": {
"type": "array",
"contains": {
"const": "any"
}
}
}
},
"transform": {
"$eval": "omit(schema, 'type')"
}
}
]
}
33 changes: 32 additions & 1 deletion test/rules/jsonschema-draft3-to-2019-09.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
[]
[
{
"name": "draft3 type:any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "any"
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft3 type:[any]",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "any" ]
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
},
{
"name": "draft3 type including any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "string", "any" ]
},
"expected": {
"$schema": "https://json-schema.org/draft/2019-09/schema"
}
}
]
33 changes: 32 additions & 1 deletion test/rules/jsonschema-draft3-to-2020-12.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
[]
[
{
"name": "draft3 type:any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "any"
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft3 type:[any]",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "any" ]
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
},
{
"name": "draft3 type including any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "string", "any" ]
},
"expected": {
"$schema": "https://json-schema.org/draft/2020-12/schema"
}
}
]
33 changes: 32 additions & 1 deletion test/rules/jsonschema-draft3-to-draft4.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
[]
[
{
"name": "draft3 type:any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "any"
},
"expected": {
"$schema": "http://json-schema.org/draft-04/schema#"
}
},
{
"name": "draft3 type:[any]",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "any" ]
},
"expected": {
"$schema": "http://json-schema.org/draft-04/schema#"
}
},
{
"name": "draft3 type including any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "string", "any" ]
},
"expected": {
"$schema": "http://json-schema.org/draft-04/schema#"
}
}
]
33 changes: 32 additions & 1 deletion test/rules/jsonschema-draft3-to-draft6.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
[]
[
{
"name": "draft3 type:any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "any"
},
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#"
}
},
{
"name": "draft3 type:[any]",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "any" ]
},
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#"
}
},
{
"name": "draft3 type including any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "string", "any" ]
},
"expected": {
"$schema": "http://json-schema.org/draft-06/schema#"
}
}
]
33 changes: 32 additions & 1 deletion test/rules/jsonschema-draft3-to-draft7.json
Original file line number Diff line number Diff line change
@@ -1 +1,32 @@
[]
[
{
"name": "draft3 type:any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": "any"
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft3 type:[any]",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "any" ]
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
},
{
"name": "draft3 type including any",
"schema": {
"$schema": "http://json-schema.org/draft-03/schema#",
"type": [ "string", "any" ]
},
"expected": {
"$schema": "http://json-schema.org/draft-07/schema#"
}
}
]

0 comments on commit 35b3112

Please sign in to comment.