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