Skip to main content

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

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

openapi-spec-validator-0.2.6.tar.gz (22.8 kB view details)

Uploaded Source

Built Distributions

openapi_spec_validator-0.2.6-py3-none-any.whl (23.3 kB view details)

Uploaded Python 3

openapi_spec_validator-0.2.6-py2-none-any.whl (23.4 kB view details)

Uploaded Python 2

File details

Details for the file openapi-spec-validator-0.2.6.tar.gz.

File metadata

  • Download URL: openapi-spec-validator-0.2.6.tar.gz
  • Upload date:
  • Size: 22.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.8.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14

File hashes

Hashes for openapi-spec-validator-0.2.6.tar.gz
Algorithm Hash digest
SHA256 3b078fb29805dc34fec20db6b81d0da9417edbccf6fb90e4cdfae7a971822872
MD5 0ad866e1f9d06dab1e4df32c158afb24
BLAKE2b-256 74fffc1f5ce01556b2597cb476c9f350d65e3e993af8c57b19a42b0cf8b8c1cc

See more details on using hashes here.

File details

Details for the file openapi_spec_validator-0.2.6-py3-none-any.whl.

File metadata

  • Download URL: openapi_spec_validator-0.2.6-py3-none-any.whl
  • Upload date:
  • Size: 23.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.8.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14

File hashes

Hashes for openapi_spec_validator-0.2.6-py3-none-any.whl
Algorithm Hash digest
SHA256 72d3f7a5de49b9753f6a4ef7c6b835c4e6dcd4cc7e24a35dd13b86a6365439ec
MD5 e26bf254fe68af2c465186e9b0584eb5
BLAKE2b-256 0957d66ecb940d656f6762efa0216317d3b97b7dd0e2b2e07c671c7b1de5a2dc

See more details on using hashes here.

File details

Details for the file openapi_spec_validator-0.2.6-py2-none-any.whl.

File metadata

  • Download URL: openapi_spec_validator-0.2.6-py2-none-any.whl
  • Upload date:
  • Size: 23.4 kB
  • Tags: Python 2
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/1.11.0 pkginfo/1.4.2 requests/2.18.4 setuptools/36.8.0 requests-toolbelt/0.8.0 tqdm/4.23.4 CPython/2.7.14

File hashes

Hashes for openapi_spec_validator-0.2.6-py2-none-any.whl
Algorithm Hash digest
SHA256 bb8596371e08ddcc54b69adb24ff9efa905b29bfda6826d03d6162f3c2793a1e
MD5 606dd58531231c2d14e4aa5e3a8381a8
BLAKE2b-256 4f0ee070b781cce32ddc698cd84b658af55a5b7f8b37b3855cfa869a12969430

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page