Skip to content

Commit 16ba335

Browse files
author
irinaschubert
authored
chore(schemas): update schemas (DSP-1902) (#92)
* enforce schema reference to ontology * update schema version and id * update schema titles and descriptions * correct typo * restructure schemas * test external xsd schema * update schema reference * update schema reference url in xml * use uri-prop
1 parent c46618f commit 16ba335

13 files changed

Lines changed: 1251 additions & 1164 deletions

‎knora/dsplib/schemas/__init__.py‎

Whitespace-only changes.
Lines changed: 91 additions & 87 deletions
Large diffs are not rendered by default.

knora/dsplib/utils/knora-schema-lists-only.json renamed to knora/dsplib/schemas/lists-only.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "http://knora.org/pyknora/ontology/knora-schema-list-only.json",
4-
"title": "Knora JSON schema for lists only",
5-
"description": "JSON schema for lists used in Knora ontologies",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://dasch.swiss/schema/knora-schema-list-only.json",
4+
"title": "JSON schema for DSP lists",
5+
"description": "JSON schema for the lists section used in DSP ontologies",
66
"definitions": {
77
"label": {
88
"type": "object",

knora/dsplib/utils/knora-schema-lists.json renamed to knora/dsplib/schemas/lists.json

Lines changed: 15 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,8 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "http://knora.org/pyknora/ontology/knora-schema.json",
4-
"title": "Knora JSON schema",
5-
"description": "JSON Schema for Knora ontologies",
6-
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://dasch.swiss/schema/knora-schema.json",
4+
"title": "JSON schema for DSP lists",
5+
"description": "JSON schema for lists used in DSP ontologies",
76
"definitions": {
87
"label": {
98
"type": "object",
@@ -74,17 +73,25 @@
7473
}
7574
}
7675
},
77-
"required": ["shortcode", "lists"],
76+
"required": [
77+
"shortcode",
78+
"lists"
79+
],
7880
"additionalProperties": false
7981
},
8082
"prefixes": {
8183
"type": "object",
8284
"patternProperties": {
83-
"^[\\w-]+$": { "format" : "uri" }
85+
"^[\\w-]+$": {
86+
"format": "uri"
87+
}
8488
},
8589
"additionalProperties": false
8690
}
8791
},
88-
"required": ["prefixes", "project"],
92+
"required": [
93+
"prefixes",
94+
"project"
95+
],
8996
"additionalProperties": false
9097
}
Lines changed: 83 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "http://knora.org/pyknora/ontology/knora-schema.json",
4-
"title": "knora-py JSON schema",
5-
"description": "JSON Schema for Knora ontologies",
6-
2+
"$schema": "https://json-schema.org/draft/2020-12/schema",
3+
"$id": "https://dasch.swiss/schema/knora-schema.json",
4+
"title": "JSON schema for DSP ontologies",
5+
"description": "JSON schema for DSP ontologies",
76
"definitions": {
8-
97
"langstring": {
108
"anyOf": [
119
{
@@ -22,32 +20,29 @@
2220
}
2321
]
2422
},
25-
2623
"label": {
2724
"$ref": "#/definitions/langstring"
2825
},
29-
3026
"description": {
3127
"$ref": "#/definitions/langstring"
3228
},
33-
3429
"comment": {
3530
"$ref": "#/definitions/langstring"
3631
},
37-
3832
"groupdef": {
3933
"type": "string",
4034
"pattern": "^(([\\w-]*)?:([\\w ]+))|(SystemAdmin)$",
4135
"additionalProperties": false
4236
},
43-
4437
"projectdef": {
4538
"type": "string",
4639
"pattern": "^([\\w-]*)?:(member|admin)$"
4740
},
48-
4941
"resourcedef": {
50-
"type": ["string", "array"],
42+
"type": [
43+
"string",
44+
"array"
45+
],
5146
"oneOf": [
5247
{
5348
"enum": [
@@ -74,7 +69,6 @@
7469
"$ref": "#/definitions/resourcedef"
7570
}
7671
},
77-
7872
"excelref": {
7973
"type": "object",
8074
"properties": {
@@ -91,9 +85,11 @@
9185
"type": "integer"
9286
}
9387
},
94-
"required": ["file", "worksheet"]
88+
"required": [
89+
"file",
90+
"worksheet"
91+
]
9592
},
96-
9793
"user": {
9894
"type": "object",
9995
"properties": {
@@ -128,9 +124,14 @@
128124
}
129125
}
130126
},
131-
"required": ["username", "email", "givenName", "familyName", "password"]
127+
"required": [
128+
"username",
129+
"email",
130+
"givenName",
131+
"familyName",
132+
"password"
133+
]
132134
},
133-
134135
"group": {
135136
"type": "object",
136137
"properties": {
@@ -147,9 +148,11 @@
147148
"type": "boolean"
148149
}
149150
},
150-
"required": ["name", "description"]
151+
"required": [
152+
"name",
153+
"description"
154+
]
151155
},
152-
153156
"node": {
154157
"type": "object",
155158
"properties": {
@@ -177,10 +180,12 @@
177180
]
178181
}
179182
},
180-
"required": ["name", "labels"],
183+
"required": [
184+
"name",
185+
"labels"
186+
],
181187
"additionalProperties": false
182188
},
183-
184189
"ontology": {
185190
"type": "object",
186191
"properties": {
@@ -199,17 +204,21 @@
199204
"$ref": "#/definitions/property"
200205
}
201206
},
202-
"resources": {
207+
"resources": {
203208
"type": "array",
204209
"items": {
205210
"$ref": "#/definitions/resource"
206211
}
207212
}
208213
},
209-
"required": ["name", "label", "properties", "resources"],
214+
"required": [
215+
"name",
216+
"label",
217+
"properties",
218+
"resources"
219+
],
210220
"additionalProperties": false
211221
},
212-
213222
"property": {
214223
"type": "object",
215224
"properties": {
@@ -275,11 +284,9 @@
275284
"type": "string",
276285
"pattern": "^([\\w-]+)?:(\\w+)$"
277286
},
278-
279287
"labels": {
280288
"$ref": "#/definitions/label"
281289
},
282-
283290
"gui_element": {
284291
"type": "string",
285292
"enum": [
@@ -302,7 +309,6 @@
302309
"Fileupload"
303310
]
304311
},
305-
306312
"gui_attributes": {
307313
"type": "object",
308314
"properties": {
@@ -333,7 +339,10 @@
333339
},
334340
"wrap": {
335341
"type": "string",
336-
"enum": ["soft", "hard"]
342+
"enum": [
343+
"soft",
344+
"hard"
345+
]
337346
},
338347
"max": {
339348
"type": "number"
@@ -343,23 +352,30 @@
343352
}
344353
}
345354
},
346-
347355
"comments": {
348356
"$ref": "#/definitions/comment"
349357
}
350358
},
351-
"required": ["name", "object", "labels", "gui_element"],
359+
"required": [
360+
"name",
361+
"object",
362+
"labels",
363+
"gui_element"
364+
],
352365
"additionalProperties": false
353366
},
354-
355-
"cardinality":{
367+
"cardinality": {
356368
"type": "object",
357369
"properties": {
358370
"propname": {
359371
"type": "string",
360372
"oneOf": [
361373
{
362-
"enum": ["Region", "isPartOf", "seqnum"]
374+
"enum": [
375+
"Region",
376+
"isPartOf",
377+
"seqnum"
378+
]
363379
},
364380
{
365381
"pattern": "^(([\\w-]*)?:([\\w ]+))$"
@@ -368,16 +384,23 @@
368384
},
369385
"cardinality": {
370386
"type": "string",
371-
"enum": ["1", "0-1", "1-n", "0-n"]
387+
"enum": [
388+
"1",
389+
"0-1",
390+
"1-n",
391+
"0-n"
392+
]
372393
},
373394
"gui_order": {
374395
"type": "integer"
375396
}
376397
},
377-
"required": ["propname", "cardinality"],
398+
"required": [
399+
"propname",
400+
"cardinality"
401+
],
378402
"additionalProperties": false
379403
},
380-
381404
"resource": {
382405
"type": "object",
383406
"properties": {
@@ -400,21 +423,29 @@
400423
}
401424
}
402425
},
403-
"required": ["name", "super", "labels", "cardinalities"],
426+
"required": [
427+
"name",
428+
"super",
429+
"labels",
430+
"cardinalities"
431+
],
404432
"additionalProperties": false
405433
}
406434
},
407-
408435
"type": "object",
409436
"properties": {
410437
"prefixes": {
411438
"type": "object",
412439
"patternProperties": {
413-
"^[\\w-]+$": { "format" : "uri" }
440+
"^[\\w-]+$": {
441+
"format": "uri"
442+
}
414443
},
415444
"additionalProperties": false
416445
},
417-
446+
"$schema": {
447+
"type": "string"
448+
},
418449
"project": {
419450
"type": "object",
420451
"properties": {
@@ -449,25 +480,32 @@
449480
"$ref": "#/definitions/user"
450481
}
451482
},
452-
453483
"lists": {
454484
"type": "array",
455485
"items": {
456486
"$ref": "#/definitions/node"
457487
}
458488
},
459-
460489
"ontologies": {
461490
"type": "array",
462491
"items": {
463492
"$ref": "#/definitions/ontology"
464493
}
465494
}
466495
},
467-
"required": ["shortcode", "shortname", "longname", "ontologies", "keywords"],
496+
"required": [
497+
"shortcode",
498+
"shortname",
499+
"longname",
500+
"ontologies",
501+
"keywords"
502+
],
468503
"additionalProperties": false
469504
}
470505
},
471-
"required": ["project"],
506+
"required": [
507+
"$schema",
508+
"project"
509+
],
472510
"additionalProperties": false
473511
}

