Skip to content

Commit d2e768c

Browse files
authored
Merge pull request Azure#350 from necusjz/narrow-down-to-delete-operation
narrow down to delete operation
2 parents 713e2c4 + c5ea931 commit d2e768c

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

src/aaz_dev/swagger/model/schema/cmd_builder.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
CMDClsSchema, CMDClsSchemaBase, \
2525
CMDHttpResponseJsonBody
2626

27+
from swagger.model.specs._utils import operation_id_separate
2728
from swagger.utils import exceptions
2829
from .fields import MutabilityEnum
2930
from .response import Response
@@ -588,13 +589,19 @@ def classify_responses(schema):
588589

589590
success_codes = reduce(lambda x, y: x | y, [codes for codes, _ in success_responses])
590591
if schema.x_ms_long_running_operation and not success_codes & {200, 201}:
591-
lro_response = Response()
592-
lro_response.description = "Response schema for long-running operation."
593-
594592
if lro_schema := schema.x_ms_lro_final_state_schema:
595-
lro_response.schema = lro_schema # use `final-state-schema` as response
593+
lro_response = Response()
594+
lro_response.description = "Response schema for long-running operation."
595+
lro_response.schema = lro_schema
596+
597+
success_responses.append(({200, 201}, lro_response)) # use `final-state-schema` as response
596598

597-
success_responses.append(({200, 201}, lro_response))
599+
elif operation_id_separate(schema.operation_id)[-1][0] == "delete":
600+
lro_response = Response()
601+
lro_response.description = "Response schema for long-running operation."
602+
success_responses.append(({200, 201}, lro_response))
603+
else:
604+
logger.warning(f"No response schema for long-running-operation: {schema.operation_id}.")
598605

599606
# # default response
600607
# if 'default' not in error_responses and len(error_responses) == 1:

0 commit comments

Comments
 (0)