Skip to content

Commit 157e509

Browse files
committed
Try layers validation with json-schema
1 parent c237777 commit 157e509

2 files changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
{
2+
"$schema": "http://json-schema.org/draft-07/schema#",
3+
4+
"definitions": {
5+
"columns": {
6+
"type": "string",
7+
"enum": ["units", "contacts"]
8+
}
9+
},
10+
11+
"type": "array",
12+
"items": [
13+
{
14+
"$ref": "#/definitions/columns"
15+
},
16+
{
17+
"$ref": "#/definitions/columns"
18+
}
19+
],
20+
"minItems": 2,
21+
"uniqueItems": true,
22+
"additionalItems": { "type": "string" }
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import jsonschema
2+
import json
3+
4+
_component = __file__.split('.')[0]
5+
_schemafile = '.'.join([_component, 'schmea', 'json'])
6+
7+
def validate(geopackage):
8+
import fiona
9+
with open(_schemafile) as f:
10+
schema = json.load(_schemafile)
11+
12+
data = fiona.listlayers(geopackage)
13+
res = jsonschema.validate(data, schema)

0 commit comments

Comments
 (0)