knora/dsplib/utils/knora-schema-resources-only.json renamed to knora/dsplib/schemas/resources-only.json

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
{
2-
"$schema": "http://json-schema.org/draft-07/schema#",
3-
"$id": "http://knora.org/pyknora/ontology/knora-schema-resources-only.json",
4-
"title": "Knora JSON schema for resources only",
5-
"description": "JSON schema for resources used in Knora ontologies",
2+
"$schema": "https://json-schema.org/draft/2020-12/schema#",
3+
"$id": "https://dasch.swiss/schema/knora-schema-resources-only.json",
4+
"title": "JSON schema for resources used in DSP ontologies",
5+
"description": "JSON schema for the resources section used in DSP ontologies",
66
"definitions": {
77
"langstring": {
88
"anyOf": [

‎knora/dsplib/utils/excel_to_json_lists.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ def validate_list_with_schema(json_list: str) -> bool:
258258
259259
"""
260260
current_dir = os.path.dirname(os.path.realpath(__file__))
261-
with open(os.path.join(current_dir, 'knora-schema-lists-only.json')) as schema:
261+
with open(os.path.join(current_dir, '../schemas/lists-only.json')) as schema:
262262
list_schema = json.load(schema)
263263

264264
try:

‎knora/dsplib/utils/excel_to_json_resources.py‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ def validate_resources_with_schema(json_file: str) -> bool:
1717
1818
"""
1919
current_dir = os.path.dirname(os.path.realpath(__file__))
20-
with open(os.path.join(current_dir, 'knora-schema-resources-only.json')) as schema:
20+
with open(os.path.join(current_dir, '../schemas/resources-only.json')) as schema:
2121
resources_schema = json.load(schema)
2222

2323
try:

0 commit comments

Comments
 (0)