A cli app that implements HTTP service for validating JSON entities by given JSON Schema.
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Permalink
Type Name Latest commit message Commit time
Failed to load latest commit information.
_fixtures
ci-scripts
.editorconfig
.gitattributes
.gitignore
.travis.yml
README.md
VERSION
build.sh
e2e-test-configurations.sh
e2e-test-registrations.sh
e2e-test.sh
install.sh
lint-go.sh
local-pipeline.sh
main.go
start.sh
stop.sh

README.md

contract-validator Build Status Go Report Card

A cli app that implements HTTP service for validating JSON entities by given JSON Schema.

The binary is compiled for all Linux distributions which rely on amd64 process-architecture. It listens on the TCP network address and then calls Serve with handler to handle requests on incoming connections.

Download & Run

Download latest release

Explorer the service

./contract-validator --help

Usage of ./contract-validator:
  -jsonSchema string
        absolute path to JSON schema file (default "./")
  -port string
        port number to the host (default "6565")
  -version
        prints current version

Start the service (default port is 6565)

./contract-validator -port=6565 -jsonSchema=file://${PWD}/_fixtures/product-schema.json

Validate JSON data

curl -X POST "http://localhost:6565/validate" -d "{"id":1,"name":"A green door","price": 12.50,"tags": ["home", "green"]}"

For example you can use curl to execute an request to http://localhost:6565/validate using HTTP request method POST and an JSON data as request body.

Possible responses are:

  • 400 Bad Request: if JSON data is empty.
  • 422 Unprocessable Entity: if JSON schema or data are not valid. A list of vulnerabilities is responded within response body.
  • 200 OK: if JSON data is valid.

Development

For developing and contributing you need Golang 1.9.1 installed.