Skip to content

Commit 3d385a5

Browse files
authored
Update JSON Schemas to Draft202012 (#223)
* Change to draft 2020-12 schema * Switch to DRAFT202012 * Support const output without quotes
1 parent 903d381 commit 3d385a5

39 files changed

+508
-284
lines changed

mappyfile/pprint.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -354,7 +354,9 @@ def is_expression(self, option):
354354

355355
def check_options_list(self, options_list, value):
356356
for option in options_list:
357-
if "enum" in option and value.lower() in option["enum"]:
357+
if ("enum" in option and value.lower() in option["enum"]) or (
358+
"const" in option and value.lower() in option["const"]
359+
):
358360
if value.lower() == "end":
359361
# in GEOTRANSFORM "end" is an attribute value
360362
return self.quoter.add_quotes(value)

mappyfile/schemas/class.json

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"type": "object",
33
"additionalProperties": false,
44
"patternProperties": {
5-
"^__[a-z]+__$": {}
5+
"^__[a-z]+__$": true
66
},
77
"properties": {
88
"__type__": {
9-
"enum": [ "class" ]
9+
"const": "class"
1010
},
1111
"include": {
1212
"type": "array",
@@ -78,7 +78,7 @@
7878
"type": "number",
7979
"minimum": 0,
8080
"metadata": {
81-
"minVersion": 5.0
81+
"minVersion": 5
8282
}
8383
},
8484
"maxsize": {
@@ -91,8 +91,7 @@
9191
"$ref": "metadata.json"
9292
},
9393
"minfeaturesize": {
94-
"type": "number",
95-
"exclusiveMinimum": 0
94+
"type": "number"
9695
},
9796
"minscale": {
9897
"type": "number",
@@ -104,7 +103,7 @@
104103
"type": "number",
105104
"minimum": 0,
106105
"metadata": {
107-
"minVersion": 5.0
106+
"minVersion": 5
108107
}
109108
},
110109
"minsize": {
@@ -141,7 +140,7 @@
141140
"$ref": "style.json"
142141
},
143142
"metadata": {
144-
"minVersion": 4.0
143+
"minVersion": 4
145144
}
146145
},
147146
"symbol": {
@@ -173,5 +172,6 @@
173172
"validation": {
174173
"$ref": "validation.json"
175174
}
176-
}
177-
}
175+
},
176+
"$schema": "https://json-schema.org/draft/2020-12/schema"
177+
}

mappyfile/schemas/cluster.json

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"type": "object",
33
"additionalProperties": false,
44
"patternProperties": {
5-
"^__[a-z]+__$": {}
5+
"^__[a-z]+__$": true
66
},
77
"properties": {
88
"__type__": {
9-
"enum": [ "cluster" ]
9+
"const": "cluster"
1010
},
1111
"include": {
1212
"type": "array",
@@ -16,8 +16,7 @@
1616
},
1717
"maxdistance": {
1818
"type": "number",
19-
"default": 10,
20-
"exclusiveMinimum": 0
19+
"default": 10
2120
},
2221
"region": {
2322
"oneOf": [
@@ -41,5 +40,6 @@
4140
"filter": {
4241
"$ref": "expression.json"
4342
}
44-
}
45-
}
43+
},
44+
"$schema": "https://json-schema.org/draft/2020-12/schema"
45+
}

mappyfile/schemas/color.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,5 +15,6 @@
1515
"example": "#aa33cc",
1616
"type": "string"
1717
}
18-
]
18+
],
19+
"$schema": "https://json-schema.org/draft/2020-12/schema"
1920
}

mappyfile/schemas/composite.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"type": "object",
33
"additionalProperties": false,
44
"patternProperties": {
5-
"^__[a-z]+__$": {}
5+
"^__[a-z]+__$": true
66
},
77
"properties": {
88
"__type__": {
9-
"enum": [ "composite" ]
9+
"const": "composite"
1010
},
1111
"include": {
1212
"type": "array",
@@ -58,5 +58,6 @@
5858
"xor"
5959
]
6060
}
61-
}
62-
}
61+
},
62+
"$schema": "https://json-schema.org/draft/2020-12/schema"
63+
}
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
{
22
"type": "object",
3-
"properties": {
4-
},
3+
"properties": {},
54
"additionalProperties": true,
65
"metadata": {
76
"minVersion": 7.6
8-
}
7+
},
8+
"$schema": "https://json-schema.org/draft/2020-12/schema"
99
}

mappyfile/schemas/debug.json

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,13 @@
11
{
2-
"enum": [ "on", "off", 0, 1, 2, 3, 4, 5 ]
3-
}
2+
"enum": [
3+
"on",
4+
"off",
5+
0,
6+
1,
7+
2,
8+
3,
9+
4,
10+
5
11+
],
12+
"$schema": "https://json-schema.org/draft/2020-12/schema"
13+
}

mappyfile/schemas/expression.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,5 +13,6 @@
1313
"pattern": "^/(.*?)/$",
1414
"description": "regex"
1515
}
16-
]
17-
}
16+
],
17+
"$schema": "https://json-schema.org/draft/2020-12/schema"
18+
}

mappyfile/schemas/extent.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,5 +4,6 @@
44
"type": "number"
55
},
66
"minItems": 4,
7-
"maxItems": 4
8-
}
7+
"maxItems": 4,
8+
"$schema": "https://json-schema.org/draft/2020-12/schema"
9+
}

mappyfile/schemas/feature.json

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,11 @@
22
"type": "object",
33
"additionalProperties": false,
44
"patternProperties": {
5-
"^__[a-z]+__$": {}
5+
"^__[a-z]+__$": true
66
},
77
"properties": {
88
"__type__": {
9-
"enum": [ "feature" ]
9+
"const": "feature"
1010
},
1111
"include": {
1212
"type": "array",
@@ -36,5 +36,6 @@
3636
"wkt": {
3737
"type": "string"
3838
}
39-
}
40-
}
39+
},
40+
"$schema": "https://json-schema.org/draft/2020-12/schema"
41+
}

0 commit comments

Comments
 (0)