diff --git a/AutoRest/Generators/Azure.Common/Azure.Common/AzureCodeGenerator.cs b/AutoRest/Generators/Azure.Common/Azure.Common/AzureCodeGenerator.cs index 4799c42173..c9eeeae029 100644 --- a/AutoRest/Generators/Azure.Common/Azure.Common/AzureCodeGenerator.cs +++ b/AutoRest/Generators/Azure.Common/Azure.Common/AzureCodeGenerator.cs @@ -219,7 +219,7 @@ public static void AddParameterGroups(ServiceClient serviceClient) foreach (Method method in serviceClient.Methods) { - //TODO: Does this group name need to be normalized later, or does that already happen? + //This group name is normalized by each languages code generator later, so it need not happen here. Dictionary> properties = new Dictionary>(); foreach (Parameter parameter in method.Parameters) { @@ -241,10 +241,10 @@ public static void AddParameterGroups(ServiceClient serviceClient) properties[parameterGroupName].Add(new Property() { IsReadOnly = false, //Since these properties are used as parameters they are never read only - Name = CodeNamer.PascalCase(parameter.Name), + Name = parameter.Name, IsRequired = parameter.IsRequired, DefaultValue = parameter.DefaultValue, - //Constraints = parameter.Constraints, TODO do these need to be copied? + //Constraints = parameter.Constraints, Omit these since we don't want to perform parameter validation Documentation = parameter.Documentation, Type = parameter.Type, SerializedName = null //Parameter is never serialized directly diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs index 23b3885b71..36fbde87d6 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs @@ -17,6 +17,7 @@ using Fixtures.Azure.AcceptanceTestsResourceFlattening.Models; using Fixtures.Azure.AcceptanceTestsSubscriptionIdApiVersion; using Fixtures.Azure.AcceptanceTestsAzureParameterGrouping; +using Fixtures.Azure.AcceptanceTestsAzureParameterGrouping.Models; using Microsoft.Rest.Azure; using Microsoft.Rest.Generator.CSharp.Azure.Tests.Properties; using Microsoft.Rest.Generator.CSharp.Tests; @@ -690,31 +691,31 @@ public void CustomNamedRequestIdTest() [Fact] public void ParameterGroupingTests() { - const int body = 1234; - const string header = "header"; - const int query = 21; - const string path = "path"; + const int bodyParameter = 1234; + const string headerParameter = "header"; + const int queryParameter = 21; + const string pathParameter = "path"; using (var client = new AutoRestParameterGroupingTestService( Fixture.Uri, new TokenCredentials(Guid.NewGuid().ToString()))) { //Valid required parameters - ParameterGroupingPostRequiredParameters requiredParameters = new ParameterGroupingPostRequiredParameters(body, path) + ParameterGroupingPostRequiredParameters requiredParameters = new ParameterGroupingPostRequiredParameters(bodyParameter, pathParameter) { - Header = header, - Query = query + Header = headerParameter, + Query = queryParameter }; client.ParameterGrouping.PostRequired(requiredParameters); //Required parameters but null optional parameters - requiredParameters = new ParameterGroupingPostRequiredParameters(body, path); + requiredParameters = new ParameterGroupingPostRequiredParameters(bodyParameter, pathParameter); client.ParameterGrouping.PostRequired(requiredParameters); //Required parameters object is not null, but a required property of the object is - requiredParameters = new ParameterGroupingPostRequiredParameters(null, path); + requiredParameters = new ParameterGroupingPostRequiredParameters(null, pathParameter); Assert.Throws(() => client.ParameterGrouping.PostRequired(requiredParameters)); //null required parameters @@ -723,8 +724,8 @@ public void ParameterGroupingTests() //Valid optional parameters ParameterGroupingPostOptionalParameters optionalParameters = new ParameterGroupingPostOptionalParameters() { - Header = header, - Query = query + Header = headerParameter, + Query = queryParameter }; client.ParameterGrouping.PostOptional(optionalParameters); @@ -733,13 +734,13 @@ public void ParameterGroupingTests() client.ParameterGrouping.PostOptional(null); //Multiple grouped parameters - FirstParameterGroup firstGroup = new FirstParameterGroup(header, query); + FirstParameterGroup firstGroup = new FirstParameterGroup(headerParameter, queryParameter); SecondParameterGroup secondGroup = new SecondParameterGroup("header2", 42); client.ParameterGrouping.PostMultipleParameterGroups(firstGroup, secondGroup); //Multiple grouped parameters -- some optional parameters omitted - firstGroup = new FirstParameterGroup(header); + firstGroup = new FirstParameterGroup(headerParameter); secondGroup = new SecondParameterGroup(queryTwo: 42); client.ParameterGrouping.PostMultipleParameterGroups(firstGroup, secondGroup); diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/FirstParameterGroup.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/FirstParameterGroup.cs similarity index 73% rename from AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/FirstParameterGroup.cs rename to AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/FirstParameterGroup.cs index cd17fb4422..84fea9add2 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/FirstParameterGroup.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/FirstParameterGroup.cs @@ -6,21 +6,9 @@ // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping.Models { using System; - using System.Linq; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; /// /// Additional parameters for the postMultipleParameterGroups operation. diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostOptionalParameters.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/ParameterGroupingPostOptionalParameters.cs similarity index 74% rename from AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostOptionalParameters.cs rename to AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/ParameterGroupingPostOptionalParameters.cs index 09209a503a..86f97e3e5c 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostOptionalParameters.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/ParameterGroupingPostOptionalParameters.cs @@ -6,21 +6,9 @@ // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping.Models { using System; - using System.Linq; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; /// /// Additional parameters for the postOptional operation. diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostRequiredParameters.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/ParameterGroupingPostRequiredParameters.cs similarity index 79% rename from AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostRequiredParameters.cs rename to AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/ParameterGroupingPostRequiredParameters.cs index 6e5bcec83c..8597fa0320 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostRequiredParameters.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/ParameterGroupingPostRequiredParameters.cs @@ -6,21 +6,9 @@ // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping.Models { using System; - using System.Linq; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; /// /// Additional parameters for the postRequired operation. diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/SecondParameterGroup.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/SecondParameterGroup.cs similarity index 73% rename from AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/SecondParameterGroup.cs rename to AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/SecondParameterGroup.cs index 20322331e1..9ddec6af01 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/SecondParameterGroup.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/SecondParameterGroup.cs @@ -6,21 +6,9 @@ // Changes may cause incorrect behavior and will be lost if the code is // regenerated. -namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping.Models { using System; - using System.Linq; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; /// /// Additional parameters for the postMultipleParameterGroups operation. diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs index 417cc21fe8..d595e43609 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs @@ -92,7 +92,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestService client ServiceClientTracing.Enter(invocationId, this, "PostRequired", tracingParameters); } // Construct URL - var url = new Uri(this.Client.BaseUri, "parameterGrouping/postRequired/{path}").ToString(); + var baseUrl = this.Client.BaseUri.AbsoluteUri; + var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "parameterGrouping/postRequired/{path}").ToString(); url = url.Replace("{path}", Uri.EscapeDataString(parameterGroupingPostRequiredParametersPath)); List queryParameters = new List(); if (parameterGroupingPostRequiredParametersQuery != null) @@ -220,7 +221,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestService client ServiceClientTracing.Enter(invocationId, this, "PostOptional", tracingParameters); } // Construct URL - var url = new Uri(this.Client.BaseUri, "parameterGrouping/postOptional").ToString(); + var baseUrl = this.Client.BaseUri.AbsoluteUri; + var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "parameterGrouping/postOptional").ToString(); List queryParameters = new List(); if (parameterGroupingPostOptionalParametersQuery != null) { @@ -349,7 +351,8 @@ internal ParameterGroupingOperations(AutoRestParameterGroupingTestService client ServiceClientTracing.Enter(invocationId, this, "PostMultipleParameterGroups", tracingParameters); } // Construct URL - var url = new Uri(this.Client.BaseUri, "parameterGrouping/postMultipleParameterGroups").ToString(); + var baseUrl = this.Client.BaseUri.AbsoluteUri; + var url = new Uri(new Uri(baseUrl + (baseUrl.EndsWith("/") ? "" : "/")), "parameterGrouping/postMultipleParameterGroups").ToString(); List queryParameters = new List(); if (firstParameterGroupQueryOne != null) { diff --git a/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs b/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs index d7b02020ab..3a5995b099 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp/AzureCSharpCodeGenerator.cs @@ -153,7 +153,7 @@ public override async Task Generate(ServiceClient serviceClient) { Model = new ParameterGroupTemplateModel(serviceClient, groupParameter) }; - await Write(parameterGroupTemplate, Path.Combine("Parameters", parameterGroupTemplate.Model.ParameterGroupType + ".cs")); + await Write(parameterGroupTemplate, Path.Combine("Models", parameterGroupTemplate.Model.ParameterGroupType + ".cs")); } } } diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs index ea6eb9894d..a4df87d5ec 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyArray using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs index 12948fab4e..e87ad1f169 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyBoolean using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs index ceb3f1f851..ebc61eee43 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyByte using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs index 3d2bdeb2b9..6844a28f89 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs index 7854e11070..985699f726 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs index 531b05d188..83853e80a2 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs index 4c4cf0b980..9779c6930f 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs index e807d42fe1..44dd4aa752 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs index 67f55bfd2e..64d2c99ba9 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs index 23593dd499..02a5993085 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyComplex using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs index 35bdde1cfe..3823a4cdd7 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyDate using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs index 868e42a5b7..39bda36316 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyDateTime using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs index 5c892ead3c..ba26c3ef61 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyDictionary using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs index 24b6e70c8d..06307a15b4 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDuration/Duration.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyDuration using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs index 501d9a1802..f3e79125db 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyFile using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs index bbe3edd8bf..1ed1398057 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyInteger using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs index d9fd842ea6..706dc2c05b 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyNumber using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs index a1bd68bb37..a7fc9d2bbb 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyString using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs index 439ef2ac1b..125842063b 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsBodyString using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs index 484c7092c2..e2ccdf2491 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHeader using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs index 6eaa570c06..c0f1f026cf 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs index d827e8e44f..1820be40b9 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs index 705f8625b7..740d441af2 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs index f27f2e837f..31e03adcfd 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs index 121c0bb2e1..9b21e0ca39 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs index 8814268a60..b81cd31aab 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs index 5c00f95c31..7774e80df3 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsHttp using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs index 640e100285..154f4305cc 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsRequiredOptional using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs index ac3a37b65d..ea644ce732 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsRequiredOptional using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs index 8d57af6cfe..98e1ca23e8 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsUrl using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs index 1d7e51aeb6..d8f049404c 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsUrl using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs index 3b94cea786..7db7cdd775 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs @@ -11,7 +11,6 @@ namespace Fixtures.AcceptanceTestsUrl using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs b/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs index fa82f613f8..b60febac11 100644 --- a/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs +++ b/AutoRest/Generators/CSharp/CSharp/CSharpCodeGenerator.cs @@ -6,8 +6,6 @@ using System.Threading.Tasks; using Microsoft.Rest.Generator.ClientModel; using Microsoft.Rest.Generator.CSharp.Templates; -using System.Collections.Generic; -using System.Linq; namespace Microsoft.Rest.Generator.CSharp { diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs index e8328933b1..8890afc5f6 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/MethodGroupTemplateModel.cs @@ -32,7 +32,7 @@ public virtual IEnumerable Usings { get { - if (this.ModelTypes.Any()) + if (this.ModelTypes.Any() || this.MethodGroups.Any()) { yield return "Models"; } diff --git a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ParameterGroupTemplateModel.cs b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ParameterGroupTemplateModel.cs index a816fbc50a..ffb2694fb8 100644 --- a/AutoRest/Generators/CSharp/CSharp/TemplateModels/ParameterGroupTemplateModel.cs +++ b/AutoRest/Generators/CSharp/CSharp/TemplateModels/ParameterGroupTemplateModel.cs @@ -30,11 +30,6 @@ public ParameterGroupTemplateModel(ServiceClient serviceClient, Parameter groupP this.Documentation = compositeType.Documentation; } - public string ParameterGroupName - { - get { return this.groupParameter.Type.Name; } - } - public string ParameterGroupType { get { return this.groupParameter.Type.Name; } diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/MethodGroupTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/MethodGroupTemplate.cshtml index 51597a0488..ab8b56e6d2 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/MethodGroupTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/MethodGroupTemplate.cshtml @@ -8,7 +8,6 @@ namespace @Settings.Namespace using System; using System.Linq; using System.Collections.Generic; - using System.Globalization; using System.Net; using System.Net.Http; using System.Net.Http.Headers; diff --git a/AutoRest/Generators/CSharp/CSharp/Templates/ParameterGroupTemplate.cshtml b/AutoRest/Generators/CSharp/CSharp/Templates/ParameterGroupTemplate.cshtml index 23e80f35c5..32d37952c6 100644 --- a/AutoRest/Generators/CSharp/CSharp/Templates/ParameterGroupTemplate.cshtml +++ b/AutoRest/Generators/CSharp/CSharp/Templates/ParameterGroupTemplate.cshtml @@ -5,21 +5,9 @@ @inherits Microsoft.Rest.Generator.Template @Header("// ") @EmptyLine -namespace @Settings.Namespace +namespace @(Settings.Namespace).Models { using System; - using System.Linq; - using System.Collections.Generic; - using System.Net; - using System.Net.Http; - using System.Net.Http.Headers; - using System.Text; - using System.Text.RegularExpressions; - using System.Threading; - using System.Threading.Tasks; - using Microsoft.Rest; - using Microsoft.Rest.Serialization; - using Newtonsoft.Json; @EmptyLine /// diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java index 5e854859a3..e299ef3c47 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java @@ -13,7 +13,7 @@ import com.microsoft.rest.credentials.ServiceClientCredentials; import com.microsoft.rest.ServiceClient; import com.squareup.okhttp.OkHttpClient; -import retrofit.RestAdapter; +import retrofit.Retrofit; /** * Initializes a new instance of the AutoRestParameterGroupingTestService class. @@ -113,10 +113,10 @@ public AutoRestParameterGroupingTestServiceImpl(String baseUri) { * * @param baseUri the base URI of the host * @param client the {@link OkHttpClient} client to use for REST calls - * @param restAdapterBuilder the builder for building up a {@link RestAdapter} + * @param retrofitBuilder the builder for building up a {@link Retrofit} */ - public AutoRestParameterGroupingTestServiceImpl(String baseUri, OkHttpClient client, RestAdapter.Builder restAdapterBuilder) { - super(client, restAdapterBuilder); + public AutoRestParameterGroupingTestServiceImpl(String baseUri, OkHttpClient client, Retrofit.Builder retrofitBuilder) { + super(client, retrofitBuilder); this.baseUri = baseUri; initialize(); } @@ -124,9 +124,9 @@ public AutoRestParameterGroupingTestServiceImpl(String baseUri, OkHttpClient cli private void initialize() { if (this.credentials != null) { - this.credentials.applyCredentialsFilter(this); + this.credentials.applyCredentialsFilter(this.client); } - RestAdapter restAdapter = restAdapterBuilder.setEndpoint(baseUri).build(); - this.parameterGrouping = new ParameterGroupingImpl(restAdapter, this); + Retrofit retrofit = retrofitBuilder.baseUrl(baseUri).build(); + this.parameterGrouping = new ParameterGroupingImpl(retrofit, this); } } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGrouping.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGrouping.java index d5c3ff1524..22665c265c 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGrouping.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGrouping.java @@ -12,8 +12,8 @@ import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceException; -import com.microsoft.rest.ServiceResponseCallback; -import retrofit.client.Response; +import retrofit.Call; +import com.squareup.okhttp.ResponseBody; import retrofit.http.POST; import retrofit.http.Body; import retrofit.http.Header; @@ -31,45 +31,37 @@ public interface ParameterGrouping { */ interface ParameterGroupingService { @POST("/parameterGrouping/postRequired/{path}") - Response postRequired(@Body int body, @Header("header") String headerParameter, @Query("query") Integer query, @Path("path") String path, @Header("accept-language") String acceptLanguage) throws ServiceException; - - @POST("/parameterGrouping/postRequired/{path}") - void postRequiredAsync(@Body int body, @Header("header") String headerParameter, @Query("query") Integer query, @Path("path") String path, @Header("accept-language") String acceptLanguage, ServiceResponseCallback cb); + Call postRequired(@Path("path") String path, @Body int body, @Header("header") String headerParameter, @Query("query") Integer query, @Header("accept-language") String acceptLanguage); @POST("/parameterGrouping/postOptional") - Response postOptional(@Header("header") String headerParameter, @Query("query") Integer query, @Header("accept-language") String acceptLanguage) throws ServiceException; - - @POST("/parameterGrouping/postOptional") - void postOptionalAsync(@Header("header") String headerParameter, @Query("query") Integer query, @Header("accept-language") String acceptLanguage, ServiceResponseCallback cb); - - @POST("/parameterGrouping/postMultipleParameterGroups") - Response postMultipleParameterGroups(@Header("header-one") String headerOne, @Query("query-one") Integer queryOne, @Header("header-two") String headerTwo, @Query("query-two") Integer queryTwo, @Header("accept-language") String acceptLanguage) throws ServiceException; + Call postOptional(@Header("header") String headerParameter, @Query("query") Integer query, @Header("accept-language") String acceptLanguage); @POST("/parameterGrouping/postMultipleParameterGroups") - void postMultipleParameterGroupsAsync(@Header("header-one") String headerOne, @Query("query-one") Integer queryOne, @Header("header-two") String headerTwo, @Query("query-two") Integer queryTwo, @Header("accept-language") String acceptLanguage, ServiceResponseCallback cb); + Call postMultipleParameterGroups(@Header("header-one") String headerOne, @Query("query-one") Integer queryOne, @Header("header-two") String headerTwo, @Query("query-two") Integer queryTwo, @Header("accept-language") String acceptLanguage); } /** * Post a bunch of required parameters grouped * - * @param body the int value * @param path Path parameter + * @param body the int value * @param headerParameter the String value * @param query Query parameter with default * @throws ServiceException the exception wrapped in ServiceException if failed. */ - void postRequired(int body, String path, String headerParameter, Integer query) throws ServiceException; + void postRequired(String path, int body, String headerParameter, Integer query) throws ServiceException; /** * Post a bunch of required parameters grouped * - * @param body the int value * @param path Path parameter + * @param body the int value * @param headerParameter the String value * @param query Query parameter with default * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object */ - void postRequiredAsync(int body, String path, String headerParameter, Integer query, final ServiceCallback serviceCallback); + Call postRequiredAsync(String path, int body, String headerParameter, Integer query, final ServiceCallback serviceCallback); /** * Post a bunch of optional parameters grouped @@ -86,8 +78,9 @@ interface ParameterGroupingService { * @param headerParameter the String value * @param query Query parameter with default * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object */ - void postOptionalAsync(String headerParameter, Integer query, final ServiceCallback serviceCallback); + Call postOptionalAsync(String headerParameter, Integer query, final ServiceCallback serviceCallback); /** * Post parameters from multiple different parameter groups @@ -108,7 +101,8 @@ interface ParameterGroupingService { * @param headerTwo the String value * @param queryTwo Query parameter with default * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + * @return the {@link Call} object */ - void postMultipleParameterGroupsAsync(String headerOne, Integer queryOne, String headerTwo, Integer queryTwo, final ServiceCallback serviceCallback); + Call postMultipleParameterGroupsAsync(String headerOne, Integer queryOne, String headerTwo, Integer queryTwo, final ServiceCallback serviceCallback); } diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupingImpl.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupingImpl.java index 3328c0ec03..3ecdfacd36 100644 --- a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupingImpl.java +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupingImpl.java @@ -10,80 +10,86 @@ package fixtures.azureparametergrouping; -import com.google.gson.reflect.TypeToken; +import com.google.common.reflect.TypeToken; import com.microsoft.rest.ServiceCallback; import com.microsoft.rest.ServiceException; import com.microsoft.rest.ServiceResponse; import com.microsoft.rest.ServiceResponseBuilder; import com.microsoft.rest.ServiceResponseCallback; -import retrofit.RestAdapter; -import retrofit.RetrofitError; -import retrofit.client.Response; +import com.microsoft.rest.ServiceResponseEmptyCallback; +import com.squareup.okhttp.ResponseBody; +import retrofit.Retrofit; +import retrofit.Call; +import retrofit.Response; import fixtures.azureparametergrouping.models.Error; public class ParameterGroupingImpl implements ParameterGrouping { private ParameterGroupingService service; AutoRestParameterGroupingTestService client; - public ParameterGroupingImpl(RestAdapter restAdapter, AutoRestParameterGroupingTestService client) { - this.service = restAdapter.create(ParameterGroupingService.class); + public ParameterGroupingImpl(Retrofit retrofit, AutoRestParameterGroupingTestService client) { + this.service = retrofit.create(ParameterGroupingService.class); this.client = client; } /** * Post a bunch of required parameters grouped * - * @param body the int value * @param path Path parameter + * @param body the int value * @param headerParameter the String value * @param query Query parameter with default * @throws ServiceException the exception wrapped in ServiceException if failed. */ - public void postRequired(int body, String path, String headerParameter, Integer query) throws ServiceException { + public void postRequired(String path, int body, String headerParameter, Integer query) throws ServiceException { if (path == null) { throw new ServiceException( new IllegalArgumentException("Parameter path is required and cannot be null.")); } try { - ServiceResponse response = postRequiredDelegate(service.postRequired(body, headerParameter, query, path, this.client.getAcceptLanguage()), null); - response.getBody(); - } catch (RetrofitError error) { - ServiceResponse response = postRequiredDelegate(error.getResponse(), error); + Call call = service.postRequired(path, body, headerParameter, query, this.client.getAcceptLanguage()); + ServiceResponse response = postRequiredDelegate(call.execute(), null); response.getBody(); + } catch (ServiceException ex) { + throw ex; + } catch (Exception ex) { + throw new ServiceException(ex); } } /** * Post a bunch of required parameters grouped * - * @param body the int value * @param path Path parameter + * @param body the int value * @param headerParameter the String value * @param query Query parameter with default * @param serviceCallback the async ServiceCallback to handle successful and failed responses. */ - public void postRequiredAsync(int body, String path, String headerParameter, Integer query, final ServiceCallback serviceCallback) { + public Call postRequiredAsync(String path, int body, String headerParameter, Integer query, final ServiceCallback serviceCallback) { if (path == null) { serviceCallback.failure(new ServiceException( new IllegalArgumentException("Parameter path is required and cannot be null."))); } - service.postRequiredAsync(body, headerParameter, query, path, this.client.getAcceptLanguage(), new ServiceResponseCallback() { + Call call = service.postRequired(path, body, headerParameter, query, this.client.getAcceptLanguage()); + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override - public void response(Response response, RetrofitError error) { + public void onResponse(Response response, Retrofit retrofit) { try { - serviceCallback.success(postRequiredDelegate(response, error)); + serviceCallback.success(postRequiredDelegate(response, retrofit)); } catch (ServiceException exception) { serviceCallback.failure(exception); } } }); + return call; } - private ServiceResponse postRequiredDelegate(Response response, RetrofitError error) throws ServiceException { + private ServiceResponse postRequiredDelegate(Response response, Retrofit retrofit) throws ServiceException { return new ServiceResponseBuilder() .register(200, new TypeToken(){}.getType()) .registerError(new TypeToken(){}.getType()) - .build(response, error); + .build(response, retrofit); } /** @@ -95,11 +101,13 @@ private ServiceResponse postRequiredDelegate(Response response, RetrofitEr */ public void postOptional(String headerParameter, Integer query) throws ServiceException { try { - ServiceResponse response = postOptionalDelegate(service.postOptional(headerParameter, query, this.client.getAcceptLanguage()), null); - response.getBody(); - } catch (RetrofitError error) { - ServiceResponse response = postOptionalDelegate(error.getResponse(), error); + Call call = service.postOptional(headerParameter, query, this.client.getAcceptLanguage()); + ServiceResponse response = postOptionalDelegate(call.execute(), null); response.getBody(); + } catch (ServiceException ex) { + throw ex; + } catch (Exception ex) { + throw new ServiceException(ex); } } @@ -110,24 +118,26 @@ public void postOptional(String headerParameter, Integer query) throws ServiceEx * @param query Query parameter with default * @param serviceCallback the async ServiceCallback to handle successful and failed responses. */ - public void postOptionalAsync(String headerParameter, Integer query, final ServiceCallback serviceCallback) { - service.postOptionalAsync(headerParameter, query, this.client.getAcceptLanguage(), new ServiceResponseCallback() { + public Call postOptionalAsync(String headerParameter, Integer query, final ServiceCallback serviceCallback) { + Call call = service.postOptional(headerParameter, query, this.client.getAcceptLanguage()); + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override - public void response(Response response, RetrofitError error) { + public void onResponse(Response response, Retrofit retrofit) { try { - serviceCallback.success(postOptionalDelegate(response, error)); + serviceCallback.success(postOptionalDelegate(response, retrofit)); } catch (ServiceException exception) { serviceCallback.failure(exception); } } }); + return call; } - private ServiceResponse postOptionalDelegate(Response response, RetrofitError error) throws ServiceException { + private ServiceResponse postOptionalDelegate(Response response, Retrofit retrofit) throws ServiceException { return new ServiceResponseBuilder() .register(200, new TypeToken(){}.getType()) .registerError(new TypeToken(){}.getType()) - .build(response, error); + .build(response, retrofit); } /** @@ -141,11 +151,13 @@ private ServiceResponse postOptionalDelegate(Response response, RetrofitEr */ public void postMultipleParameterGroups(String headerOne, Integer queryOne, String headerTwo, Integer queryTwo) throws ServiceException { try { - ServiceResponse response = postMultipleParameterGroupsDelegate(service.postMultipleParameterGroups(headerOne, queryOne, headerTwo, queryTwo, this.client.getAcceptLanguage()), null); - response.getBody(); - } catch (RetrofitError error) { - ServiceResponse response = postMultipleParameterGroupsDelegate(error.getResponse(), error); + Call call = service.postMultipleParameterGroups(headerOne, queryOne, headerTwo, queryTwo, this.client.getAcceptLanguage()); + ServiceResponse response = postMultipleParameterGroupsDelegate(call.execute(), null); response.getBody(); + } catch (ServiceException ex) { + throw ex; + } catch (Exception ex) { + throw new ServiceException(ex); } } @@ -158,24 +170,26 @@ public void postMultipleParameterGroups(String headerOne, Integer queryOne, Stri * @param queryTwo Query parameter with default * @param serviceCallback the async ServiceCallback to handle successful and failed responses. */ - public void postMultipleParameterGroupsAsync(String headerOne, Integer queryOne, String headerTwo, Integer queryTwo, final ServiceCallback serviceCallback) { - service.postMultipleParameterGroupsAsync(headerOne, queryOne, headerTwo, queryTwo, this.client.getAcceptLanguage(), new ServiceResponseCallback() { + public Call postMultipleParameterGroupsAsync(String headerOne, Integer queryOne, String headerTwo, Integer queryTwo, final ServiceCallback serviceCallback) { + Call call = service.postMultipleParameterGroups(headerOne, queryOne, headerTwo, queryTwo, this.client.getAcceptLanguage()); + call.enqueue(new ServiceResponseCallback(serviceCallback) { @Override - public void response(Response response, RetrofitError error) { + public void onResponse(Response response, Retrofit retrofit) { try { - serviceCallback.success(postMultipleParameterGroupsDelegate(response, error)); + serviceCallback.success(postMultipleParameterGroupsDelegate(response, retrofit)); } catch (ServiceException exception) { serviceCallback.failure(exception); } } }); + return call; } - private ServiceResponse postMultipleParameterGroupsDelegate(Response response, RetrofitError error) throws ServiceException { + private ServiceResponse postMultipleParameterGroupsDelegate(Response response, Retrofit retrofit) throws ServiceException { return new ServiceResponseBuilder() .register(200, new TypeToken(){}.getType()) .registerError(new TypeToken(){}.getType()) - .build(response, error); + .build(response, retrofit); } } diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS/TemplateModels/AzureMethodTemplateModel.cs b/AutoRest/Generators/NodeJS/Azure.NodeJS/TemplateModels/AzureMethodTemplateModel.cs index a16da24f67..0ec4caf746 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS/TemplateModels/AzureMethodTemplateModel.cs +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS/TemplateModels/AzureMethodTemplateModel.cs @@ -18,7 +18,6 @@ public AzureMethodTemplateModel(Method source, ServiceClient serviceClient) throw new ArgumentNullException("source"); } - this.ClientRequestIdString = AzureCodeGenerator.GetClientRequestIdString(source); this.RequestIdString = AzureCodeGenerator.GetRequestIdString(source);