Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork70
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.
License
python-openapi/openapi-spec-validator
Folders and files
Name | Name | Last commit message | Last commit date | |
---|---|---|---|---|
Repository files navigation
OpenAPI Spec Validator is a Python library that validates OpenAPI Specs against theOpenAPI 2.0 (aka Swagger),OpenAPI 3.0 andOpenAPI 3.1 specification.
The validator aims to check for full compliance with the Specification.
$ pip install openapi-spec-validator
Alternatively you can download the code and install from the repository:
$ pip install -e git+https://github.com/p1c2u/openapi-spec-validator.git#egg=openapi_spec_validator
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
Validate spec:
fromopenapi_spec_validatorimportvalidate_specfromopenapi_spec_validator.readersimportread_from_filenamespec_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({})Traceback (mostrecentcalllast): ...OpenAPIValidationError:'openapi'isarequiredproperty
Addspec_url
to validate spec with relative files:
validate_spec(spec_dict,spec_url='file:///path/to/spec/openapi.yaml')
You can also validate spec from url:
fromopenapi_spec_validatorimportvalidate_spec_url# If no exception is raised by validate_spec_url(), the spec is valid.validate_spec_url('http://example.com/openapi.json')
If you want to iterate through validation errors:
fromopenapi_spec_validatorimportopenapi_v3_spec_validatorerrors_iterator=openapi_v3_spec_validator.iter_errors(spec)
- openapi-core
- Python library that adds client-side and server-side support for the OpenAPI.
- openapi-schema-validator
- Python library that validates schema against the OpenAPI Schema Specification v3.0.
Copyright (c) 2017-2021, Artur Maciag, All rights reserved. Apache v2
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.
Topics
Resources
License
Security policy
Uh oh!
There was an error while loading.Please reload this page.
Stars
Watchers
Forks
Sponsor this project
Uh oh!
There was an error while loading.Please reload this page.
Packages0
Uh oh!
There was an error while loading.Please reload this page.