Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

narrow down to delete operation #350

Merged
merged 1 commit into from
Apr 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading