From c5ea931ca75b631a1fe1a4f61018e0365ece6425 Mon Sep 17 00:00:00 2001 From: necusjz Date: Thu, 11 Apr 2024 16:50:36 +0800 Subject: [PATCH] chore: narrow down to delete operation --- src/aaz_dev/swagger/model/schema/cmd_builder.py | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 deletions(-) diff --git a/src/aaz_dev/swagger/model/schema/cmd_builder.py b/src/aaz_dev/swagger/model/schema/cmd_builder.py index c0708334..343e2400 100644 --- a/src/aaz_dev/swagger/model/schema/cmd_builder.py +++ b/src/aaz_dev/swagger/model/schema/cmd_builder.py @@ -24,6 +24,7 @@ CMDClsSchema, CMDClsSchemaBase, \ CMDHttpResponseJsonBody +from swagger.model.specs._utils import operation_id_separate from swagger.utils import exceptions from .fields import MutabilityEnum from .response import Response @@ -588,13 +589,19 @@ def classify_responses(schema): success_codes = reduce(lambda x, y: x | y, [codes for codes, _ in success_responses]) if schema.x_ms_long_running_operation and not success_codes & {200, 201}: - lro_response = Response() - lro_response.description = "Response schema for long-running operation." - if lro_schema := schema.x_ms_lro_final_state_schema: - lro_response.schema = lro_schema # use `final-state-schema` as response + lro_response = Response() + lro_response.description = "Response schema for long-running operation." + lro_response.schema = lro_schema + + success_responses.append(({200, 201}, lro_response)) # use `final-state-schema` as response - success_responses.append(({200, 201}, lro_response)) + elif operation_id_separate(schema.operation_id)[-1][0] == "delete": + lro_response = Response() + lro_response.description = "Response schema for long-running operation." + success_responses.append(({200, 201}, lro_response)) + else: + logger.warning(f"No response schema for long-running-operation: {schema.operation_id}.") # # default response # if 'default' not in error_responses and len(error_responses) == 1: