EpiDoc Validator API provides an API interface for the EpiDoc Validator JRuby library.
It accepts EpiDoc XML and returns JSON containing any errors.
docker-compose build
docker-compose up
Include perseidsproject/epi-doc-validator-api
as one of your services in docker-compose.yml
.
The simplest version would be:
version: '3'
services:
validator:
image: perseidsproject/epi-doc-validator-api:v1.0.1
ports:
- "1600:1600"
The port can be customized using the PORT
environment variable.
For example, if you want to run on port 3000:
version: '3'
services:
validator:
image: perseidsproject/epi-doc-validator-api:v1.0.1
environment:
- PORT=3000
ports:
- "3000:3000"
(See project on Docker Hub.)
Requirements:
- JRuby (~9.2.11)
- Bundler
bundle install
bundle exec ruby app.rb
The /validate
endpoint accepts a POST request with the EpiDoc XML to be validated.
It returns a JSON array of errors. If there are no errors, it returns an empty
array. By default, it will validate against the latest version of the schema.
To validate against a different version, add that version to the end of the path:
e.g. /validate/9.1
.
The /versions
endpoint accepts a GET request and returns a JSON array of
accepted versions.
curl -X POST -d '@./spec/fixtures/files/valid_doc.xml' http://localhost:1600/validate
[]
curl -X POST -d '@./spec/fixtures/files/invalid_doc.xml' http://localhost:1600/validate
[
"-1:-1: ERROR: unknown element \"incorrect\" from namespace \"http://www.tei-c.org/ns/1.0\""
]
curl -X POST -d '@./spec/fixtures/files/valid_9.xml' http://localhost:1600/validate/8.23
[
"-1:-1: ERROR: attribute \"toWhom\" not allowed at this point; ignored"
]
curl http://localhost:1600/versions
[
"8",
"8-rc1",
"8.2"
...
"dev",
"latest"
]