This action uses the swagger-cli to validate a given swagger file(s).
Required The name of the file(s) to validate. Can be a single file path or a list of files.
See example for suggested command for finding all files ending in "openapi.yaml".
Optional Defaults to true.
For use when passing in a list of files that are space separated.
Validating file: example.openapi.yaml
example.openapi.yaml is valid
List of files that failed to validate.
List of valid files.
uses: mbowman100/swagger-validator-action@master
with:
files: |
example.openapi.yaml
on: push
name: Validate API swagger documentation
jobs:
validate:
runs-on: ubuntu-latest
steps:
- name: Get OpenAPI files
id: getfiles
uses: actions/checkout@v2
run: |
# Using github env (newline separated file list)
echo 'FILE_LIST<<EOF' >> $GITHUB_ENV
find lib -type f -iname "*openapi.yaml" >> $GITHUB_ENV
echo 'EOF' >> $GITHUB_ENV
# Using step output (space separated file list)
FILES="$(find lib -type f -iname "*openapi.yaml")"
echo "::set-output name=file_list::$FILES"
- name: swagger-validator
uses: mbowman100/swagger-validator-action@master
if: env.FILE_COUNT != '0' # Comment out if you want it to fail if no files found
with:
files: ${{ env.FILE_LIST }}
# files: ${{ steps.getfiles.outputs.file_list }} # For if you're using output