Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ ipch/
*.psess
*.vsp

# VS Code settings
*.vscode

# Code analysis
*.CodeAnalysisLog.xml

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -82,7 +82,7 @@ public string DeserializePollingResponse(string variableName, IType type)
{
var builder = new IndentedStringBuilder(" ");

string serializationLogic = type.DeserializeType(this.Scope, variableName);
string serializationLogic = GetDeserializationString(type, variableName, variableName);
return builder.AppendLine(serializationLogic).ToString();
}

Expand Down Expand Up @@ -119,9 +119,9 @@ public override List<string> ClassNamespaces
get
{
return new List<string>
{
"MsRestAzure"
};
{
"MsRestAzure"
};
}
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,10 @@
// Licensed under the MIT License. See License.txt in the project root for license information.

using System.Collections.Generic;
using Microsoft.Rest.Generator.Azure.Ruby.Templates;
using Microsoft.Rest.Generator.ClientModel;
using Microsoft.Rest.Generator.Ruby;
using Microsoft.Rest.Generator.Utilities;
using Microsoft.Rest.Generator.Azure.Ruby.Templates;

namespace Microsoft.Rest.Generator.Azure.Ruby
{
Expand Down Expand Up @@ -45,36 +45,6 @@ public override string GetBaseTypeName()

return string.Empty;
}

/// <summary>
/// Generates code for model serialization.
/// </summary>
/// <param name="variableName">Variable serialize model from.</param>
/// <param name="type">The type of the model.</param>
/// <returns>The code for serialization in string format.</returns>
public override string SerializeProperty(string variableName, IType type)
{
var builder = new IndentedStringBuilder(" ");

string serializationLogic = type.AzureSerializeType(this.Scope, variableName);
builder.AppendLine(serializationLogic);

return builder.ToString();
}

/// <summary>
/// Generates code for model deserialization.
/// </summary>
/// <param name="variableName">Variable deserialize model from.</param>
/// <param name="type">The type of the model.</param>
/// <returns>The code for вуserialization in string format.</returns>
public override string DeserializeProperty(string variableName, IType type)
{
var builder = new IndentedStringBuilder(" ");

string serializationLogic = type.AzureDeserializeType(this.Scope, variableName);
return builder.AppendLine(serializationLogic).ToString();
}

/// <summary>
/// Gets the list of modules/classes which need to be included.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,10 @@ def @(Model.Name)(@(Model.MethodParameterDeclaration))
promise = promise.then do |response|
# Defining deserialization method.
deserialize_method = lambda do |parsed_response|
@(Model.DeserializePollingResponse("parsed_response", Model.ReturnType.Body))
@if(Model.ReturnType.Body != null)
{
@:@(Model.DeserializePollingResponse("parsed_response", Model.ReturnType.Body))
}
end

@EmptyLine
Expand Down Expand Up @@ -79,7 +82,10 @@ def @(Model.Name)(@(Model.MethodParameterDeclaration))
promise = promise.then do |response|
# Defining deserialization method.
deserialize_method = lambda do |parsed_response|
@(Model.DeserializePollingResponse("parsed_response", Model.ReturnType.Body))
@if(Model.ReturnType.Body != null)
{
@:@(Model.DeserializePollingResponse("parsed_response", Model.ReturnType.Body))
}
end

@EmptyLine
Expand Down
10 changes: 10 additions & 0 deletions AutoRest/Generators/Ruby/Ruby.Tests/RspecTests/string_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,8 @@

client = AutoRestSwaggerBATService.new(@credentials, @base_url)
@string_client = StringModule::String.new(client)

@enum_client = StringModule::Enum.new(client)
end

it 'should create test service' do
Expand Down Expand Up @@ -62,4 +64,12 @@
expect(result.response.status).to eq(200)
expect(result.body).to be_nil
end
it 'should support valid enum valid value' do
result = @enum_client.get_not_expandable_async().value!
expect(result.response.status).to eq(200)
expect(result.response.body).to include('red color')
end
it 'should correctly handle invalid values for enum' do
expect { @enum_client.put_not_expandable_async('orange color').value! }.to raise_error(MsRest::ValidationError)
end
end
Loading