Skip to content

Commit

Permalink
[spec-first#1786] Address jsonschema format_checker deprecation
Browse files Browse the repository at this point in the history
  • Loading branch information
mavwolverine committed Sep 10, 2024
1 parent a930303 commit de007c4
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
4 changes: 2 additions & 2 deletions connexion/validators/form_data.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import logging
import typing as t

from jsonschema import ValidationError, draft4_format_checker
from jsonschema import Draft4Validator, ValidationError
from starlette.datastructures import Headers, UploadFile
from starlette.formparsers import FormParser, MultiPartParser
from starlette.types import Scope
Expand Down Expand Up @@ -39,7 +39,7 @@ def __init__(
@property
def _validator(self):
return Draft4RequestValidator(
self._schema, format_checker=draft4_format_checker
self._schema, format_checker=Draft4Validator.FORMAT_CHECKER
)

@property
Expand Down
10 changes: 6 additions & 4 deletions connexion/validators/json.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import typing as t

import jsonschema
from jsonschema import Draft4Validator, ValidationError, draft4_format_checker
from jsonschema import Draft4Validator, ValidationError
from starlette.types import Scope

from connexion.exceptions import BadRequestProblem, NonConformingResponseBody
Expand Down Expand Up @@ -44,7 +44,7 @@ def __init__(
@property
def _validator(self):
return Draft4RequestValidator(
self._schema, format_checker=draft4_format_checker
self._schema, format_checker=Draft4Validator.FORMAT_CHECKER
)

async def _parse(
Expand Down Expand Up @@ -86,7 +86,9 @@ class DefaultsJSONRequestBodyValidator(JSONRequestBodyValidator):
@property
def _validator(self):
validator_cls = self.extend_with_set_default(Draft4RequestValidator)
return validator_cls(self._schema, format_checker=draft4_format_checker)
return validator_cls(
self._schema, format_checker=Draft4Validator.FORMAT_CHECKER
)

# via https://python-jsonschema.readthedocs.io/
@staticmethod
Expand All @@ -111,7 +113,7 @@ class JSONResponseBodyValidator(AbstractResponseBodyValidator):
@property
def validator(self) -> Draft4Validator:
return Draft4ResponseValidator(
self._schema, format_checker=draft4_format_checker
self._schema, format_checker=Draft4Validator.FORMAT_CHECKER
)

def _parse(self, stream: t.Generator[bytes, None, None]) -> t.Any:
Expand Down

0 comments on commit de007c4

Please sign in to comment.