From 9a624437f4495464678fb7f3507e76122fc032f9 Mon Sep 17 00:00:00 2001 From: "Kirill A. Golubev" Date: Mon, 2 Aug 2021 14:46:05 +0300 Subject: [PATCH] add support of Optional[Union[T]] --- aiohttp_pydantic/oas/view.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/aiohttp_pydantic/oas/view.py b/aiohttp_pydantic/oas/view.py index b2fc9e5..e75ac7f 100644 --- a/aiohttp_pydantic/oas/view.py +++ b/aiohttp_pydantic/oas/view.py @@ -26,7 +26,7 @@ def _handle_optional(type_): """ if typing.get_origin(type_) is typing.Union: args = typing.get_args(type_) - if len(args) == 2 and type(None) in args: + if len(args) >= 2 and type(None) in args: return next(iter(set(args) - {type(None)})) return None