OpenAPI schema validation for Python
Project description
About
Openapi-schema-validator is a Python library that validates schema against the OpenAPI Schema Specification v3.0 which is an extended subset of the JSON Schema Specification Wright Draft 00.
Installation
Recommended way (via pip):
$ pip install openapi-schema-validator
Alternatively you can download the code and install from the repository:
$ pip install -e git+https://github.com/p1c2u/openapi-schema-validator.git#egg=openapi_schema_validator
Usage
Simple usage
from openapi_schema_validator import validate
# A sample schema
schema = {
"type" : "object",
"required": [
"name"
],
"properties": {
"name": {
"type": "string"
},
"age": {
"type": "integer",
"format": "int32",
"minimum": 0,
"nullable": True,
},
"birth-date": {
"type": "string",
"format": "date",
}
},
"additionalProperties": False,
}
# If no exception is raised by validate(), the instance is valid.
validate({"name": "John", "age": 23}, schema)
validate({"name": "John", "city": "London"}, schema)
Traceback (most recent call last):
...
ValidationError: Additional properties are not allowed ('city' was unexpected)
You can also check format for primitive types
from openapi_schema_validator import oas30_format_checker
validate({"name": "John", "birth-date": "-12"}, schema, format_checker=oas30_format_checker)
Traceback (most recent call last):
...
ValidationError: '-12' is not a 'date'
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distributions
File details
Details for the file openapi-schema-validator-0.1.5.tar.gz
.
File metadata
- Download URL: openapi-schema-validator-0.1.5.tar.gz
- Upload date:
- Size: 6.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | a4b2712020284cee880b4c55faa513fbc2f8f07f365deda6098f8ab943c9f0df |
|
MD5 | 585af925029c531c63f1d7ba92028179 |
|
BLAKE2b-256 | 8c440065b0e102810356c54e01d8bd56542d5d02acd27060d81b2e372fd0888c |
File details
Details for the file openapi_schema_validator-0.1.5-py3-none-any.whl
.
File metadata
- Download URL: openapi_schema_validator-0.1.5-py3-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.4.1 importlib_metadata/3.7.3 pkginfo/1.7.0 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.6.13
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | b65d6c2242620bfe76d4c749b61cd9657e4528895a8f4fb6f916085b508ebd24 |
|
MD5 | 25f5da49274679a90bd06ac92ff3b522 |
|
BLAKE2b-256 | 61de67a615be34d76a1b18ee13861ffd584ffc982e465499c67d5b029bd1084a |
File details
Details for the file openapi_schema_validator-0.1.5-py2-none-any.whl
.
File metadata
- Download URL: openapi_schema_validator-0.1.5-py2-none-any.whl
- Upload date:
- Size: 7.9 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/1.15.0 pkginfo/1.7.0 requests/2.25.1 setuptools/41.2.0 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/2.7.18
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 215b516d0942f4e8e2446cf3f7d4ff2ed71d102ebddcc30526d8a3f706ab1df6 |
|
MD5 | 47567108b14084e17330adea1bbba500 |
|
BLAKE2b-256 | 9bd7e1db5c09d71bd9a1eb778af152e3e924ba354a65fb3d24244a1ef2eaa4fc |