|
24 | 24 | CMDClsSchema, CMDClsSchemaBase, \ |
25 | 25 | CMDHttpResponseJsonBody |
26 | 26 |
|
| 27 | +from swagger.model.specs._utils import operation_id_separate |
27 | 28 | from swagger.utils import exceptions |
28 | 29 | from .fields import MutabilityEnum |
29 | 30 | from .response import Response |
@@ -588,13 +589,19 @@ def classify_responses(schema): |
588 | 589 |
|
589 | 590 | success_codes = reduce(lambda x, y: x | y, [codes for codes, _ in success_responses]) |
590 | 591 | 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 | | - |
594 | 592 | 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 |
596 | 598 |
|
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}.") |
598 | 605 |
|
599 | 606 | # # default response |
600 | 607 | # if 'default' not in error_responses and len(error_responses) == 1: |
|
0 commit comments