1616from openapi_core .schema .schemas .enums import SchemaFormat , SchemaType
1717from openapi_core .schema .schemas .exceptions import (
1818 InvalidSchemaValue , UndefinedSchemaProperty , MissingSchemaProperty ,
19- OpenAPISchemaError , NoOneOfSchema , MultipleOneOfSchema , NoValidSchema ,
19+ OpenAPISchemaError , NoValidSchema ,
2020 UndefinedItemsSchema , InvalidCustomFormatSchemaValue , InvalidSchemaProperty ,
2121 UnmarshallerStrictTypeError ,
2222)
2323from openapi_core .schema .schemas .util import (
2424 forcebool , format_date , format_datetime , format_byte , format_uuid ,
2525 format_number ,
2626)
27- from openapi_core .schema .schemas .validators import (
28- TypeValidator , AttributeValidator , OAS30Validator ,
29- )
27+ from openapi_core .schema .schemas .validators import OAS30Validator
3028
3129log = logging .getLogger (__name__ )
3230
@@ -49,36 +47,6 @@ class Schema(object):
4947 DEFAULT_UNMARSHAL_CALLABLE_GETTER = {
5048 }
5149
52- STRING_FORMAT_CALLABLE_GETTER = {
53- SchemaFormat .NONE : Format (text_type , TypeValidator (text_type )),
54- SchemaFormat .PASSWORD : Format (text_type , TypeValidator (text_type )),
55- SchemaFormat .DATE : Format (
56- format_date , TypeValidator (date , exclude = datetime )),
57- SchemaFormat .DATETIME : Format (format_datetime , TypeValidator (datetime )),
58- SchemaFormat .BINARY : Format (binary_type , TypeValidator (binary_type )),
59- SchemaFormat .UUID : Format (format_uuid , TypeValidator (UUID )),
60- SchemaFormat .BYTE : Format (format_byte , TypeValidator (text_type )),
61- }
62-
63- NUMBER_FORMAT_CALLABLE_GETTER = {
64- SchemaFormat .NONE : Format (format_number , TypeValidator (
65- integer_types + (float , ), exclude = bool )),
66- SchemaFormat .FLOAT : Format (float , TypeValidator (float )),
67- SchemaFormat .DOUBLE : Format (float , TypeValidator (float )),
68- }
69-
70- TYPE_VALIDATOR_CALLABLE_GETTER = {
71- SchemaType .ANY : lambda x : True ,
72- SchemaType .BOOLEAN : TypeValidator (bool ),
73- SchemaType .INTEGER : TypeValidator (integer_types , exclude = bool ),
74- SchemaType .NUMBER : TypeValidator (
75- integer_types + (float , ), exclude = bool ),
76- SchemaType .STRING : TypeValidator (
77- text_type , date , datetime , binary_type , UUID ),
78- SchemaType .ARRAY : TypeValidator (list , tuple ),
79- SchemaType .OBJECT : AttributeValidator ('__dict__' ),
80- }
81-
8250 def __init__ (
8351 self , schema_type = None , model = None , properties = None , items = None ,
8452 schema_format = None , required = None , default = None , nullable = False ,
@@ -304,11 +272,12 @@ def _unmarshal_any(self, value, custom_formatters=None, strict=True):
304272 continue
305273 else :
306274 if result is not None :
307- raise MultipleOneOfSchema (self .type )
275+ log .warning ("multiple valid oneOf schemas found" )
276+ continue
308277 result = unmarshalled
309278
310279 if result is None :
311- raise NoOneOfSchema ( self . type )
280+ log . warning ( "valid oneOf schema not found" )
312281
313282 return result
314283 else :
@@ -321,7 +290,8 @@ def _unmarshal_any(self, value, custom_formatters=None, strict=True):
321290 except (OpenAPISchemaError , TypeError ):
322291 continue
323292
324- raise NoValidSchema (value )
293+ log .warning ("failed to unmarshal any type" )
294+ return value
325295
326296 def _unmarshal_collection (self , value , custom_formatters = None , strict = True ):
327297 if not isinstance (value , (list , tuple )):
@@ -344,17 +314,18 @@ def _unmarshal_object(self, value, model_factory=None,
344314 properties = None
345315 for one_of_schema in self .one_of :
346316 try :
347- found_props = self ._unmarshal_properties (
317+ unmarshalled = self ._unmarshal_properties (
348318 value , one_of_schema , custom_formatters = custom_formatters )
349319 except OpenAPISchemaError :
350320 pass
351321 else :
352322 if properties is not None :
353- raise MultipleOneOfSchema (self .type )
354- properties = found_props
323+ log .warning ("multiple valid oneOf schemas found" )
324+ continue
325+ properties = unmarshalled
355326
356327 if properties is None :
357- raise NoOneOfSchema ( self . type )
328+ log . warning ( "valid oneOf schema not found" )
358329
359330 else :
360331 properties = self ._unmarshal_properties (
@@ -398,10 +369,8 @@ def _unmarshal_properties(self, value, one_of_schema=None,
398369 if not prop .nullable and not prop .default :
399370 continue
400371 prop_value = prop .default
401- try :
402- properties [prop_name ] = prop .unmarshal (
403- prop_value , custom_formatters = custom_formatters )
404- except OpenAPISchemaError as exc :
405- raise InvalidSchemaProperty (prop_name , exc )
372+
373+ properties [prop_name ] = prop .unmarshal (
374+ prop_value , custom_formatters = custom_formatters )
406375
407376 return properties
0 commit comments