Skip to main content

OpenAPI 2.0 (aka Swagger) and OpenAPI 3 spec validator

Project description

https://img.shields.io/docker/v/p1c2u/openapi-spec-validator.svg?color=%23086DD7&label=docker%20hub&sort=semver https://img.shields.io/pypi/v/openapi-spec-validator.svg https://travis-ci.org/python-openapi/openapi-spec-validator.svg?branch=master https://img.shields.io/codecov/c/github/python-openapi/openapi-spec-validator/master.svg?style=flat https://img.shields.io/pypi/pyversions/openapi-spec-validator.svg https://img.shields.io/pypi/format/openapi-spec-validator.svg https://img.shields.io/pypi/status/openapi-spec-validator.svg

About

OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger), OpenAPI 3.0 and OpenAPI 3.1 specification. The validator aims to check for full compliance with the Specification.

Documentation

Check documentation to see more details about the features. All documentation is in the “docs” directory and online at openapi-spec-validator.readthedocs.io

Installation

pip install openapi-spec-validator

Alternatively you can download the code and install from the repository:

pip install -e git+https://github.com/python-openapi/openapi-spec-validator.git#egg=openapi_spec_validator

Usage

CLI (Command Line Interface)

Straight forward way:

openapi-spec-validator openapi.yaml

pipes way:

cat openapi.yaml | openapi-spec-validator -

docker way:

docker run -v path/to/openapi.yaml:/openapi.yaml --rm p1c2u/openapi-spec-validator /openapi.yaml

or more pythonic way:

python -m openapi_spec_validator openapi.yaml

For more details, read about CLI (Command Line Interface).

Python package

from openapi_spec_validator import validate_spec
from openapi_spec_validator.readers import read_from_filename

spec_dict, spec_url = read_from_filename('openapi.yaml')

# If no exception is raised by validate_spec(), the spec is valid.
validate_spec(spec_dict)

validate_spec({'openapi': '3.1.0'})

Traceback (most recent call last):
    ...
OpenAPIValidationError: 'info' is a required property

For more details, read about Python package.

License

Copyright (c) 2017-2023, 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.6.0a2.tar.gz (33.7 kB view details)

Uploaded Source

Built Distribution

openapi_spec_validator-0.6.0a2-py3-none-any.whl (32.4 kB view details)

Uploaded Python 3

File details

Details for the file openapi_spec_validator-0.6.0a2.tar.gz.

File metadata

  • Download URL: openapi_spec_validator-0.6.0a2.tar.gz
  • Upload date:
  • Size: 33.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.5.1 CPython/3.11.4 Linux/5.15.0-1039-azure

File hashes

Hashes for openapi_spec_validator-0.6.0a2.tar.gz
Algorithm Hash digest
SHA256 7092c1824cf87b5aff20f7bf8be2a78b3edcee01144e99980e4f7bc82d20ed35
MD5 a4f16593a24d1cff5e121c6d270b0c51
BLAKE2b-256 bfd59adbc4972c5126377b38e94e8246448f60edf02c5f3063c15904b59184b3

See more details on using hashes here.

File details

Details for the file openapi_spec_validator-0.6.0a2-py3-none-any.whl.

File metadata

File hashes

Hashes for openapi_spec_validator-0.6.0a2-py3-none-any.whl
Algorithm Hash digest
SHA256 b8c6d8d8da171e355c2fab84f12637e3cfa4d405447ea62dc861c27d4cbc1dd5
MD5 9a6c991527cdeea370cb59a66ba25aec
BLAKE2b-256 105d4db5c9c96e42e724d05979f5ea2aa83447f3d248afb209df42e2470e0a96

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