{"id":14109626,"url":"https://github.com/python-openapi/openapi-schema-validator","last_synced_at":"2026-04-01T21:50:57.176Z","repository":{"id":38344403,"uuid":"245119225","full_name":"python-openapi/openapi-schema-validator","owner":"python-openapi","description":"OpenAPI schema validator is a Python library that validates schema against OpenAPI Schema Specification v3.0 and v3.1","archived":false,"fork":false,"pushed_at":"2026-03-26T16:55:54.000Z","size":1146,"stargazers_count":123,"open_issues_count":9,"forks_count":37,"subscribers_count":3,"default_branch":"master","last_synced_at":"2026-03-28T01:54:30.642Z","etag":null,"topics":["oas","oas3","openapi","openapi3","openapi31","python","python-library","schema","swagger","validation"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/python-openapi.png","metadata":{"files":{"readme":"README.rst","changelog":null,"contributing":"CONTRIBUTING.rst","funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":"AGENTS.md","dco":null,"cla":null},"funding":{"github":["p1c2u"]}},"created_at":"2020-03-05T09:23:39.000Z","updated_at":"2026-03-24T06:15:05.000Z","dependencies_parsed_at":"2024-03-12T08:28:31.354Z","dependency_job_id":"4b3b6dfe-cc07-438e-a821-2517ea5e76bd","html_url":"https://github.com/python-openapi/openapi-schema-validator","commit_stats":{"total_commits":196,"total_committers":19,"mean_commits":10.31578947368421,"dds":0.5255102040816326,"last_synced_commit":"06144e3cae25d02676378783366b26cf28d40bc8"},"previous_names":["p1c2u/openapi-schema-validator"],"tags_count":35,"template":false,"template_full_name":null,"purl":"pkg:github/python-openapi/openapi-schema-validator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-openapi%2Fopenapi-schema-validator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-openapi%2Fopenapi-schema-validator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-openapi%2Fopenapi-schema-validator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-openapi%2Fopenapi-schema-validator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/python-openapi","download_url":"https://codeload.github.com/python-openapi/openapi-schema-validator/tar.gz/refs/heads/master","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/python-openapi%2Fopenapi-schema-validator/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":31292578,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-04-01T21:15:39.731Z","status":"ssl_error","status_checked_at":"2026-04-01T21:15:34.046Z","response_time":53,"last_error":"SSL_read: unexpected eof while reading","robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":false,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["oas","oas3","openapi","openapi3","openapi31","python","python-library","schema","swagger","validation"],"created_at":"2024-08-14T10:02:25.055Z","updated_at":"2026-04-01T21:50:57.167Z","avatar_url":"https://github.com/python-openapi.png","language":"Python","readme":"************************\nopenapi-schema-validator\n************************\n\n.. image:: https://img.shields.io/pypi/v/openapi-schema-validator.svg\n     :target: https://pypi.org/project/openapi-schema-validator/\n.. image:: https://github.com/python-openapi/openapi-schema-validator/actions/workflows/python-tests.yml/badge.svg\n     :target: https://github.com/python-openapi/openapi-schema-validator/actions\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.org/project/openapi-schema-validator/\n.. image:: https://img.shields.io/pypi/format/openapi-schema-validator.svg\n     :target: https://pypi.org/project/openapi-schema-validator/\n.. image:: https://img.shields.io/pypi/status/openapi-schema-validator.svg\n     :target: https://pypi.org/project/openapi-schema-validator/\n\nAbout\n#####\n\nopenapi-schema-validator is a Python library that validates schemas against:\n\n* `OpenAPI Schema Specification v3.0 \u003chttps://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#schemaObject\u003e`__ which is an extended subset of the `JSON Schema Specification Wright Draft 00 \u003chttp://json-schema.org/\u003e`__.\n* `OpenAPI Schema Specification v3.1 \u003chttps://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.1.0.md#schemaObject\u003e`__ which is an extended superset of the `JSON Schema Specification Draft 2020-12 \u003chttp://json-schema.org/\u003e`__.\n* `OpenAPI Schema Specification v3.2 \u003chttps://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.2.0.md#schemaObject\u003e`__ using the published OAS 3.2 JSON Schema dialect resources.\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 \u003chttps://openapi-schema-validator.readthedocs.io\u003e`__\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 \"git+https://github.com/python-openapi/openapi-schema-validator.git\"\n\n\nUsage\n#####\n\n``validate`` call signature is:\n\n.. code-block:: python\n\n   validate(\n       instance,\n       schema,\n       cls=OAS32Validator,\n       allow_remote_references=False,\n       check_schema=True,\n       **kwargs,\n   )\n\nThe first argument is always the value you want to validate.\nThe second argument is always the OpenAPI schema object.\nThe ``cls`` keyword argument is optional and defaults to ``OAS32Validator``.\nUse ``cls`` when you need a specific validator version/behavior.\n\n.. code-block:: python\n\n   from openapi_schema_validator import OAS30Validator\n   from openapi_schema_validator import OAS31Validator\n   from openapi_schema_validator import validate\n\n   # OpenAPI 3.0 behavior\n   validate(instance, schema, cls=OAS30Validator)\n\n   # OpenAPI 3.1 behavior\n   validate(instance, schema, cls=OAS31Validator)\n\n   # OpenAPI 3.2 behavior (default)\n   validate(instance, schema)\n\nCommon forwarded keyword arguments include ``registry`` (reference context)\nand ``format_checker`` (format validation behavior).\nBy default, ``validate`` uses a local-only empty registry to avoid implicit\nremote ``$ref`` retrieval. To resolve external references, pass an explicit\n``registry``. Set ``allow_remote_references=True`` only if you explicitly\naccept jsonschema's default remote retrieval behavior.\n\n``check_schema`` defaults to ``True`` and validates the schema before\nvalidating an instance. For trusted pre-validated schemas in hot paths, set\n``check_schema=False`` to skip schema checking.\n\nThe ``validate`` helper keeps an internal compiled-validator cache. You can\ncontrol cache size using the\n``OPENAPI_SCHEMA_VALIDATOR_COMPILED_VALIDATOR_CACHE_MAX_SIZE`` environment variable\n(default: ``128``).\nThe value is loaded once at first use and reused for the lifetime of the\nprocess.\n\nTo validate an OpenAPI 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\nExpected failure output:\n\n.. code-block:: text\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\nDefault dialect resolution\n--------------------------\n\nThe OpenAPI 3.1 and 3.2 base dialect URIs are registered for\n``jsonschema.validators.validator_for`` resolution.\nSchemas declaring ``\"$schema\"`` as either\n``\"https://spec.openapis.org/oas/3.1/dialect/base\"`` or\n``\"https://spec.openapis.org/oas/3.2/dialect/2025-09-17\"`` resolve\ndirectly to ``OAS31Validator`` and ``OAS32Validator`` without\nunresolved-metaschema fallback warnings.\n\n.. code-block:: python\n\n   from jsonschema.validators import validator_for\n\n   from openapi_schema_validator import OAS31Validator\n   from openapi_schema_validator import OAS32Validator\n\n   schema = {\n       \"$schema\": \"https://spec.openapis.org/oas/3.1/dialect/base\",\n       \"type\": \"object\",\n   }\n   schema32 = {\n       \"$schema\": \"https://spec.openapis.org/oas/3.2/dialect/2025-09-17\",\n       \"type\": \"object\",\n   }\n\n   assert validator_for(schema) is OAS31Validator\n   assert validator_for(schema32) is OAS32Validator\n\nBinary Data Semantics\n=====================\n\nThe handling of binary-like payloads differs between OpenAPI versions.\n\nOpenAPI 3.0\n-----------\n\nOpenAPI 3.0 keeps historical ``format: binary`` / ``format: byte`` usage on\n``type: string``.\n\n**OAS30Validator (default - compatibility behavior)**\n   - ``type: string`` accepts ``str``\n   - ``type: string, format: binary`` accepts Python ``bytes`` and strings\n   - useful when validating Python-native runtime data\n\n**OAS30StrictValidator**\n   - ``type: string`` accepts ``str`` only\n   - ``type: string, format: binary`` uses strict format validation\n   - use when you want strict, spec-oriented behavior for 3.0 schemas\n\nOpenAPI 3.1+\n------------\n\nOpenAPI 3.1+ follows JSON Schema semantics for string typing in this library.\n\n- ``type: string`` accepts ``str`` only (not ``bytes``)\n- ``format: binary`` and ``format: byte`` are not treated as built-in formats\n- for base64-in-JSON, model with ``contentEncoding: base64`` (optionally\n  ``contentMediaType``)\n- for raw binary payloads, model via media type (for example\n  ``application/octet-stream``) rather than schema string formats\n\nRegex Behavior\n==============\n\nBy default, ``pattern`` handling follows host Python regex behavior.\nFor ECMAScript-oriented regex validation and matching (via ``regress``),\ninstall the optional extra:\n\n.. code-block:: console\n\n   pip install \"openapi-schema-validator[ecma-regex]\"\n\n\nFor more details read about `Validation \u003chttps://openapi-schema-validator.readthedocs.io/en/latest/validation.html\u003e`__.\n\n\nRelated projects\n################\n* `openapi-core \u003chttps://github.com/python-openapi/openapi-core\u003e`__\n   Python library that adds client-side and server-side support for the OpenAPI.\n* `openapi-spec-validator \u003chttps://github.com/python-openapi/openapi-spec-validator\u003e`__\n   Python library that validates OpenAPI Specs against the OpenAPI 2.0 (aka Swagger) and OpenAPI 3.0 specification\n","funding_links":["https://github.com/sponsors/p1c2u"],"categories":["Python"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-openapi%2Fopenapi-schema-validator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fpython-openapi%2Fopenapi-schema-validator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fpython-openapi%2Fopenapi-schema-validator/lists"}