Skip to content
Merged
Show file tree
Hide file tree
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: 9 additions & 8 deletions src/aaz_dev/command/controller/workspace_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from datetime import datetime

from command.model.configuration import CMDHelp, CMDResource, CMDCommandExample, CMDArg, CMDCommand, \
CMDBuildInVariants, CMDHttpOperation
CMDBuildInVariants, CMDHttpOperation, CMDInstanceUpdateOperation
from command.model.editor import CMDEditorWorkspace, CMDCommandTreeNode, CMDCommandTreeLeaf
from swagger.controller.example_generator import ExampleGenerator
from swagger.controller.command_generator import SwaggerCommandGenerator, TypespecCommandGenerator
Expand Down Expand Up @@ -471,12 +471,8 @@ def is_ready_to_skip(operations):
if len(operations) == 1 and isinstance(operations[0], CMDHttpOperation):
return False

# skip when there is more than one operation and not all operations are get requests
for op in operations:
if not isinstance(op, CMDHttpOperation) or op.http.request.method != "get":
return True

return False
# skip when there is no http operation
return all(not isinstance(op, CMDHttpOperation) for op in operations)

if is_ready_to_skip(command.operations):
return []
Expand All @@ -499,7 +495,12 @@ def generate_operations_examples_by_swagger(self, command, cmd_name):
).get_resource_in_version(resource["id"], resource["version"], resource.rp_name))

# load swagger resource
cmd_operation_ids = {op.operation_id: op for op in command.operations}
is_generic_update = {op.http.request.method for op in command.operations if isinstance(op, CMDHttpOperation)} == {'get', 'put'}
if is_generic_update:
cmd_operation_ids = {op.operation_id: op for op in command.operations if isinstance(op, CMDHttpOperation) and op.http.request.method == 'put'}
else:
cmd_operation_ids = {op.operation_id: op for op in command.operations if isinstance(op, CMDHttpOperation)}

self.swagger_example_generator.load_examples(swagger_resources)

examples = self.swagger_example_generator.create_draft_examples_by_swagger(
Expand Down
8 changes: 8 additions & 0 deletions src/aaz_dev/swagger/controller/example_generator.py
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,14 @@ def create_draft_examples_by_swagger(self, resources, command, cmd_operation_ids
)
examples = path_item.put.x_ms_examples

elif path_item.patch is not None and path_item.patch.operation_id in cmd_operation_ids:
example_builder = SwaggerExampleBuilder(
command=command,
operation=path_item.patch,
cmd_operation=cmd_operation_ids[path_item.patch.operation_id]
)
examples = path_item.patch.x_ms_examples

elif path_item.post is not None and path_item.post.operation_id in cmd_operation_ids:
example_builder = SwaggerExampleBuilder(
command=command,
Expand Down
Loading