Git Product home page Git Product logo

json-validator-service's Introduction

JSON Validator Service

This service implement an API to upload JSON Schemas and validate JSON documents againts the schema.

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`

License

This code is licensed under the MIT License, see the LICENSE file for details.

System requirements

  • Java 11
  • PostgreSQL 11 (or higher)

Developer guide

For development and testing you need to install sbt. Please see CONTRIBUTING.md for details how to to contribute to the project.

During development you can start (and restart) the application via the reStart sbt task provided by the sbt-revolver plugin.

Tests

Tests are included in the project. You can run them via the appropriate sbt tasks test and IntegrationTest/test. The latter will execute the integration tests. Be aware that the integration tests might need a working database.

Running local guide

Start the local postgres with:

docker-compose up

Then run the application with

sbt run

The service will start listening on port 8081 by default.

Useful commands:

  • To upload a schema
curl http://localhost:8081/schema/config-schema -X POST -d @./examples/config-schema.json
  • To download a schema
curl http://localhost:8081/schema/config-schema -X GET
  • To test validation successful
curl http://localhost:8081/validate/config-schema -X POST -d @./examples/valid-document.json
  • To test validation errors
curl http://localhost:8081/validate/config-schema -X POST -d @./examples/invalid-document.json

Open API

There's also swagger running on:

http://localhost:8081/docs

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.