Add swagger.yaml validation
- yamllint to ensure it is a valid YAML file - go-swagger validate to ensure it is a valid swagger file Signed-off-by: Ben Firshman <ben@firshman.co.uk>
This commit is contained in:
parent
e5e1c7feef
commit
5c4abd107a
4 changed files with 27 additions and 0 deletions
|
@ -194,6 +194,15 @@ RUN git clone https://github.com/docker/docker-py.git /docker-py \
|
||||||
&& git checkout -q $DOCKER_PY_COMMIT \
|
&& git checkout -q $DOCKER_PY_COMMIT \
|
||||||
&& pip install -r test-requirements.txt
|
&& pip install -r test-requirements.txt
|
||||||
|
|
||||||
|
# Install yamllint for validating swagger.yaml
|
||||||
|
RUN pip install yamllint==1.5.0
|
||||||
|
|
||||||
|
# Install go-swagger for validating swagger.yaml
|
||||||
|
ENV GO_SWAGGER_COMMIT c28258affb0b6251755d92489ef685af8d4ff3eb
|
||||||
|
RUN git clone https://github.com/go-swagger/go-swagger.git /go/src/github.com/go-swagger/go-swagger \
|
||||||
|
&& (cd /go/src/github.com/go-swagger/go-swagger && git checkout -q $GO_SWAGGER_COMMIT) \
|
||||||
|
&& go install -v github.com/go-swagger/go-swagger/cmd/swagger
|
||||||
|
|
||||||
# Set user.email so crosbymichael's in-container merge commits go smoothly
|
# Set user.email so crosbymichael's in-container merge commits go smoothly
|
||||||
RUN git config --global user.email 'docker-dummy@example.com'
|
RUN git config --global user.email 'docker-dummy@example.com'
|
||||||
|
|
||||||
|
|
4
hack/validate/.swagger-yamllint
Normal file
4
hack/validate/.swagger-yamllint
Normal file
|
@ -0,0 +1,4 @@
|
||||||
|
extends: default
|
||||||
|
rules:
|
||||||
|
document-start: disable
|
||||||
|
line-length: disable
|
|
@ -9,6 +9,7 @@ export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
. $SCRIPTDIR/gofmt
|
. $SCRIPTDIR/gofmt
|
||||||
. $SCRIPTDIR/lint
|
. $SCRIPTDIR/lint
|
||||||
. $SCRIPTDIR/pkg-imports
|
. $SCRIPTDIR/pkg-imports
|
||||||
|
. $SCRIPTDIR/swagger
|
||||||
. $SCRIPTDIR/test-imports
|
. $SCRIPTDIR/test-imports
|
||||||
. $SCRIPTDIR/toml
|
. $SCRIPTDIR/toml
|
||||||
. $SCRIPTDIR/vet
|
. $SCRIPTDIR/vet
|
||||||
|
|
13
hack/validate/swagger
Executable file
13
hack/validate/swagger
Executable file
|
@ -0,0 +1,13 @@
|
||||||
|
#!/bin/bash
|
||||||
|
set -e
|
||||||
|
export SCRIPTDIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
|
||||||
|
source "${SCRIPTDIR}/.validate"
|
||||||
|
|
||||||
|
IFS=$'\n'
|
||||||
|
files=( $(validate_diff --diff-filter=ACMR --name-only -- 'api/swagger.yaml' || true) )
|
||||||
|
unset IFS
|
||||||
|
|
||||||
|
if [ ${#files[@]} -gt 0 ]; then
|
||||||
|
yamllint -c ${SCRIPTDIR}/.swagger-yamllint api/swagger.yaml
|
||||||
|
swagger validate api/swagger.yaml
|
||||||
|
fi
|
Loading…
Reference in a new issue