https://github.com/gjerokrsteski/go-contract-validator
A cli app that implements HTTP service for validating JSON entities by given JSON Schema.
https://github.com/gjerokrsteski/go-contract-validator
go golang http-server json-parser json-schema microservice validator
Last synced: 2 months ago
JSON representation
A cli app that implements HTTP service for validating JSON entities by given JSON Schema.
- Host: GitHub
- URL: https://github.com/gjerokrsteski/go-contract-validator
- Owner: gjerokrsteski
- Created: 2018-10-17T18:41:24.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2018-10-28T20:26:26.000Z (over 6 years ago)
- Last Synced: 2025-01-21T01:12:49.551Z (4 months ago)
- Topics: go, golang, http-server, json-parser, json-schema, microservice, validator
- Language: Shell
- Homepage:
- Size: 42 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# contract-validator [](https://travis-ci.org/gjerokrsteski/go-contract-validator) [](https://goreportcard.com/report/github.com/gjerokrsteski/go-contract-validator)
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](https://github.com/gjerokrsteski/go-contract-validator/releases)
## Explorer the service
```
./contract-validator --helpUsage 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](https://golang.org/) installed.