From ecc63ffe51f25fa61b6e8c728244e8b5a963f3f0 Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Wed, 9 Oct 2024 09:18:59 +0200 Subject: [PATCH 1/4] fix(openapi): add missing properties in Any --- src/middlewared/middlewared/schema/adaptable_schemas.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/middlewared/middlewared/schema/adaptable_schemas.py b/src/middlewared/middlewared/schema/adaptable_schemas.py index 7ff3fb8ac5938..e094f9cafab03 100644 --- a/src/middlewared/middlewared/schema/adaptable_schemas.py +++ b/src/middlewared/middlewared/schema/adaptable_schemas.py @@ -15,8 +15,8 @@ def to_json_schema(self, parent=None): {'type': 'string'}, {'type': 'integer'}, {'type': 'boolean'}, - {'type': 'object'}, - {'type': 'array'}, + {'type': 'object', 'properties': {}}, + {'type': 'array', 'items': []}, ], 'nullable': self.null, **self._to_json_schema_common(parent), From 3e4f112d54788f9baf8f713588cf1fb080346380 Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Wed, 9 Oct 2024 09:19:38 +0200 Subject: [PATCH 2/4] fix(openapi): convert more sub-schemas --- src/middlewared/middlewared/restful.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/middlewared/middlewared/restful.py b/src/middlewared/middlewared/restful.py index d6a8db87e7091..40079ba078956 100644 --- a/src/middlewared/middlewared/restful.py +++ b/src/middlewared/middlewared/restful.py @@ -368,11 +368,13 @@ def _convert_schema(self, schema): if item.get('type') == 'null': items.remove(item) if len(items) > 1: - schema['items'] = {'oneOf': items} + schema['items'] = {'oneOf': list(map(self._convert_schema, items))} elif len(items) > 0: - schema['items'] = items[0] + schema['items'] = self._convert_schema(items[0]) else: schema['items'] = {} + if anyOf := schema.get('anyOf', None): + schema['anyOf'] = list(map(self._convert_schema, anyOf)) return schema def _returns_to_request(self, methodname, method_returns): From 2dec76e3dad5e39d8d14a2c1da7455b41fd8411a Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Wed, 9 Oct 2024 09:22:15 +0200 Subject: [PATCH 3/4] fix(openapi): fix typo --- src/middlewared/middlewared/plugins/device.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewared/middlewared/plugins/device.py b/src/middlewared/middlewared/plugins/device.py index a2805b646e6e9..46469c4faabdc 100644 --- a/src/middlewared/middlewared/plugins/device.py +++ b/src/middlewared/middlewared/plugins/device.py @@ -33,7 +33,7 @@ class Config: Str('pci_slot', required=True), Str('domain', required=True), Str('bus', required=True), - Str('slot', True), + Str('slot', required=True), ), Str('description', required=True), List('devices', items=[Dict( From b72b0b040c506e5682a53c21fdf287ad64a8e0c6 Mon Sep 17 00:00:00 2001 From: Richard Kojedzinszky Date: Wed, 9 Oct 2024 09:33:55 +0200 Subject: [PATCH 4/4] fix(openapi): fix Float json schema type --- src/middlewared/middlewared/schema/integer_schema.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/middlewared/middlewared/schema/integer_schema.py b/src/middlewared/middlewared/schema/integer_schema.py index 71a21759e625a..3f40042641e5f 100644 --- a/src/middlewared/middlewared/schema/integer_schema.py +++ b/src/middlewared/middlewared/schema/integer_schema.py @@ -56,6 +56,6 @@ def clean(self, value): def to_json_schema(self, parent=None): return { - 'type': ['float', 'null'] if self.null else 'float', + 'type': ['number', 'null'] if self.null else 'number', **self._to_json_schema_common(parent), }