Skip to main content

No project description provided

Project description

https://img.shields.io/pypi/v/openapi-schema-validator.svg https://travis-ci.org/p1c2u/openapi-schema-validator.svg?branch=master https://img.shields.io/codecov/c/github/p1c2u/openapi-schema-validator/master.svg?style=flat https://img.shields.io/pypi/pyversions/openapi-schema-validator.svg https://img.shields.io/pypi/format/openapi-schema-validator.svg https://img.shields.io/pypi/status/openapi-schema-validator.svg

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 OAS30Validator, oas30_format_checker

# A sample schema
schema = {
    "type" : "object",
    "required": [
       "name"
    ],
    "properties": {
        "name": {
            "type": "string"
        },
        "age": {
            "type": "integer",
            "format": "int32",
            "minimum": 0,
            "nullable": True,
        },
    },
    "additionalProperties": False,
}

validator = OAS30Validator(schema)
# If no exception is raised by validate(), the instance is valid.
validator.validate({"name": "John", "age": 23})

validator.validate({"name": "John", "city": "London"})

Traceback (most recent call last):
    ...
ValidationError: Additional properties are not allowed ('city' was unexpected)

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-schema-validator-0.1.0.tar.gz (6.5 kB view hashes)

Uploaded Source

Built Distributions

openapi_schema_validator-0.1.0-py3-none-any.whl (7.2 kB view hashes)

Uploaded Python 3

openapi_schema_validator-0.1.0-py2-none-any.whl (7.2 kB view hashes)

Uploaded Python 2

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