From f5b58b5f96039c4fcae55ffc3a704347e4ff0a13 Mon Sep 17 00:00:00 2001 From: Artem Goncharov Date: Mon, 9 Dec 2024 14:38:28 +0100 Subject: [PATCH] Fix LB failover schemas LB and amphora failover schemas are explicit null. Without that generated code fails with `Request must be a JSON dict`. Change-Id: Ic2a8b46e1c29b0a1e85efe8757d241d3c31b28aa --- codegenerator/openapi/octavia.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/codegenerator/openapi/octavia.py b/codegenerator/openapi/octavia.py index 368c4a1..eea7b28 100644 --- a/codegenerator/openapi/octavia.py +++ b/codegenerator/openapi/octavia.py @@ -19,6 +19,7 @@ from unittest import mock import fixtures from codegenerator.common.schema import SpecSchema +from codegenerator.common.schema import TypeSchema from codegenerator.openapi.base import ( OpenStackServerSourceBase, _convert_wsme_to_jsonschema, @@ -1169,3 +1170,34 @@ class OctaviaGenerator(OpenStackServerSourceBase): response_body_schema, expected_errors, ) + + def _get_schema_ref( + self, + openapi_spec, + name, + description=None, + schema_def=None, + action_name=None, + ): + schema: None = None + ref: str | None + mime_type: str | None = "application/json" + + if name in [ + "LbaasLoadbalancersFailoverFailoverRequest", + "OctaviaAmphoraeFailoverFailoverRequest", + ]: + schema = openapi_spec.components.schemas.setdefault( + name, TypeSchema(type="null") + ) + ref = f"#/components/schemas/{name}" + else: + (ref, mime_type) = super()._get_schema_ref( + openapi_spec, + name, + description, + schema_def=schema_def, + action_name=action_name, + ) + + return (ref, mime_type)

AltStyle によって変換されたページ (->オリジナル) /