Skip to content

Commit 504b3e8

Browse files
committed
Extend documentation
1 parent 06a352a commit 504b3e8

File tree

3 files changed

+29
-14
lines changed

3 files changed

+29
-14
lines changed

README.md

Lines changed: 26 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -135,17 +135,36 @@ The knowledge graph is organized in individual named graphs. URIs of most of the
135135

136136
### Validation
137137

138-
Received data in RDF or JSKOS format must be syntactically valid. Additional validation has not been implemented yet.
138+
Received data in RDF or JSKOS format must be syntactically valid. Additional constraints are being implemented. Validation errors are returned in [Data Validation Error Format]. For instance an error like this is emitted when JSON field `url` is no valid URL:
139139

140-
Validation errors are returned in [Data Validation Error Format].
140+
~~~json
141+
{
142+
"message": "'http:/example.org/' does not match '^https?://'",
143+
"position" {
144+
"jsonpointer": "/url"
145+
}
146+
}
147+
~~~
148+
149+
**JSON metadata** to describe collections and mapping sources is validated with JSON Schemas [collection-schema.json] and [mappings-schema.json], respectively.
150+
151+
**JSKOS data** (for terminologies and mappings) is not validated yet (see [open issue](https://github.com/nfdi4objects/n4o-graph-importer/issues/50)).
152+
153+
**RDF data** is allowed to contain any absolute IRI references matching the regular expression `` ^[a-z][a-z0-9+.-]*:[^<>"{}|^`\\\x00-\x20]*$ ``. This includes some IRI references invalid in theory but supported by most RDF software in practice. Additional constraints on RDF data do not result in validation errors but malformed triples are filtered out and result in collected as part of [report] files.
141154

142155
### Filtering
143156

144157
[filtering]: #filtering
145158

146-
RDF data is filtered depending on kind of data and configuration.
159+
RDF data is filtered depending on kind of data and configuration. Triples (aka RDF statements) matching the following criteria are filtered out:
160+
161+
- Triples with relative IRI references and local `file:` URIs
162+
163+
- Statements about registered terminologies in collection data
147164

148-
*Filtering is still being worked on and not fully documented yet.*
165+
- ... *(RDF filtering is still being worked on and not fully documented yet)*
166+
167+
Filtered RDF triples are collected as part of reports.
149168

150169
### Reports
151170

@@ -348,7 +367,9 @@ Return the list of registered mapping sources.
348367

349368
#### GET /mappings/schema.json
350369

351-
Return the [mapping sources schema](lib/mappings-schema.json) used to validate mapping sources.
370+
[mappings-schema.json]: lib/mappings-schema.json)
371+
372+
Return the mapping sources schema [mappings-schema.json] used to validate mapping sources.
352373

353374
#### GET /mappings/properties.json
354375

tests/test_api.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,6 @@ def expect_error(client, method, path, json=None, error=None, code=400):
5858
error = {"message": error}
5959
error["code"] = code
6060
res = res.get_json()
61-
# print(res)
6261
for key in error:
6362
assert res.get(key, None) == error[key]
6463

@@ -95,6 +94,9 @@ def test_validation(client):
9594
fail("PUT", "/collection/1", [], "expected JSON object")
9695
fail("PUT", "/collection/1", {"uri": "https://graph.nfdi4objects.net/collection/2"},
9796
"URI https://graph.nfdi4objects.net/collection/2 and id 1 don't match")
97+
fail("PUT", "/collection/1", {"url": "http:/example.org/"}, {
98+
'message': "'http:/example.org/' does not match '^https?://'",
99+
'position': {'jsonpointer': '/url'}})
98100
fail("PUT", "/collection/1", {"id": "2"}, "ids 1 and 2 don't match")
99101

100102
fail("PUT", "/collection/", {}, "expected list of collection")

tests/test_validate.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,6 @@
11
from lib import ValidationError, validateJSON
22

33

4-
def validateIRI():
5-
pass
6-
7-
8-
def test_validateiri():
9-
pass
10-
11-
124
def test_jsonschema():
135
data = { # Example from JSON Pointer RFC
146
"foo": ["bar"],

0 commit comments

Comments
 (0)