From 8773ca9cd6c2f1bbe9aeb1a1b1c1d7a13e9d0012 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?V=C3=ADctor=20D=C3=ADaz=20Marco?= Date: Thu, 18 Jan 2024 17:42:31 +0100 Subject: [PATCH] Fix "primary_ip" nullable type. --- api/openapi.yaml | 3 +++ scripts/fix-spec.py | 12 +++++++++--- 2 files changed, 12 insertions(+), 3 deletions(-) diff --git a/api/openapi.yaml b/api/openapi.yaml index 0270d9db3a..c7bb24cd84 100644 --- a/api/openapi.yaml +++ b/api/openapi.yaml @@ -98504,6 +98504,7 @@ components: allOf: - $ref: '#/components/schemas/NestedIPAddress' readOnly: true + nullable: true primary_ip4: allOf: - $ref: '#/components/schemas/NestedIPAddress' @@ -99406,6 +99407,7 @@ components: allOf: - $ref: '#/components/schemas/NestedIPAddress' readOnly: true + nullable: true primary_ip4: allOf: - $ref: '#/components/schemas/NestedIPAddress' @@ -131389,6 +131391,7 @@ components: allOf: - $ref: '#/components/schemas/NestedIPAddress' readOnly: true + nullable: true primary_ip4: allOf: - $ref: '#/components/schemas/NestedIPAddress' diff --git a/scripts/fix-spec.py b/scripts/fix-spec.py index e3e3f403b9..926763bdb8 100755 --- a/scripts/fix-spec.py +++ b/scripts/fix-spec.py @@ -19,9 +19,15 @@ if 'properties' in prop and 'value' in prop['properties'] and 'enum' in prop['properties']['value'] and None in prop['properties']['value']['enum']: prop['properties']['value']['enum'].remove(None) - # Fix "parent_device" nullable type - if 'parent_device' in schema['properties']: - schema['properties']['parent_device']['nullable'] = True + # Fix nullable types + nullable_types = [ + 'parent_device', + 'primary_ip', + ] + + for ntype in nullable_types: + if ntype in schema['properties']: + schema['properties'][ntype]['nullable'] = True # Save the spec file with open(SPEC_PATH, 'w') as file: