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 OpenAPI 3.1 and OpenAPI 3.2 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.9.0 # 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)
# Example of an intentionally invalid spec.
invalid_spec = {'openapi': '3.1.0'}
validate(invalid_spec)
Traceback (most recent call last):
...
OpenAPIValidationError: 'info' is a required property
For more details, read about Python package.
Performance tuning
You can tune resolved-path caching with an environment variable:
OPENAPI_SPEC_VALIDATOR_RESOLVED_CACHE_MAXSIZE=2048
Rules:
Default is 128.
Set 0 to disable the resolved cache.
Invalid values (non-integer or negative) fall back to 128.
You can also choose schema validator backend:
OPENAPI_SPEC_VALIDATOR_SCHEMA_VALIDATOR_BACKEND=jsonschema-rs
Allowed values are auto (default), jsonschema, and jsonschema-rs. Invalid values raise a warning and fall back to auto.
If you select the jsonschema-rs backend, make sure the optional jsonschema-rs package is installed:
pip install jsonschema-rs
License
Copyright (c) 2017-2023, Artur Maciag, All rights reserved. Apache v2
Release files for openapi-spec-validator 0.9.0
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| openapi_spec_validator-0.9.0.tar.gz | 1.8 MB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| openapi_spec_validator-0.9.0-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 1.8 MB
Release files / openapi_spec_validator-0.9.0.tar.gz
| Download URL | openapi_spec_validator-0.9.0.tar.gz |
|---|---|
| Size | 1.8 MB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
6d648cff6490ebb799dcfe273792f2941c050158854c721f086599d845da78b8
|
|
BLAKE2b-256 checksum How to use checksums |
8fd2640b5149cd5688bc0ad1fdbb4df6a2f7b84a093c8d787c27d566132f8b8b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2026.
Transparency logRelease files / openapi_spec_validator-0.9.0-py3-none-any.whl
| Download URL | openapi_spec_validator-0.9.0-py3-none-any.whl |
|---|---|
| Size | 50.3 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
222fecffc7714f6d0a6ad62c0e4b66cc2b7dbfafb7b93acfc6c308abbdb51af8
|
|
BLAKE2b-256 checksum How to use checksums |
95d8321ff889330acca2e3097f3d4f80a40bcc41b6d34d302978ab32c449520b
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
Yes |
| Uploaded via |
twine/6.1.0 CPython/3.13.12
|
Provenance
Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.
PyPI Publish Attestation
PyPI verified that this artifact, at this checksum, originated from the publisher listed below.
Signed by GitHub Actions, verified by PyPI on May 20, 2026.
Transparency log