Skip to content

Commit 418049e

Browse files
committed
Add NullUnmarshaller
The value 'null' is allowed in OpenAPI 3.1. Signed-off-by: Stephen Finucane <stephen@that.guru>
1 parent a2b31c9 commit 418049e

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

openapi_core/unmarshalling/schemas/factories.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
from openapi_core.unmarshalling.schemas.unmarshallers import (
3131
IntegerUnmarshaller,
3232
)
33+
from openapi_core.unmarshalling.schemas.unmarshallers import NullUnmarshaller
3334
from openapi_core.unmarshalling.schemas.unmarshallers import NumberUnmarshaller
3435
from openapi_core.unmarshalling.schemas.unmarshallers import ObjectUnmarshaller
3536
from openapi_core.unmarshalling.schemas.unmarshallers import StringUnmarshaller
@@ -45,6 +46,7 @@ class SchemaUnmarshallersFactory:
4546
"boolean": BooleanUnmarshaller,
4647
"array": ArrayUnmarshaller,
4748
"object": ObjectUnmarshaller,
49+
"null": NullUnmarshaller,
4850
"any": AnyUnmarshaller,
4951
}
5052

openapi_core/unmarshalling/schemas/unmarshallers.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
from functools import partial
33
from typing import TYPE_CHECKING
44
from typing import Any
5-
from typing import Dict
65
from typing import Iterable
76
from typing import List
87
from typing import Optional
@@ -12,6 +11,7 @@
1211
from jsonschema._types import is_array
1312
from jsonschema._types import is_bool
1413
from jsonschema._types import is_integer
14+
from jsonschema._types import is_null
1515
from jsonschema._types import is_number
1616
from jsonschema._types import is_object
1717
from jsonschema.protocols import Validator
@@ -159,6 +159,13 @@ class BooleanUnmarshaller(BaseSchemaUnmarshaller):
159159
}
160160

161161

162+
class NullUnmarshaller(BaseSchemaUnmarshaller):
163+
164+
FORMATTERS: FormattersDict = {
165+
None: Formatter.from_callables(partial(is_null, None), None),
166+
}
167+
168+
162169
class ComplexUnmarshaller(BaseSchemaUnmarshaller):
163170
def __init__(
164171
self,

0 commit comments

Comments
 (0)