Skip to content

Commit

Permalink
update validation page
Browse files Browse the repository at this point in the history
  • Loading branch information
calmacx committed Feb 16, 2024
1 parent ba0d112 commit 9047fb2
Showing 1 changed file with 102 additions and 99 deletions.
201 changes: 102 additions & 99 deletions docs/metadata-validation.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,16 +7,13 @@ Once you have created your metadata, for example for the HDRUK schema `2.1.2`, y
Using python `requests`
``` python

import requests
import json

metadata = json.load(open("example-hdruk212.json"))

headers = {
"Content-Type": "application/json",
}

traser_uri = "http://localhost:8002"
traser_uri = "https://hdr-gateway-traser-dev-qmnkcg5qjq-ew.a.run.app"
response = requests.post(
f"{traser_uri}/find?with_errors=1", headers=headers, json=metadata
)
Expand All @@ -25,103 +22,109 @@ Once you have created your metadata, for example for the HDRUK schema `2.1.2`, y

```

Responds with:
```
[
{
"name": "HDRUK",
"version": "2.1.2",
"matches": true,
"errors": null
},
{
"name": "HDRUK",
"version": "2.1.3",
"matches": false,
"errors": [
{
"instancePath": "/provenance/temporal",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "publishingFrequency"
},
"message": "must have required property 'publishingFrequency'"
},
{
"instancePath": "/provenance",
"schemaPath": "#/properties/provenance/anyOf/1/type",
"keyword": "type",
"params": {
"type": "null"
},
"message": "must be null"
},
{
"instancePath": "/provenance",
"schemaPath": "#/properties/provenance/anyOf",
"keyword": "anyOf",
"params": {},
"message": "must match a schema in anyOf"
}
]
},
....
{
"name": "HDRUK",
"version": "2.2.0",
"matches": false,
"errors": [
{
"instancePath": "/summary",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "datasetType"
},
"message": "must have required property 'datasetType'"
}
]
},
{
"name": "GWDM",
"version": "1.0",
"matches": false,
"errors": [
{
"instancePath": "",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "required"
},
"message": "must have required property 'required'"
}
]
},
...
{
"name": "SchemaOrg",
"version": "BioSchema",
"matches": false,
"errors": [
{
"instancePath": "",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "name"
},
"message": "must have required property 'name'"
}
]
},
...
]
=== "CURL"

```bash
curl --location 'http://localhost:3001/find?with_errors=1' \
--header 'Content-Type: application/json' \
--data-raw '{<data>}'
```

=== "CURL"
<to add>
Responds with:

```
[
{
"name": "HDRUK",
"version": "2.1.2",
"matches": true,
"errors": null
},
{
"name": "HDRUK",
"version": "2.1.3",
"matches": false,
"errors": [
{
"instancePath": "/provenance/temporal",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "publishingFrequency"
},
"message": "must have required property 'publishingFrequency'"
},
{
"instancePath": "/provenance",
"schemaPath": "#/properties/provenance/anyOf/1/type",
"keyword": "type",
"params": {
"type": "null"
},
"message": "must be null"
},
{
"instancePath": "/provenance",
"schemaPath": "#/properties/provenance/anyOf",
"keyword": "anyOf",
"params": {},
"message": "must match a schema in anyOf"
}
]
},
....
{
"name": "HDRUK",
"version": "2.2.0",
"matches": false,
"errors": [
{
"instancePath": "/summary",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "datasetType"
},
"message": "must have required property 'datasetType'"
}
]
},
{
"name": "GWDM",
"version": "1.0",
"matches": false,
"errors": [
{
"instancePath": "",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "required"
},
"message": "must have required property 'required'"
}
]
},
...
{
"name": "SchemaOrg",
"version": "BioSchema",
"matches": false,
"errors": [
{
"instancePath": "",
"schemaPath": "#/required",
"keyword": "required",
"params": {
"missingProperty": "name"
},
"message": "must have required property 'name'"
}
]
},
...
]
```

You can use the route `validate` instead of `find` to validate a payload against an expected schema.

Expand Down

0 comments on commit 9047fb2

Please sign in to comment.