Skip to content

An http server to validate json documents against a schema

License

Notifications You must be signed in to change notification settings

istreeter/json-validator

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Json Schema Validator

An http server to validate json documents against a schema.

Run the server

You can launch the server with sbt. The server will listen on port 8080:

sbt run

Endpoints

POST    /schema/SCHEMAID        - Upload a JSON Schema with unique `SCHEMAID`
GET     /schema/SCHEMAID        - Download a JSON Schema with unique `SCHEMAID`

POST    /validate/SCHEMAID      - Validate a JSON document against the JSON Schema identified by `SCHEMAID`

Examples

Create a new schema

curl -XPOST http://localhost:8080/schema/my-schema -d '
  {
    "$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"]
  }'

Check your schema exists

curl http://localhost:8080/schema/my-schema

Validate a document against your schema

curl -XPOST http://localhost:8080/validate/my-schema -d '
  {
    "source": "/home/alice/image.iso",
    "destination": "/mnt/storage",
    "timeout": null,
    "chunks": {
      "size": 1024,
      "number": null
    }
  }
'

About

An http server to validate json documents against a schema

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages