You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+43-4Lines changed: 43 additions & 4 deletions
Original file line number
Diff line number
Diff line change
@@ -92,7 +92,7 @@ nodemon src/server
92
92
```
93
93
94
94
## Validation API
95
-
This validator exposes two endpoints that will accept POST requests: `/validate` and `/prototype`.
95
+
This validator exposes two endpoints that will accept POST requests: `/validate`for a single stand-alone schema and data object, and `/validateRefs` for a complex schema referencing other schemas and a related data object.
96
96
97
97
### /validate
98
98
The endpoint will expect the body to have the following structure:
@@ -139,7 +139,7 @@ Where the schema should be a valid json schema to validate the object against.
139
139
}
140
140
```
141
141
142
-
### /prototype
142
+
### /validateRefs
143
143
The endpoint will expect the body to have the following structure:
144
144
```js
145
145
{
@@ -247,10 +247,49 @@ Sending malformed JSON or a body with either the schema or the submittable missi
247
247
248
248
## Custom keywords
249
249
The AJV library supports the implementation of custom json schema keywords to address validation scenarios that go beyond what json schema can handle.
250
-
This validator has two custom keywords implemented, `isChildTermOf` and `isValidTerm`.
250
+
This validator has three custom keywords implemented, `graph_restriction`, `isChildTermOf` and `isValidTerm`.
251
+
252
+
### graph_restriction
253
+
254
+
This custom keyword *evaluates if an ontology term is child of another*. This keyword is applied to a string (CURIE) and **passes validation if the term is a child of the term defined in the schema**.
255
+
The keyword requires one or more **parent terms***(classes)* and **ontology ids***(ontologies)*, both of which should exist in [OLS - Ontology Lookup Service](https://www.ebi.ac.uk/ols).
256
+
257
+
This keyword works by doing an asynchronous call to the [OLS API](https://www.ebi.ac.uk/ols/api/) that will respond with the required information to know if a given term is child of another.
258
+
Being an async validation step, whenever used is a schema, the schema must have the flag: `"$async": true` in it's object root.
"description":"A term from the ontology [UBERON](https://www.ebi.ac.uk/ols/ontologies/uberon) for an organ or a cellular bodily fluid such as blood or lymph.",
271
+
"type":"string",
272
+
"graph_restriction": {
273
+
"ontologies": ["obo:hcao", "obo:uberon"],
274
+
"classes": ["UBERON:0000062","UBERON:0000179"],
275
+
"relations": ["rdfs:subClassOf"],
276
+
"direct":false,
277
+
"include_self":false
278
+
}
279
+
}
280
+
}
281
+
}
282
+
```
283
+
JSON object:
284
+
```js
285
+
{
286
+
"ontology":"UBERON:0000955"
287
+
}
288
+
```
289
+
251
290
252
291
### isChildTermOf
253
-
This custom keyword *evaluates if an ontology term is child of other*. This keyword is applied to a string (url) and **passes validation if the term is a child of the term defined in the schema**.
292
+
This custom keyword also *evaluates if an ontology term is child of another* and is a simplified version of the graph_restriction keyword. This keyword is applied to a string (url) and **passes validation if the term is a child of the term defined in the schema**.
254
293
The keyword requires the **parent term** and the **ontology id**, both of which should exist in [OLS - Ontology Lookup Service](https://www.ebi.ac.uk/ols).
255
294
256
295
This keyword works by doing an asynchronous call to the [OLS API](https://www.ebi.ac.uk/ols/api/) that will respond with the required information to know if a given term is child of another.
0 commit comments