A REST-service for validating JSON documents against JSON Schemas.
- Clone the project.
cd json-validation-servicesbt run
You could use curl or any other tool to interact with the service.
You could upload the JSON schema using curl http://localhost/schema/config-schema -X POST -d @config-schema.json.
config-schema.json
{
"$schema": "http://json-schema.org/draft-04/schema#",
"type": "object",
"properties": {
"source": {
"type": "string"
},
"destination": {
"type": "string"
},
"timeout": {
"type": "integer",
"minimum": 0,
"maximum": 32767
},
"chunks": {
"type": "object",
"properties": {
"size": {
"type": "integer"
},
"number": {
"type": "integer"
}
},
"required": ["size"]
}
},
"required": ["source", "destination"]
}
Download an existing schema by schemaId using curl http://localhost/schema/config-schema
You could validate a JSON document against an existing schema id using curl http://localhost/validate/config-schema -X POST -d @config.json
config.json
{
"source": "/home/alice/image.iso",
"destination": "/mnt/storage",
"timeout": null,
"chunks": {
"size": 1024,
"number": null
}
}
The server cleans the uploaded JSON document to remove keys for which the value is null.