5
5
6
6
from six import iteritems
7
7
8
- from openapi_core .exceptions import (
9
- InvalidValueType , UndefinedSchemaProperty , MissingProperty , InvalidValue ,
10
- )
11
8
from openapi_core .extensions .models .factories import ModelFactory
12
9
from openapi_core .schema .schemas .enums import SchemaType , SchemaFormat
10
+ from openapi_core .schema .schemas .exceptions import (
11
+ InvalidSchemaValue , UndefinedSchemaProperty , MissingSchemaProperty ,
12
+ )
13
13
from openapi_core .schema .schemas .util import forcebool
14
14
15
15
log = logging .getLogger (__name__ )
@@ -74,7 +74,7 @@ def cast(self, value):
74
74
"""Cast value to schema type"""
75
75
if value is None :
76
76
if not self .nullable :
77
- raise InvalidValueType ("Null value for non-nullable schema" )
77
+ raise InvalidSchemaValue ("Null value for non-nullable schema" )
78
78
return self .default
79
79
80
80
if self .type is None :
@@ -89,7 +89,7 @@ def cast(self, value):
89
89
try :
90
90
return cast_callable (value )
91
91
except ValueError :
92
- raise InvalidValueType (
92
+ raise InvalidSchemaValue (
93
93
"Failed to cast value of {0} to {1}" .format (value , self .type )
94
94
)
95
95
@@ -104,7 +104,7 @@ def unmarshal(self, value):
104
104
return None
105
105
106
106
if self .enum and casted not in self .enum :
107
- raise InvalidValue (
107
+ raise InvalidSchemaValue (
108
108
"Value of {0} not in enum choices: {1}" .format (
109
109
value , self .enum )
110
110
)
@@ -116,7 +116,8 @@ def _unmarshal_collection(self, value):
116
116
117
117
def _unmarshal_object (self , value ):
118
118
if not isinstance (value , (dict , )):
119
- raise InvalidValueType ("Value of {0} not an object" .format (value ))
119
+ raise InvalidSchemaValue (
120
+ "Value of {0} not an object" .format (value ))
120
121
121
122
all_properties = self .get_all_properties ()
122
123
all_required_properties = self .get_all_required_properties ()
@@ -135,7 +136,7 @@ def _unmarshal_object(self, value):
135
136
prop_value = value [prop_name ]
136
137
except KeyError :
137
138
if prop_name in all_required_properties :
138
- raise MissingProperty (
139
+ raise MissingSchemaProperty (
139
140
"Missing schema property {0}" .format (prop_name ))
140
141
if not prop .nullable and not prop .default :
141
142
continue
0 commit comments