From 5101bc72200bb48d34ec035359ca1d26e64a2491 Mon Sep 17 00:00:00 2001 From: veronicagg Date: Fri, 29 Apr 2016 18:56:13 -0700 Subject: [PATCH] Fixing arrays with collection format not replaced correctly in URLs (#990) --- .../Ruby/Ruby.Tests/RspecTests/path_spec.rb | 7 +++++++ .../TemplateModels/MethodTemplateModel.cs | 19 +++++++++++++++++-- 2 files changed, 24 insertions(+), 2 deletions(-) diff --git a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb index 7e7dc17b5f733..3c2676513fc9f 100644 --- a/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb +++ b/AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb @@ -15,6 +15,8 @@ client = AutoRestUrlTestService.new(@credentials, @base_url) @paths_client = Paths.new(client) + + @array_path = ['ArrayPath1', "begin!*'();:@ &=+$,/?#[]end", nil, ''] end it 'should create test service' do @@ -124,4 +126,9 @@ result = @paths_client.date_time_null_async('null').value! expect(result.response.status).to eq(200) end + + it 'should get array csv in path' do + result = @paths_client.array_csv_in_path_async(@array_path).value! + expect(result.response.status).to eq(200) + end end \ No newline at end of file diff --git a/AutoRest/Generators/Ruby/Ruby/TemplateModels/MethodTemplateModel.cs b/AutoRest/Generators/Ruby/Ruby/TemplateModels/MethodTemplateModel.cs index f66881e9294be..d612a9cefa007 100644 --- a/AutoRest/Generators/Ruby/Ruby/TemplateModels/MethodTemplateModel.cs +++ b/AutoRest/Generators/Ruby/Ruby/TemplateModels/MethodTemplateModel.cs @@ -8,6 +8,7 @@ using Microsoft.Rest.Generator.ClientModel; using Microsoft.Rest.Generator.Ruby.TemplateModels; using Microsoft.Rest.Generator.Utilities; +using System.Text.RegularExpressions; namespace Microsoft.Rest.Generator.Ruby { @@ -428,9 +429,23 @@ protected string ParamsToRubyDict(IEnumerable parameters foreach (var param in parameters) { string variableName = param.Name; - encodedParameters.Add(string.Format("'{0}' => {1}", param.SerializedName, variableName)); + string urlPathName = param.SerializedName; + string pat = @".*\{" + urlPathName + @"(\:\w+)\}"; + Regex r = new Regex(pat); + Match m = r.Match(Url); + if (m.Success) + { + urlPathName += m.Groups[1].Value; + } + if (param.Type is SequenceType) + { + encodedParameters.Add(string.Format("'{0}' => {1}", urlPathName, param.GetFormattedReferenceValue())); + } + else + { + encodedParameters.Add(string.Format("'{0}' => {1}", urlPathName, variableName)); + } } - return string.Format(CultureInfo.InvariantCulture, "{{{0}}}", string.Join(",", encodedParameters)); }