Skip to content

Commit

Permalink
Fixing arrays with collection format not replaced correctly in URLs (A…
Browse files Browse the repository at this point in the history
  • Loading branch information
veronicagg authored and amarzavery committed Apr 30, 2016
1 parent 47753e5 commit 5101bc7
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 2 deletions.
7 changes: 7 additions & 0 deletions AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/path_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -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
{
Expand Down Expand Up @@ -428,9 +429,23 @@ protected string ParamsToRubyDict(IEnumerable<ParameterTemplateModel> 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));
}

Expand Down

0 comments on commit 5101bc7

Please sign in to comment.