Skip to content

Commit

Permalink
Implement x-ms-parameterized-host extension for ruby
Browse files Browse the repository at this point in the history
Default value of method parameters should not be double escaped when string
  • Loading branch information
vishrutshah committed May 1, 2016
1 parent 5101bc7 commit 590f07d
Show file tree
Hide file tree
Showing 8 changed files with 330 additions and 186 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
# encoding: utf-8

$: << 'RspecTests/Generated/custom_base_uri_more'

require 'custom_base_url_more_options'
require 'uri'

module CustomBaseUriMoreModule
describe 'Custom base uri more options' do
before(:all) do
url = URI(ENV['StubServerURI'])
@vault = "http://#{url.host}"
@key_name = "key1"

dummyToken = 'dummy12321343423'
@credentials = MsRest::TokenCredentials.new(dummyToken)

client = CustomBaseUriMoreModule::AutoRestParameterizedCustomHostTestClient.new(@credentials)
client.subscription_id = 'test12'
client.instance_variable_set("@dns_suffix", ":#{url.port.to_s}")
@custom_base_url_client = CustomBaseUriMoreModule::Paths.new(client)
end

it 'should get empty' do
result = @custom_base_url_client.get_empty_async(@vault, '', @key_name).value!
expect(result.response.status).to eq(200)
end

it 'should throw on nil vault or secret' do
expect {
@custom_base_url_client.get_empty_async(nil, nil, @key_name).value!
}.to raise_error(ArgumentError)

expect {
@custom_base_url_client.get_empty_async(@vault, nil, @key_name).value!
}.to raise_error(ArgumentError)
end
end
end
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
# encoding: utf-8

$: << 'RspecTests/Generated/custom_base_uri'

require 'custom_base_url'
require 'uri'

module CustomBaseUriModule
describe 'Custom base uri' do
before(:all) do
url = URI(ENV['StubServerURI'])
@account_name = url.host

dummyToken = 'dummy12321343423'
@credentials = MsRest::TokenCredentials.new(dummyToken)

client = CustomBaseUriModule::AutoRestParameterizedHostTestClient.new(@credentials)
client.instance_variable_set("@host", ":#{url.port.to_s}")
@custom_base_url_client = CustomBaseUriModule::Paths.new(client)
end

it 'should get empty' do
result = @custom_base_url_client.get_empty_async(@account_name).value!
expect(result.response.status).to eq(200)
end

it 'should throw on nil account name' do
expect {
@custom_base_url_client.get_empty_async(nil).value!
}.to raise_error(ArgumentError)
end
end
end
17 changes: 9 additions & 8 deletions AutoRest/Generators/Ruby/Ruby/RubyCodeGenerator.cs
Original file line number Diff line number Diff line change
Expand Up @@ -111,24 +111,25 @@ public override string ImplementationFileExtension
/// <summary>
/// Normalizes client model by updating names and types to be language specific.
/// </summary>
/// <param name="serviceClientModel"></param>
public override void NormalizeClientModel(ServiceClient serviceClientModel)
/// <param name="serviceClient"></param>
public override void NormalizeClientModel(ServiceClient serviceClient)
{
PopulateAdditionalProperties(serviceClientModel);
CodeNamer.NormalizeClientModel(serviceClientModel);
CodeNamer.ResolveNameCollisions(serviceClientModel, Settings.Namespace,
Extensions.ProcessParameterizedHost(serviceClient, Settings);
PopulateAdditionalProperties(serviceClient);
CodeNamer.NormalizeClientModel(serviceClient);
CodeNamer.ResolveNameCollisions(serviceClient, Settings.Namespace,
Settings.Namespace + "::Models");
}

/// <summary>
/// Adds special properties to the service client (e.g. credentials).
/// </summary>
/// <param name="serviceClientModel">The service client.</param>
private void PopulateAdditionalProperties(ServiceClient serviceClientModel)
/// <param name="serviceClient">The service client.</param>
private void PopulateAdditionalProperties(ServiceClient serviceClient)
{
if (Settings.AddCredentials)
{
serviceClientModel.Properties.Add(new Property
serviceClient.Properties.Add(new Property
{
Name = "Credentials",
Type = new PrimaryType(KnownPrimaryType.Credentials),
Expand Down
Loading

0 comments on commit 590f07d

Please sign in to comment.