From fae2d8ae44ca38b57b5f7005b5ed53c7a9e2c25a Mon Sep 17 00:00:00 2001 From: annatisch Date: Mon, 9 May 2016 10:58:52 -0700 Subject: [PATCH] Change body serialization for complex type --- .../AzureLongRunningMethodTemplate.cshtml | 29 +++++++++++++----- .../AzurePagingMethodTemplate.cshtml | 22 +++++++++++--- .../Python/Templates/MethodTemplate.cshtml | 30 ++++++++++++++----- 3 files changed, 62 insertions(+), 19 deletions(-) diff --git a/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml b/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml index 78533cd451225..d7911a1260236 100644 --- a/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml +++ b/AutoRest/Generators/Python/Azure.Python/Templates/AzureLongRunningMethodTemplate.cshtml @@ -64,17 +64,32 @@ { @:body_content = upload_gen(@parameter.Name) break; - } + } + } } - } - else if (Model.RequestBody.IsRequired) - { + else if (Model.RequestBody.IsRequired) + { + + if (Model.RequestBody.Type is CompositeType) + { + @:body_content = self._serialize.body(@Model.RequestBody.Name, models.@(Model.RequestBody.Type.ToPythonRuntimeTypeString())) + } + else + { @:body_content = self._serialize.body(@Model.RequestBody.Name, '@(Model.RequestBody.Type.ToPythonRuntimeTypeString())') - } - else - { + } + } + else + { @:if @Model.RequestBody.Name is not None: + if (Model.RequestBody.Type is CompositeType) + { + @:body_content = self._serialize.body(@Model.RequestBody.Name, models.@(Model.RequestBody.Type.ToPythonRuntimeTypeString())) + } + else + { @:body_content = self._serialize.body(@Model.RequestBody.Name, '@(Model.RequestBody.Type.ToPythonRuntimeTypeString())') + } @:else: @:body_content = None } diff --git a/AutoRest/Generators/Python/Azure.Python/Templates/AzurePagingMethodTemplate.cshtml b/AutoRest/Generators/Python/Azure.Python/Templates/AzurePagingMethodTemplate.cshtml index 9e3ddbbf618ec..496b19a0bee76 100644 --- a/AutoRest/Generators/Python/Azure.Python/Templates/AzurePagingMethodTemplate.cshtml +++ b/AutoRest/Generators/Python/Azure.Python/Templates/AzurePagingMethodTemplate.cshtml @@ -59,13 +59,27 @@ { @:# Construct body if (Model.RequestBody.IsRequired) - { + { + if (Model.RequestBody.Type is CompositeType) + { + @:body_content = self._serialize.body(@Model.RequestBody.Name, models.@(Model.RequestBody.Type.ToPythonRuntimeTypeString())) + } + else + { @:body_content = self._serialize.body(@Model.RequestBody.Name, '@(Model.RequestBody.Type.ToPythonRuntimeTypeString())') - } - else - { + } + } + else + { @:if @Model.RequestBody.Name is not None: + if (Model.RequestBody.Type is CompositeType) + { + @:body_content = self._serialize.body(@Model.RequestBody.Name, models.@(Model.RequestBody.Type.ToPythonRuntimeTypeString())) + } + else + { @:body_content = self._serialize.body(@Model.RequestBody.Name, '@(Model.RequestBody.Type.ToPythonRuntimeTypeString())') + } @:else: @:body_content = None } diff --git a/AutoRest/Generators/Python/Python/Templates/MethodTemplate.cshtml b/AutoRest/Generators/Python/Python/Templates/MethodTemplate.cshtml index 6cd57e9b0253d..a97a9c8921c19 100644 --- a/AutoRest/Generators/Python/Python/Templates/MethodTemplate.cshtml +++ b/AutoRest/Generators/Python/Python/Templates/MethodTemplate.cshtml @@ -64,17 +64,31 @@ { @:body_content = self._client.stream_upload(@parameter.Name, callback) break; - } - } - } - else if (Model.RequestBody.IsRequired) - { + } + } + } + else if (Model.RequestBody.IsRequired) + { + if (Model.RequestBody.Type is CompositeType) + { + @:body_content = self._serialize.body(@Model.RequestBody.Name, models.@(Model.RequestBody.Type.ToPythonRuntimeTypeString())) + } + else + { @:body_content = self._serialize.body(@Model.RequestBody.Name, '@(Model.RequestBody.Type.ToPythonRuntimeTypeString())') - } - else - { + } + } + else + { @:if @Model.RequestBody.Name is not None: + if (Model.RequestBody.Type is CompositeType) + { + @:body_content = self._serialize.body(@Model.RequestBody.Name, models.@(Model.RequestBody.Type.ToPythonRuntimeTypeString())) + } + else + { @:body_content = self._serialize.body(@Model.RequestBody.Name, '@(Model.RequestBody.Type.ToPythonRuntimeTypeString())') + } @:else: @:body_content = None }