From 704dbd56aecb35261f8b12e39020cee187f5783d Mon Sep 17 00:00:00 2001 From: p1c2u Date: Wed, 20 Sep 2023 19:40:21 +0000 Subject: [PATCH] Jsonschema keyworkds module rename fix --- .../{_validators.py => _keywords.py} | 6 +- openapi_schema_validator/validators.py | 94 +++++++++---------- poetry.lock | 8 +- pyproject.toml | 2 +- 4 files changed, 55 insertions(+), 55 deletions(-) rename openapi_schema_validator/{_validators.py => _keywords.py} (98%) diff --git a/openapi_schema_validator/_validators.py b/openapi_schema_validator/_keywords.py similarity index 98% rename from openapi_schema_validator/_validators.py rename to openapi_schema_validator/_keywords.py index 729a3f1..08c8078 100644 --- a/openapi_schema_validator/_validators.py +++ b/openapi_schema_validator/_keywords.py @@ -8,11 +8,11 @@ from typing import Mapping from typing import Union +from jsonschema._keywords import allOf as _allOf +from jsonschema._keywords import anyOf as _anyOf +from jsonschema._keywords import oneOf as _oneOf from jsonschema._utils import extras_msg from jsonschema._utils import find_additional_properties -from jsonschema._validators import allOf as _allOf -from jsonschema._validators import anyOf as _anyOf -from jsonschema._validators import oneOf as _oneOf from jsonschema.exceptions import FormatError from jsonschema.exceptions import ValidationError from jsonschema.protocols import Validator diff --git a/openapi_schema_validator/validators.py b/openapi_schema_validator/validators.py index 4643b3f..f541655 100644 --- a/openapi_schema_validator/validators.py +++ b/openapi_schema_validator/validators.py @@ -2,16 +2,16 @@ from typing import Any from typing import Type -from jsonschema import _legacy_validators -from jsonschema import _validators +from jsonschema import _keywords +from jsonschema import _legacy_keywords from jsonschema.validators import Draft202012Validator from jsonschema.validators import create from jsonschema.validators import extend from jsonschema_specifications import REGISTRY as SPECIFICATIONS from openapi_schema_validator import _format as oas_format +from openapi_schema_validator import _keywords as oas_keywords from openapi_schema_validator import _types as oas_types -from openapi_schema_validator import _validators as oas_validators from openapi_schema_validator._types import oas31_type_checker OAS30Validator = create( @@ -19,42 +19,42 @@ "http://json-schema.org/draft-04/schema#", ), validators={ - "multipleOf": _validators.multipleOf, + "multipleOf": _keywords.multipleOf, # exclusiveMaximum supported inside maximum_draft3_draft4 - "maximum": _legacy_validators.maximum_draft3_draft4, + "maximum": _legacy_keywords.maximum_draft3_draft4, # exclusiveMinimum supported inside minimum_draft3_draft4 - "minimum": _legacy_validators.minimum_draft3_draft4, - "maxLength": _validators.maxLength, - "minLength": _validators.minLength, - "pattern": _validators.pattern, - "maxItems": _validators.maxItems, - "minItems": _validators.minItems, - "uniqueItems": _validators.uniqueItems, - "maxProperties": _validators.maxProperties, - "minProperties": _validators.minProperties, - "enum": _validators.enum, + "minimum": _legacy_keywords.minimum_draft3_draft4, + "maxLength": _keywords.maxLength, + "minLength": _keywords.minLength, + "pattern": _keywords.pattern, + "maxItems": _keywords.maxItems, + "minItems": _keywords.minItems, + "uniqueItems": _keywords.uniqueItems, + "maxProperties": _keywords.maxProperties, + "minProperties": _keywords.minProperties, + "enum": _keywords.enum, # adjusted to OAS - "type": oas_validators.type, - "allOf": oas_validators.allOf, - "oneOf": oas_validators.oneOf, - "anyOf": oas_validators.anyOf, - "not": _validators.not_, - "items": oas_validators.items, - "properties": _validators.properties, - "required": oas_validators.required, - "additionalProperties": oas_validators.additionalProperties, + "type": oas_keywords.type, + "allOf": oas_keywords.allOf, + "oneOf": oas_keywords.oneOf, + "anyOf": oas_keywords.anyOf, + "not": _keywords.not_, + "items": oas_keywords.items, + "properties": _keywords.properties, + "required": oas_keywords.required, + "additionalProperties": oas_keywords.additionalProperties, # TODO: adjust description - "format": oas_validators.format, + "format": oas_keywords.format, # TODO: adjust default - "$ref": _validators.ref, + "$ref": _keywords.ref, # fixed OAS fields - "discriminator": oas_validators.not_implemented, - "readOnly": oas_validators.readOnly, - "writeOnly": oas_validators.writeOnly, - "xml": oas_validators.not_implemented, - "externalDocs": oas_validators.not_implemented, - "example": oas_validators.not_implemented, - "deprecated": oas_validators.not_implemented, + "discriminator": oas_keywords.not_implemented, + "readOnly": oas_keywords.readOnly, + "writeOnly": oas_keywords.writeOnly, + "xml": oas_keywords.not_implemented, + "externalDocs": oas_keywords.not_implemented, + "example": oas_keywords.not_implemented, + "deprecated": oas_keywords.not_implemented, }, type_checker=oas_types.oas30_type_checker, format_checker=oas_format.oas30_format_checker, @@ -67,17 +67,17 @@ OAS30ReadValidator = extend( OAS30Validator, validators={ - "required": oas_validators.read_required, - "readOnly": oas_validators.not_implemented, - "writeOnly": oas_validators.writeOnly, + "required": oas_keywords.read_required, + "readOnly": oas_keywords.not_implemented, + "writeOnly": oas_keywords.writeOnly, }, ) OAS30WriteValidator = extend( OAS30Validator, validators={ - "required": oas_validators.write_required, - "readOnly": oas_validators.readOnly, - "writeOnly": oas_validators.not_implemented, + "required": oas_keywords.write_required, + "readOnly": oas_keywords.readOnly, + "writeOnly": oas_keywords.not_implemented, }, ) @@ -85,15 +85,15 @@ Draft202012Validator, { # adjusted to OAS - "allOf": oas_validators.allOf, - "oneOf": oas_validators.oneOf, - "anyOf": oas_validators.anyOf, - "description": oas_validators.not_implemented, + "allOf": oas_keywords.allOf, + "oneOf": oas_keywords.oneOf, + "anyOf": oas_keywords.anyOf, + "description": oas_keywords.not_implemented, # fixed OAS fields - "discriminator": oas_validators.not_implemented, - "xml": oas_validators.not_implemented, - "externalDocs": oas_validators.not_implemented, - "example": oas_validators.not_implemented, + "discriminator": oas_keywords.not_implemented, + "xml": oas_keywords.not_implemented, + "externalDocs": oas_keywords.not_implemented, + "example": oas_keywords.not_implemented, }, type_checker=oas31_type_checker, format_checker=oas_format.oas31_format_checker, diff --git a/poetry.lock b/poetry.lock index c88c372..c92bb53 100644 --- a/poetry.lock +++ b/poetry.lock @@ -565,13 +565,13 @@ i18n = ["Babel (>=2.7)"] [[package]] name = "jsonschema" -version = "4.19.0" +version = "4.19.1" description = "An implementation of JSON Schema validation for Python" optional = false python-versions = ">=3.8" files = [ - {file = "jsonschema-4.19.0-py3-none-any.whl", hash = "sha256:043dc26a3845ff09d20e4420d6012a9c91c9aa8999fa184e7efcfeccb41e32cb"}, - {file = "jsonschema-4.19.0.tar.gz", hash = "sha256:6e1e7569ac13be8139b2dd2c21a55d350066ee3f80df06c608b398cdc6f30e8f"}, + {file = "jsonschema-4.19.1-py3-none-any.whl", hash = "sha256:cd5f1f9ed9444e554b38ba003af06c0a8c2868131e56bfbef0550fb450c0330e"}, + {file = "jsonschema-4.19.1.tar.gz", hash = "sha256:ec84cc37cfa703ef7cd4928db24f9cb31428a5d0fa77747b8b51a847458e0bbf"}, ] [package.dependencies] @@ -1558,4 +1558,4 @@ docs = [] [metadata] lock-version = "2.0" python-versions = "^3.8.0" -content-hash = "758f2a11c12063c46b5662d792e70d7e1f30ef526a20f2ffcd8efa831d7e2d1e" +content-hash = "aaf6d06196e45abedeb1fdb9852cc747a1b1c839db9b7bffe26000eb9257dae0" diff --git a/pyproject.toml b/pyproject.toml index 4978940..d42ecbe 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -55,7 +55,7 @@ include = [ [tool.poetry.dependencies] python = "^3.8.0" -jsonschema = "^4.18.0" +jsonschema = "^4.19.1" rfc3339-validator = "*" # requred by jsonschema for date-time checker jsonschema-specifications = "^2023.5.2"