openapi-schema-validator


Nameopenapi-schema-validator JSON
Version 0.6.2 PyPI version JSON
download
home_pagehttps://github.com/python-openapi/openapi-schema-validator
SummaryOpenAPI schema validation for Python
upload_time2023-10-05 11:16:40
maintainer
docs_urlNone
authorArtur Maciag
requires_python>=3.8.0,<4.0.0
licenseBSD-3-Clause
keywords openapi swagger schema
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI
coveralls test coverage No coveralls.
            ************************
openapi-schema-validator
************************

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

About
#####

Openapi-schema-validator is a Python library that validates schema against:

* `OpenAPI Schema Specification v3.0 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject>`__ which is an extended subset of the `JSON Schema Specification Wright Draft 00 <http://json-schema.org/>`__.
* `OpenAPI Schema Specification v3.1 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject>`__ which is an extended superset of the `JSON Schema Specification Draft 2020-12 <http://json-schema.org/>`__.


Documentation
#############

Check documentation to see more details about the features. All documentation is in the "docs" directory and online at `openapi-schema-validator.readthedocs.io <https://openapi-schema-validator.readthedocs.io>`__


Installation
############

Recommended way (via pip):

.. code-block:: console

   pip install openapi-schema-validator

Alternatively you can download the code and install from the repository:

.. code-block:: console

   pip install -e git+https://github.com/python-openapi/openapi-schema-validator.git#egg=openapi_schema_validator


Usage
#####

To validate an OpenAPI v3.1 schema:

.. code-block:: python

   from openapi_schema_validator import validate

   # A sample schema
   schema = {
       "type": "object",
       "required": [
          "name"
       ],
       "properties": {
           "name": {
               "type": "string"
           },
           "age": {
               "type": ["integer", "null"],
               "format": "int32",
               "minimum": 0,
           },
           "birth-date": {
               "type": "string",
               "format": "date",
           },
           "address": {
                "type": 'array',
                "prefixItems": [
                    { "type": "number" },
                    { "type": "string" },
                    { "enum": ["Street", "Avenue", "Boulevard"] },
                    { "enum": ["NW", "NE", "SW", "SE"] }
                ],
                "items": False,
            }
       },
       "additionalProperties": False,
   }

   # If no exception is raised by validate(), the instance is valid.
   validate({"name": "John", "age": 23, "address": [1600, "Pennsylvania", "Avenue"]}, schema)

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

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

By default, the latest OpenAPI schema syntax is expected.

For more details read about `Validation <https://openapi-schema-validator.readthedocs.io/en/latest/validation.html>`__.

Related projects
################
* `openapi-core <https://github.com/python-openapi/openapi-core>`__
   Python library that adds client-side and server-side support for the OpenAPI.
