diff --git a/src/middlewared/middlewared/plugins/pool.py b/src/middlewared/middlewared/plugins/pool.py index f77f5d2f7ed37..20b05babab5f5 100644 --- a/src/middlewared/middlewared/plugins/pool.py +++ b/src/middlewared/middlewared/plugins/pool.py @@ -54,7 +54,13 @@ def validate(self, value): def to_json_schema(self, parent=None): schema = self.value.to_json_schema(parent) - schema['anyOf'] = [{'type': schema.pop('type')}, {'type': 'string', 'enum': ['INHERIT']}] + type_schema = schema.pop('type') + schema['nullable'] = 'null' in type_schema + if schema['nullable']: + type_schema.remove('null') + if len(type_schema) == 1: + type_schema = type_schema[0] + schema['anyOf'] = [{'type': type_schema}, {'type': 'string', 'enum': ['INHERIT']}] return schema diff --git a/src/middlewared/middlewared/schema.py b/src/middlewared/middlewared/schema.py index a08709791b5b3..28dc75d2dbc35 100644 --- a/src/middlewared/middlewared/schema.py +++ b/src/middlewared/middlewared/schema.py @@ -142,6 +142,7 @@ def to_json_schema(self, parent=None): {'type': 'array'}, ], 'title': self.title, + 'nullable': True if self.null else False } if self.description: schema['description'] = self.description