https://github.com/usabilla/openapi3-validator
Validator for OpenAPI v3 specs
https://github.com/usabilla/openapi3-validator
api automation open-source openapi tooling validation
Last synced: 11 months ago
JSON representation
Validator for OpenAPI v3 specs
- Host: GitHub
- URL: https://github.com/usabilla/openapi3-validator
- Owner: usabilla
- License: mit
- Created: 2017-10-09T11:46:40.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2022-08-26T13:27:00.000Z (over 3 years ago)
- Last Synced: 2024-04-14T23:59:13.291Z (almost 2 years ago)
- Topics: api, automation, open-source, openapi, tooling, validation
- Language: Python
- Homepage:
- Size: 47.9 KB
- Stars: 11
- Watchers: 7
- Forks: 3
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# OpenAPI v3 Validator
This is essentially a docker image that runs
https://github.com/p1c2u/openapi-spec-validator and can be plugged into CI
servers or even be used during development.
It's still being improved, but it already helps us to ensure that our API specs
are actually following the [OpenAPI
specification](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md).
## Usage
First you need to pull the image from [Docker Hub](https://hub.docker.com):
```sh
docker pull usabillabv/openapi3-validator
```
The validator can be run with the following arguments:
```sh
usage: main.py [-h] (-f FILE | -u URL | -p LOOKUP_PATH) [-n SPEC_NAME] [-i]
Open API spec validation tool
options:
-h, --help show this help message and exit
-f FILE, --file FILE full path to open api spec file, multiple arguments are supported
-u URL, --url URL uri to open api spec, multiple arguments are supported
-p LOOKUP_PATH, --lookup-path LOOKUP_PATH
open api spec files lookup path
-n SPEC_NAME, --spec-name SPEC_NAME
open api spec file name, multiple arguments are supported. Used in conjunction with --lookup-path option. Default value:
*openapi.yml,*openapi.yaml
-i, --ignore-missing-spec
do not fail processing if spec file is missing. Used in conjunction with --lookup-path option.
```
Then you can use it to validate specs available on a shared volume.
### Validate spec file(s) by the full path
```sh
$ docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator --file --file
```
or
```sh
$ docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator -f -f
```
### Lookup and validate spec file(s):
The tool will search for _openapi.yaml_ spec file by default in the provided path tree:
```sh
$ docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator --path /project
```
or you can provide specific spec file name(s) for lookup with a support of wildcards:
```sh
$ docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator --path /project --spec-name *-open-api-*.yaml --spec-name other-file.yaml
```
or
```sh
$ docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator -p /project -n *-open-api-*.yaml -n other-file.yaml
```
### Validate spec file via url(s)
```sh
$ docker run -it --rm usabillabv/openapi3-validator --url --url
```
or
```sh
$ docker run -it --rm usabillabv/openapi3-validator -u
```
Optionally you can create an alias and just use it, like:
```sh
$ alias openapi3-validate='docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator'
$ openapi3-validate
```
## Legacy mode usage
Validate specs available on a shared volume:
```sh
$ docker run -it --rm -v $(pwd):/project -w /project usabillabv/openapi3-validator
```
Or available via an HTTP(s) endpoint:
```sh
$ docker run -it --rm usabillabv/openapi3-validator
```