diff --git a/src/aaz_dev/command/controller/workspace_manager.py b/src/aaz_dev/command/controller/workspace_manager.py index 18f0d5c9..27a58193 100644 --- a/src/aaz_dev/command/controller/workspace_manager.py +++ b/src/aaz_dev/command/controller/workspace_manager.py @@ -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 @@ -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 [] @@ -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( diff --git a/src/aaz_dev/swagger/controller/example_generator.py b/src/aaz_dev/swagger/controller/example_generator.py index 0109fb03..e886a925 100644 --- a/src/aaz_dev/swagger/controller/example_generator.py +++ b/src/aaz_dev/swagger/controller/example_generator.py @@ -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,