|
1 |
| -from copy import copy |
2 | 1 | import warnings
|
3 | 2 |
|
4 |
| -from openapi_schema_validator import OAS30Validator, oas30_format_checker |
| 3 | +from openapi_schema_validator import OAS30Validator |
5 | 4 |
|
6 | 5 | from openapi_core.schema.schemas.enums import SchemaType, SchemaFormat
|
7 | 6 | from openapi_core.schema.schemas.models import Schema
|
@@ -35,8 +34,11 @@ class SchemaUnmarshallersFactory(object):
|
35 | 34 | UnmarshalContext.RESPONSE: 'read',
|
36 | 35 | }
|
37 | 36 |
|
38 |
| - def __init__(self, resolver=None, custom_formatters=None, context=None): |
| 37 | + def __init__( |
| 38 | + self, resolver=None, format_checker=None, |
| 39 | + custom_formatters=None, context=None): |
39 | 40 | self.resolver = resolver
|
| 41 | + self.format_checker = format_checker |
40 | 42 | if custom_formatters is None:
|
41 | 43 | custom_formatters = {}
|
42 | 44 | self.custom_formatters = custom_formatters
|
@@ -79,17 +81,10 @@ def get_formatter(self, default_formatters, type_format=SchemaFormat.NONE):
|
79 | 81 | return default_formatters.get(schema_format)
|
80 | 82 |
|
81 | 83 | def get_validator(self, schema):
|
82 |
| - format_checker = self._get_format_checker() |
83 | 84 | kwargs = {
|
84 | 85 | 'resolver': self.resolver,
|
85 |
| - 'format_checker': format_checker, |
| 86 | + 'format_checker': self.format_checker, |
86 | 87 | }
|
87 | 88 | if self.context is not None:
|
88 | 89 | kwargs[self.CONTEXT_VALIDATION[self.context]] = True
|
89 | 90 | return OAS30Validator(schema.__dict__, **kwargs)
|
90 |
| - |
91 |
| - def _get_format_checker(self): |
92 |
| - fc = copy(oas30_format_checker) |
93 |
| - for name, formatter in self.custom_formatters.items(): |
94 |
| - fc.checks(name)(formatter.validate) |
95 |
| - return fc |
0 commit comments