This GitHub Action validates OpenAPI (OAS) definition file using Swagger Editor.
It's handy for use-cases when OAS definition is maintained manually and is checked within the git. If modifications are made to the OAS definition you want to make sure that there are no errors introduced by modifications. Errors that would appear in Swagger Editor when the OAS definition would be pasted inside it.
If you're interested about technical design and evolution of this GitHub Action please read our release article.
Optional Defines URL of swagger-editor where definition
file is going to be validated. Default https://editor.swagger.io/
.
Required Defines path of OAS definition file that exists as a physical file in your repository.
Optional Defines path to JavaScript file containing predicate for determining if the error should be ignored or not.
There are two major use-cases of how to use this GitHub Action.
If you have access to the internet and don't mind that this action sends your OAS definition to https://editor.swagger.io/ for validation.
on: [push]
jobs:
test_swagger_editor_validator_remote:
runs-on: ubuntu-latest
name: Swagger Editor Validator Remote
steps:
- uses: actions/checkout@v2
- name: Validate OpenAPI definition
uses: swaggerexpert/swagger-editor-validate@v1
with:
definition-file: examples/openapi-2-0.yaml
If you want to maintain complete privacy and your OAS definition may contain sensitive information use the following workflow. The workflow uses swagger-editor docker image that runs as service of the workflow.
on: [push]
jobs:
test_swagger_editor_validator_service:
runs-on: ubuntu-latest
name: Swagger Editor Validator Service
# Service containers to run with `runner-job`
services:
# Label used to access the service container
swagger-editor:
# Docker Hub image
image: swaggerapi/swagger-editor
ports:
# Maps port 8080 on service container to the host 80
- 80:8080
steps:
- uses: actions/checkout@v2
- name: Validate OpenAPI definition
uses: swaggerexpert/swagger-editor-validate@v1
with:
swagger-editor-url: http://localhost/
definition-file: examples/openapi-2-0.yaml