Skip to content

Instantly share code, notes, and snippets.

@mcupak
Last active February 20, 2019 20:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mcupak/f64da7efad1af89dbaa0529ec2a36417 to your computer and use it in GitHub Desktop.
Save mcupak/f64da7efad1af89dbaa0529ec2a36417 to your computer and use it in GitHub Desktop.
language: java
dist: trusty
sudo: false
jdk:
- openjdk8
env:
- GH_URL=https://raw.githubusercontent.com VALIDATOR_URL=http://localhost:8080/validator/debug?url FILE_TO_VALIDATE=openapi.yaml URL_TO_VALIDATE=$GH_URL/${TRAVIS_PULL_REQUEST_SLUG:-$TRAVIS_REPO_SLUG}/${TRAVIS_PULL_REQUEST_BRANCH:-$TRAVIS_BRANCH}/$FILE_TO_VALIDATE
before_install:
# Build and start validator-badge. This setup will not be needed once the online version of validator-badge supports OAS 3.0. Until then we'll need to set up a local version.
- git clone --branch=v2.0.0 https://github.com/swagger-api/validator-badge.git
- cd validator-badge
- mvn package -q -DskipTests=true -Dmaven.javadoc.skip=true -B -V jetty:run &
- cd ..
- sleep 60
script:
# validate
- echo "Validating $URL_TO_VALIDATE:"
- VALIDATION_OUTPUT=`curl -sS "$VALIDATOR_URL=$URL_TO_VALIDATE"`
# print validation errors
- echo $VALIDATION_OUTPUT
# check if the validation output ignoring warnings is an empty array
- VALIDATION_ERROR_COUNT=`echo "$VALIDATION_OUTPUT" |jq -c '.schemaValidationMessages // [] | map(select(.level != "warning"))' |jq length`
- test "$VALIDATION_ERROR_COUNT" == 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment