Skip to content

Commit 1f94be4

Browse files
committed
Unmarshaller factory refactor
1 parent 1aca1e4 commit 1f94be4

File tree

1 file changed

+10
-11
lines changed

1 file changed

+10
-11
lines changed

openapi_core/unmarshalling/schemas/factories.py

Lines changed: 10 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -15,18 +15,18 @@
1515

1616
class SchemaUnmarshallersFactory:
1717

18-
PRIMITIVE_UNMARSHALLERS = {
18+
UNMARSHALLERS = {
1919
'string': StringUnmarshaller,
2020
'integer': IntegerUnmarshaller,
2121
'number': NumberUnmarshaller,
2222
'boolean': BooleanUnmarshaller,
23-
}
24-
COMPLEX_UNMARSHALLERS = {
2523
'array': ArrayUnmarshaller,
2624
'object': ObjectUnmarshaller,
2725
'any': AnyUnmarshaller,
2826
}
2927

28+
COMPLEX_UNMARSHALLERS = ['array', 'object', 'any']
29+
3030
CONTEXT_VALIDATION = {
3131
UnmarshalContext.REQUEST: 'write',
3232
UnmarshalContext.RESPONSE: 'read',
@@ -51,14 +51,13 @@ def create(self, schema, type_override=None):
5151
warnings.warn("The schema is deprecated", DeprecationWarning)
5252

5353
schema_type = type_override or schema.getkey('type', 'any')
54-
if schema_type in self.PRIMITIVE_UNMARSHALLERS:
55-
klass = self.PRIMITIVE_UNMARSHALLERS[schema_type]
56-
kwargs = dict(schema=schema)
57-
58-
elif schema_type in self.COMPLEX_UNMARSHALLERS:
59-
klass = self.COMPLEX_UNMARSHALLERS[schema_type]
60-
kwargs = dict(
61-
schema=schema, unmarshallers_factory=self,
54+
55+
klass = self.UNMARSHALLERS[schema_type]
56+
kwargs = dict(schema=schema)
57+
58+
if schema_type in self.COMPLEX_UNMARSHALLERS:
59+
kwargs.update(
60+
unmarshallers_factory=self,
6261
context=self.context,
6362
)
6463

0 commit comments

Comments
 (0)