From d78a21c04c578cac007ab18e0e330861c73e5a1e Mon Sep 17 00:00:00 2001 From: "T. Franzel" Date: Fri, 22 Dec 2023 16:31:37 +0100 Subject: [PATCH] add OAS 3.1 null case --- drf_spectacular/plumbing.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/drf_spectacular/plumbing.py b/drf_spectacular/plumbing.py index ae47f236..c5a6a03b 100644 --- a/drf_spectacular/plumbing.py +++ b/drf_spectacular/plumbing.py @@ -533,6 +533,8 @@ def append_meta(schema: _SchemaType, meta: _SchemaType) -> _SchemaType: schema['type'] = [schema['type'], 'null'] elif '$ref' in schema: schema = {'oneOf': [schema, {'type': 'null'}]} + elif len(schema) == 1 and 'oneOf' in schema: + schema['oneOf'].append({'type': 'null'}) else: assert False, 'Invalid nullable case' # pragma: no cover