OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0.0 spec validator
Project description
OpenAPI Spec validator
About
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0.0 specification. The validator aims to check for full compliance with the Specification.
Installation
$ pip install openapi-spec-validator
Usage
Command Line Interface
Straight forward way:
$ openapi-spec-validator some.yaml
pipes way:
$ cat some.yaml | openapi-spec-validator -
docker way:
$ docker run -v path/to/some.yaml:/some.yaml --rm p1c2u/openapi-spec-validator /some.yaml
or more pythonic way:
$ python -m openapi_spec_validator some.yaml
Examples
Validate spec:
from openapi_spec_validator import validate_spec
validate_spec(spec_dict)
Add spec_url
to validate spec with relative files:
from openapi_spec_validator import validate_spec
validate_spec(spec_dict, spec_url='file:///path/to/spec/openapi.yaml')
You can also validate spec from url:
from openapi_spec_validator import validate_spec_url
validate_spec_url('http://example.com/openapi.json')
If you want to iterate through validation errors:
from openapi_spec_validator import openapi_v3_spec_validator
errors_iterator = openapi_v3_spec_validator.iter_errors(spec)
Related projects
- openapi-core is a Python library that adds client-side and server-side support for the OpenAPI.
License
Copyright (c) 2017, Artur Maciag, All rights reserved. Apache v2
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
Close
Hashes for openapi-spec-validator-0.2.9.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 79381a69b33423ee400ae1624a461dae7725e450e2e306e32f2dd8d16a4d85cb |
|
MD5 | 3589c9cf40497849fc3a0160f0fe0213 |
|
BLAKE2b-256 | 879d016a76d6949287b3860f337faae745e5f77563a60b241d9c472305a721a1 |
Close
Hashes for openapi_spec_validator-0.2.9-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | ec1b01a00e20955a527358886991ae34b4b791b253027ee9f7df5f84b59d91c7 |
|
MD5 | 2dfdc4bd49286b95cd2020d0e2289f46 |
|
BLAKE2b-256 | 104cb2aece7b557dc79f02537e857510f277afac44825b13d331fbfc259ea96b |
Close
Hashes for openapi_spec_validator-0.2.9-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6dd75e50c94f1bb454d0e374a56418e7e06a07affb2c7f1df88564c5d728dac3 |
|
MD5 | 4ed6b7ecd211c52e65c446c76297fe87 |
|
BLAKE2b-256 | 87d51e8deaaebf29672e2df4fc5244b56d2fefe01a6c7bdd6b2990cfefcdae9a |