General idea behind this API implementation is to provide an API as a service based on the awesome spectral schema linter and it´s nodeJS based SDK.
The API is build on top of the @stoplight/spectral-core SDK for nodeJS to execute API validations that follow the "Open API Specification" pattern. Spectral itself is Open Source and able to validate any json or yaml defined schemas with dedicated rulesets, while playing it´s strengths definitely in validation of OpenAPI Specs.
First make sure to have installed the following OS dependencies for development:
- Docker Desktop
- node LTS
- IDE of your choice like Visual Studio Code
Download all local development dependencies via (just for code completion, code will be executed in docker):
$ npm install
Build the Docker-Compose based local dev environment
$ docker-compose build --no-cache
Per default the API runs in "debug" mode during local development.
You should always start the API using Docker-Compose.
$ docker-compose build
$ docker-compose up (-d)
$ docker-compose -f docker-compose-prod-sim.yml build
$ docker-compose -f docker-compose-prod-sim.yml up (-d)
The API downloads a dedicated spectral ruleset behind a configurable url as a base for further migration of this files into JavaScript. No need to redeploy the application after changing your spectral ruleset, restart is enough and you get served with your recently updated and published ruleset.
Without changing the download url the API uses SchwarzIT API Rules as default for API linting.
# unit tests
$ npm run test
# e2e tests
$ npm run test:e2e
# test coverage
$ npm run test:cov