* `openapi-spec-validator <https://github.com/python-openapi/openapi-spec-validator>`__
   Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0 specification

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/python-openapi/openapi-schema-validator",
    "name": "openapi-schema-validator",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8.0,<4.0.0",
    "maintainer_email": "",
    "keywords": "openapi,swagger,schema",
    "author": "Artur Maciag",
    "author_email": "maciag.artur@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/5c/b2/7d5bdf2b26b6a95ebf4fbec294acaf4306c713f3a47c2453962511110248/openapi_schema_validator-0.6.2.tar.gz",
    "platform": null,
    "description": "************************\nopenapi-schema-validator\n************************\n\n.. image:: https://img.shields.io/pypi/v/openapi-schema-validator.svg\n     :target: https://pypi.python.org/pypi/openapi-schema-validator\n.. image:: https://travis-ci.org/python-openapi/openapi-schema-validator.svg?branch=master\n     :target: https://travis-ci.org/python-openapi/openapi-schema-validator\n.. image:: https://img.shields.io/codecov/c/github/python-openapi/openapi-schema-validator/master.svg?style=flat\n     :target: https://codecov.io/github/python-openapi/openapi-schema-validator?branch=master\n.. image:: https://img.shields.io/pypi/pyversions/openapi-schema-validator.svg\n     :target: https://pypi.python.org/pypi/openapi-schema-validator\n.. image:: https://img.shields.io/pypi/format/openapi-schema-validator.svg\n     :target: https://pypi.python.org/pypi/openapi-schema-validator\n.. image:: https://img.shields.io/pypi/status/openapi-schema-validator.svg\n     :target: https://pypi.python.org/pypi/openapi-schema-validator\n\nAbout\n#####\n\nOpenapi-schema-validator is a Python library that validates schema against:\n\n* `OpenAPI Schema Specification v3.0 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject>`__ which is an extended subset of the `JSON Schema Specification Wright Draft 00 <http://json-schema.org/>`__.\n* `OpenAPI Schema Specification v3.1 <https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject>`__ which is an extended superset of the `JSON Schema Specification Draft 2020-12 <http://json-schema.org/>`__.\n\n\nDocumentation\n#############\n\nCheck documentation to see more details about the features. All documentation is in the \"docs\" directory and online at `openapi-schema-validator.readthedocs.io <https://openapi-schema-validator.readthedocs.io>`__\n\n\nInstallation\n############\n\nRecommended way (via pip):\n\n.. code-block:: console\n\n   pip install openapi-schema-validator\n\nAlternatively you can download the code and install from the repository:\n\n.. code-block:: console\n\n   pip install -e git+https://github.com/python-openapi/openapi-schema-validator.git#egg=openapi_schema_validator\n\n\nUsage\n#####\n\nTo validate an OpenAPI v3.1 schema:\n\n.. code-block:: python\n\n   from openapi_schema_validator import validate\n\n   # A sample schema\n   schema = {\n       \"type\": \"object\",\n       \"required\": [\n          \"name\"\n       ],\n       \"properties\": {\n           \"name\": {\n               \"type\": \"string\"\n           },\n           \"age\": {\n               \"type\": [\"integer\", \"null\"],\n               \"format\": \"int32\",\n               \"minimum\": 0,\n           },\n           \"birth-date\": {\n               \"type\": \"string\",\n               \"format\": \"date\",\n           },\n           \"address\": {\n                \"type\": 'array',\n                \"prefixItems\": [\n                    { \"type\": \"number\" },\n                    { \"type\": \"string\" },\n                    { \"enum\": [\"Street\", \"Avenue\", \"Boulevard\"] },\n                    { \"enum\": [\"NW\", \"NE\", \"SW\", \"SE\"] }\n                ],\n                \"items\": False,\n            }\n       },\n       \"additionalProperties\": False,\n   }\n\n   # If no exception is raised by validate(), the instance is valid.\n   validate({\"name\": \"John\", \"age\": 23, \"address\": [1600, \"Pennsylvania\", \"Avenue\"]}, schema)\n\n   validate({\"name\": \"John\", \"city\": \"London\"}, schema)\n\n   Traceback (most recent call last):\n       ...\n   ValidationError: Additional properties are not allowed ('city' was unexpected)\n\nBy default, the latest OpenAPI schema syntax is expected.\n\nFor more details read about `Validation <https://openapi-schema-validator.readthedocs.io/en/latest/validation.html>`__.\n\nRelated projects\n################\n* `openapi-core <https://github.com/python-openapi/openapi-core>`__\n   Python library that adds client-side and server-side support for the OpenAPI.\n* `openapi-spec-validator <https://github.com/python-openapi/openapi-spec-validator>`__\n   Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0 specification\n",
    "bugtrack_url": null,
    "license": "BSD-3-Clause",
    "summary": "OpenAPI schema validation for Python",
    "version": "0.6.2",
    "project_urls": {
        "Homepage": "https://github.com/python-openapi/openapi-schema-validator",
        "Repository": "https://github.com/python-openapi/openapi-schema-validator"
    },
    "split_keywords": [
        "openapi",
        "swagger",
        "schema"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b3dc9aefae8891454130968ff079ece851d1ae9ccf6fb7965761f47c50c04853",
                "md5": "ebf53dddf3ff1032afe8c770f15bc9de",
                "sha256": "c4887c1347c669eb7cded9090f4438b710845cd0f90d1fb9e1b3303fb37339f8"
            },
            "downloads": -1,
            "filename": "openapi_schema_validator-0.6.2-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "ebf53dddf3ff1032afe8c770f15bc9de",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8.0,<4.0.0",
            "size": 8750,
            "upload_time": "2023-10-05T11:16:38",
            "upload_time_iso_8601": "2023-10-05T11:16:38.360342Z",
            "url": "https://files.pythonhosted.org/packages/b3/dc/9aefae8891454130968ff079ece851d1ae9ccf6fb7965761f47c50c04853/openapi_schema_validator-0.6.2-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "5cb27d5bdf2b26b6a95ebf4fbec294acaf4306c713f3a47c2453962511110248",
                "md5": "1c1faed2edfd01bb1471bdbe525406f7",
                "sha256": "11a95c9c9017912964e3e5f2545a5b11c3814880681fcacfb73b1759bb4f2804"
            },
            "downloads": -1,
            "filename": "openapi_schema_validator-0.6.2.tar.gz",
            "has_sig": false,
            "md5_digest": "1c1faed2edfd01bb1471bdbe525406f7",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8.0,<4.0.0",
            "size": 11860,
            "upload_time": "2023-10-05T11:16:40",
            "upload_time_iso_8601": "2023-10-05T11:16:40.200398Z",
            "url": "https://files.pythonhosted.org/packages/5c/b2/7d5bdf2b26b6a95ebf4fbec294acaf4306c713f3a47c2453962511110248/openapi_schema_validator-0.6.2.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-10-05 11:16:40",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "python-openapi",
    "github_project": "openapi-schema-validator",
    "travis_ci": true,
    "coveralls": false,
    "github_actions": true,
    "lcname": "openapi-schema-validator"
}
        
Elapsed time: 0.12399s