Skip to content

Commit

Permalink
Merge pull request #350 from necusjz/narrow-down-to-delete-operation
Browse files Browse the repository at this point in the history
narrow down to delete operation
  • Loading branch information
kairu-ms authored Apr 26, 2024
2 parents 713e2c4 + c5ea931 commit d2e768c
Showing 1 changed file with 12 additions and 5 deletions.
17 changes: 12 additions & 5 deletions src/aaz_dev/swagger/model/schema/cmd_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down

0 comments on commit d2e768c

Please sign in to comment.