Skip to main content

OpenAPI 2.0 (aka Swagger) and OpenAPI 3 spec validator

Project description

https://img.shields.io/docker/v/pythonopenapi/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 CLI, pre-commit hook and python package 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 pythonopenapi/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).

pre-commit hook

repos:
-   repo: https://github.com/python-openapi/openapi-spec-validator
    rev: 0.5.5 # The version to use or 'master' for latest
    hooks:
    -   id: openapi-spec-validator

For more details, read about pre-commit hook.

Python package

from openapi_spec_validator import validate
from openapi_spec_validator.readers import read_from_filename

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

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

validate({'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.7.2.tar.gz (36.9 kB view details)

Uploaded Source

Built Distribution

openapi_spec_validator-0.7.2-py3-none-any.whl (39.7 kB view details)

Uploaded Python 3

File details

Details for the file openapi_spec_validator-0.7.2.tar.gz.

File metadata

  • Download URL: openapi_spec_validator-0.7.2.tar.gz
  • Upload date:
  • Size: 36.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for openapi_spec_validator-0.7.2.tar.gz
Algorithm Hash digest
SHA256 cc029309b5c5dbc7859df0372d55e9d1ff43e96d678b9ba087f7c56fc586f734
MD5 c5bf8550c7f187e12497e4c96f2285f3
BLAKE2b-256 82affe2d7618d6eae6fb3a82766a44ed87cd8d6d82b4564ed1c7cfb0f6378e91

See more details on using hashes here.

Provenance

The following attestation bundles were made for openapi_spec_validator-0.7.2.tar.gz:

Publisher: python-publish.yml on python-openapi/openapi-spec-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

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

File metadata

File hashes

Hashes for openapi_spec_validator-0.7.2-py3-none-any.whl
Algorithm Hash digest
SHA256 4bbdc0894ec85f1d1bea1d6d9c8b2c3c8d7ccaa13577ef40da9c006c9fd0eb60
MD5 fe99ab6f33cca99f184ade713a2086b8
BLAKE2b-256 27ddb3fd642260cb17532f66cc1e8250f3507d1e580483e209dc1e9d13bd980d

See more details on using hashes here.

Provenance

The following attestation bundles were made for openapi_spec_validator-0.7.2-py3-none-any.whl:

Publisher: python-publish.yml on python-openapi/openapi-spec-validator

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

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