Skip to content

A REST-service for validating JSON documents against JSON Schemas

License

Notifications You must be signed in to change notification settings

devesh-shetty/json-validation-service

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

JSON validation service

A REST-service for validating JSON documents against JSON Schemas.

How to run the project?

  • Clone the project.
  • cd json-validation-service
  • sbt 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.

About

A REST-service for validating JSON documents against JSON Schemas

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages