No project description provided
Project description
# OpenAPI Spec validator
[![Package Version](https://img.shields.io/pypi/v/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
[![Build Status](https://travis-ci.org/p1c2u/openapi-spec-validator.svg?branch=master)](https://travis-ci.org/p1c2u/openapi-spec-validator)
[![Code Coverage](https://img.shields.io/codecov/c/github/p1c2u/openapi-spec-validator/master.svg?style=flat)](https://codecov.io/github/p1c2u/openapi-spec-validator?branch=master)
[![PyPI Version](https://img.shields.io/pypi/pyversions/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
[![PyPI Format](https://img.shields.io/pypi/format/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
[![PyPI Status](https://img.shields.io/pypi/status/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
## About
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against the [OpenAPI 2.0 (aka Swagger)](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and [OpenAPI 3.0.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) 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:
```bash
$ openapi-spec-validator some.yaml
```
or more pythonic way:
```bash
$ python -m openapi_spec_validator some.yaml
```
### Examples
Validate spec:
```python
from openapi_spec_validator import validate_spec
validate_spec(spec_dict)
```
Add `spec_url` to validate spec with relative files:
```python
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:
```python
from openapi_spec_validator import validate_spec_url
validate_spec_url('http://example.com/openapi.json')
```
If you want to iterate through validation errors:
```python
from openapi_spec_validator import openapi_v3_spec_validator
errors_iterator = openapi_v3_spec_validator.iter_errors(spec)
```
## Security Note
PyYAML, a requirement of this project, has a
[security vulnerability](https://nvd.nist.gov/vuln/detail/CVE-2017-18342)
in the default implementation of `yaml.load()`, which allows execution
of arbitrary code while loading a target file or stream. OpenAPI Spec
Validator uses a safe loader to ensure that only Python objects
marked as safe can be executed. Thus, you are not exposed to this
vulnerability by using this package.
If you use `PyYAML` directly, be sure to use `yaml.safe_load()` to
avoid inadvertantly exposing youself to potentially malicous data. The
[PyYAML docs](https://pyyaml.org/wiki/PyYAMLDocumentation#loading-yaml)
describe this issue in detail.
## Related projects
* [openapi-core](https://github.com/p1c2u/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
[![Package Version](https://img.shields.io/pypi/v/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
[![Build Status](https://travis-ci.org/p1c2u/openapi-spec-validator.svg?branch=master)](https://travis-ci.org/p1c2u/openapi-spec-validator)
[![Code Coverage](https://img.shields.io/codecov/c/github/p1c2u/openapi-spec-validator/master.svg?style=flat)](https://codecov.io/github/p1c2u/openapi-spec-validator?branch=master)
[![PyPI Version](https://img.shields.io/pypi/pyversions/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
[![PyPI Format](https://img.shields.io/pypi/format/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
[![PyPI Status](https://img.shields.io/pypi/status/openapi-spec-validator.svg)](https://pypi.python.org/pypi/openapi-spec-validator)
## About
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against the [OpenAPI 2.0 (aka Swagger)](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/2.0.md) and [OpenAPI 3.0.0](https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md) 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:
```bash
$ openapi-spec-validator some.yaml
```
or more pythonic way:
```bash
$ python -m openapi_spec_validator some.yaml
```
### Examples
Validate spec:
```python
from openapi_spec_validator import validate_spec
validate_spec(spec_dict)
```
Add `spec_url` to validate spec with relative files:
```python
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:
```python
from openapi_spec_validator import validate_spec_url
validate_spec_url('http://example.com/openapi.json')
```
If you want to iterate through validation errors:
```python
from openapi_spec_validator import openapi_v3_spec_validator
errors_iterator = openapi_v3_spec_validator.iter_errors(spec)
```
## Security Note
PyYAML, a requirement of this project, has a
[security vulnerability](https://nvd.nist.gov/vuln/detail/CVE-2017-18342)
in the default implementation of `yaml.load()`, which allows execution
of arbitrary code while loading a target file or stream. OpenAPI Spec
Validator uses a safe loader to ensure that only Python objects
marked as safe can be executed. Thus, you are not exposed to this
vulnerability by using this package.
If you use `PyYAML` directly, be sure to use `yaml.safe_load()` to
avoid inadvertantly exposing youself to potentially malicous data. The
[PyYAML docs](https://pyyaml.org/wiki/PyYAMLDocumentation#loading-yaml)
describe this issue in detail.
## Related projects
* [openapi-core](https://github.com/p1c2u/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.6.tar.gz
Algorithm | Hash digest | |
---|---|---|
SHA256 | 3b078fb29805dc34fec20db6b81d0da9417edbccf6fb90e4cdfae7a971822872 |
|
MD5 | 0ad866e1f9d06dab1e4df32c158afb24 |
|
BLAKE2b-256 | 74fffc1f5ce01556b2597cb476c9f350d65e3e993af8c57b19a42b0cf8b8c1cc |
Close
Hashes for openapi_spec_validator-0.2.6-py3-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | 72d3f7a5de49b9753f6a4ef7c6b835c4e6dcd4cc7e24a35dd13b86a6365439ec |
|
MD5 | e26bf254fe68af2c465186e9b0584eb5 |
|
BLAKE2b-256 | 0957d66ecb940d656f6762efa0216317d3b97b7dd0e2b2e07c671c7b1de5a2dc |
Close
Hashes for openapi_spec_validator-0.2.6-py2-none-any.whl
Algorithm | Hash digest | |
---|---|---|
SHA256 | bb8596371e08ddcc54b69adb24ff9efa905b29bfda6826d03d6162f3c2793a1e |
|
MD5 | 606dd58531231c2d14e4aa5e3a8381a8 |
|
BLAKE2b-256 | 4f0ee070b781cce32ddc698cd84b658af55a5b7f8b37b3855cfa869a12969430 |