From 9047fb282718da5241e09b1147fa6e5ddbbac579 Mon Sep 17 00:00:00 2001 From: Calum Macdonald Date: Fri, 16 Feb 2024 16:11:43 +0000 Subject: [PATCH] update validation page --- docs/metadata-validation.md | 201 ++++++++++++++++++------------------ 1 file changed, 102 insertions(+), 99 deletions(-) diff --git a/docs/metadata-validation.md b/docs/metadata-validation.md index a820bb2..11e46fb 100644 --- a/docs/metadata-validation.md +++ b/docs/metadata-validation.md @@ -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 ) @@ -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 '{}' ``` -=== "CURL" - +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.