Skip to content

gjerokrsteski/go-contract-validator

Repository files navigation

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.

About

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

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published