Fix role_assignments command

In the cli generation it was assumed that the first element in the
response schema is the object itself. That is used to check whether the
response is list or not. Now the role_assignment schema return `links`
object first breaking that assumption. Extend the check to first look at
the `response_key` that we identified previously.

Change-Id: Ib2cf6e394486ebd0a475ed3d9bba97feefcd5205
This commit is contained in:
Artem Goncharov
2025-05-17 12:25:57 +02:00
parent d201f9a6d9
commit d3f1f124e5

View File

@@ -901,7 +901,7 @@ class RustCliGenerator(BaseGenerator):
) )
if response: if response:
response_key: str response_key: str | None
if args.response_key: if args.response_key:
response_key = ( response_key = (
args.response_key args.response_key
@@ -910,7 +910,7 @@ class RustCliGenerator(BaseGenerator):
) )
else: else:
response_key = resource_name response_key = resource_name
response_def, _ = common.find_resource_schema( response_def, response_key = common.find_resource_schema(
response, None, response_key response, None, response_key
) )
@@ -960,9 +960,15 @@ class RustCliGenerator(BaseGenerator):
) )
response_props = response.get("properties", {}) response_props = response.get("properties", {})
if ( if response_props and (
response_props (
and response_props[ response_key
and response_props.get(response_key, {}).get(
"type"
)
== "array"
)
or response_props[
list(response_props.keys())[0] list(response_props.keys())[0]
].get("type") ].get("type")
== "array" == "array"