From 105ea6af98cceaf4f0ea09b0ba75b7af41ddbc57 Mon Sep 17 00:00:00 2001 From: matthchr Date: Mon, 5 Oct 2015 16:12:04 -0700 Subject: [PATCH] Add ParameterGrouping extension tests - Only C#/NodeJS supported right now. --- .../Azure.CSharp.Tests/AcceptanceTests.cs | 47 +++ .../AutoRestParameterGroupingTestService.cs | 198 +++++++++++ ...tParameterGroupingTestServiceExtensions.cs | 23 ++ .../IAutoRestParameterGroupingTestService.cs | 60 ++++ .../IParameterGroupingOperations.cs | 52 +++ .../AzureParameterGrouping/Models/Error.cs | 34 ++ .../ParameterGroupingOperations.cs | 319 ++++++++++++++++++ .../ParameterGroupingOperationsExtensions.cs | 85 +++++ ...ParameterGroupingPostOptionalParameters.cs | 55 +++ ...ParameterGroupingPostRequiredParameters.cs | 71 ++++ .../AcceptanceTests/BodyArray/Array.cs | 1 + .../AcceptanceTests/BodyBoolean/BoolModel.cs | 1 + .../AcceptanceTests/BodyByte/ByteModel.cs | 1 + .../AcceptanceTests/BodyComplex/Array.cs | 1 + .../BodyComplex/BasicOperations.cs | 1 + .../AcceptanceTests/BodyComplex/Dictionary.cs | 1 + .../BodyComplex/Inheritance.cs | 1 + .../BodyComplex/Polymorphicrecursive.cs | 1 + .../BodyComplex/Polymorphism.cs | 1 + .../AcceptanceTests/BodyComplex/Primitive.cs | 1 + .../Expected/AcceptanceTests/BodyDate/Date.cs | 1 + .../AcceptanceTests/BodyDateTime/Datetime.cs | 1 + .../BodyDictionary/Dictionary.cs | 1 + .../AcceptanceTests/BodyFile/Files.cs | 1 + .../AcceptanceTests/BodyInteger/IntModel.cs | 1 + .../AcceptanceTests/BodyNumber/Number.cs | 1 + .../AcceptanceTests/BodyString/EnumModel.cs | 1 + .../AcceptanceTests/BodyString/StringModel.cs | 1 + .../Expected/AcceptanceTests/Header/Header.cs | 1 + .../AcceptanceTests/Http/HttpClientFailure.cs | 1 + .../AcceptanceTests/Http/HttpFailure.cs | 1 + .../AcceptanceTests/Http/HttpRedirects.cs | 1 + .../AcceptanceTests/Http/HttpRetry.cs | 1 + .../AcceptanceTests/Http/HttpServerFailure.cs | 1 + .../AcceptanceTests/Http/HttpSuccess.cs | 1 + .../AcceptanceTests/Http/MultipleResponses.cs | 1 + .../RequiredOptional/ExplicitModel.cs | 1 + .../RequiredOptional/ImplicitModel.cs | 1 + .../Expected/AcceptanceTests/Url/PathItems.cs | 1 + .../Expected/AcceptanceTests/Url/Paths.cs | 1 + .../Expected/AcceptanceTests/Url/Queries.cs | 1 + .../AutoRestParameterGroupingTestService.java | 66 ++++ ...oRestParameterGroupingTestServiceImpl.java | 132 ++++++++ .../ParameterGrouping.java | 86 +++++ .../ParameterGroupingImpl.java | 133 ++++++++ .../models/CloudError.java | 18 + .../azureparametergrouping/models/Error.java | 64 ++++ .../AcceptanceTests/coverage.js | 1 + .../AcceptanceTests/parameterGrouping.js | 84 +++++ .../AcceptanceTests/testlist.txt | 1 + .../Azure.NodeJS.Tests.njsproj | 77 +---- .../autoRestParameterGroupingTestService.js | 67 ++++ .../models/errorModel.js | 79 +++++ .../AzureParameterGrouping/models/index.js | 22 ++ .../operations/index.js | 17 + .../operations/parameterGrouping.js | 309 +++++++++++++++++ .../autoRestReportServiceForAzure.js | 2 +- .../operations/apiVersionDefault.js | 8 +- .../operations/apiVersionLocal.js | 8 +- .../AzureSpecials/operations/header.js | 4 +- .../operations/skipUrlEncoding.js | 14 +- .../operations/subscriptionInCredentials.js | 10 +- .../operations/subscriptionInMethod.js | 8 +- .../operations/xMsClientRequestId.js | 6 +- .../Head/operations/httpSuccess.js | 4 +- .../Lro/operations/lRORetrys.js | 14 +- .../AcceptanceTests/Lro/operations/lROSADs.js | 50 +-- .../AcceptanceTests/Lro/operations/lROs.js | 72 ++-- .../Lro/operations/lROsCustomHeader.js | 8 +- .../Paging/operations/paging.js | 28 +- .../autoRestResourceFlatteningTestService.js | 12 +- .../operations/storageAccounts.js | 22 +- .../operations/usageOperations.js | 2 +- .../operations/group.js | 2 +- .../Header/operations/header.js | 64 ++-- .../RequiredOptional/operations/explicit.js | 12 +- .../RequiredOptional/operations/implicit.js | 2 +- .../NodeJS/NodeJS/ClientModelExtensions.cs | 6 +- .../NodeJS/Templates/MethodTemplate.cshtml | 2 +- .../server/SwaggerBATServer.njsproj | 1 + AutoRest/TestServer/server/app.js | 4 +- .../server/routes/azureParameterGrouping.js | 35 ++ .../swagger/azure-parameter-grouping.json | 135 ++++++++ gulpfile.js | 1 + 84 files changed, 2416 insertions(+), 251 deletions(-) create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestService.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceExtensions.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestService.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IParameterGroupingOperations.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/Error.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperationsExtensions.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostOptionalParameters.cs create mode 100644 AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostRequiredParameters.cs create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGrouping.java create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupingImpl.java create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/CloudError.java create mode 100644 AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/Error.java create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/parameterGrouping.js create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autoRestParameterGroupingTestService.js create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/errorModel.js create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/index.js create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/index.js create mode 100644 AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/parameterGrouping.js create mode 100644 AutoRest/TestServer/server/routes/azureParameterGrouping.js create mode 100644 AutoRest/TestServer/swagger/azure-parameter-grouping.json diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs index 5bbeeae2e1..7841d2fb2e 100644 --- a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/AcceptanceTests.cs @@ -16,6 +16,7 @@ using Fixtures.Azure.AcceptanceTestsResourceFlattening; using Fixtures.Azure.AcceptanceTestsResourceFlattening.Models; using Fixtures.Azure.AcceptanceTestsSubscriptionIdApiVersion; +using Fixtures.Azure.AcceptanceTestsAzureParameterGrouping; using Microsoft.Rest.Azure; using Microsoft.Rest.Generator.CSharp.Azure.Tests.Properties; using Microsoft.Rest.Generator.CSharp.Tests; @@ -685,5 +686,51 @@ public void CustomNamedRequestIdTest() Assert.Equal("123", response.RequestId); } } + + public void ParameterGroupingTests() + { + const int body = 1234; + const string header = "header"; + const int query = 21; + const string path = "path"; + + using (var client = new AutoRestParameterGroupingTestService( + Fixture.Uri, + new TokenCredentials(Guid.NewGuid().ToString()))) + { + //Valid required parameters + ParameterGroupingPostRequiredParameters requiredParameters = new ParameterGroupingPostRequiredParameters(body, path) + { + Header = header, + Query = query + }; + + client.ParameterGrouping.PostRequired(requiredParameters); + + //Required parameters but null optional parameters + requiredParameters = new ParameterGroupingPostRequiredParameters(body, path); + + client.ParameterGrouping.PostRequired(requiredParameters); + + //Required parameters object is not null, but a required property of the object is + requiredParameters = new ParameterGroupingPostRequiredParameters(null, path); + Assert.Throws(() => client.ParameterGrouping.PostRequired(requiredParameters)); + + //null required parameters + Assert.Throws(() => client.ParameterGrouping.PostRequired(null)); + + //Valid optional parameters + ParameterGroupingPostOptionalParameters optionalParameters = new ParameterGroupingPostOptionalParameters() + { + Header = header, + Query = query + }; + + client.ParameterGrouping.PostOptional(optionalParameters); + + //null optional paramters + client.ParameterGrouping.PostOptional(null); + } + } } } diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestService.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestService.cs new file mode 100644 index 0000000000..5b5e4b8330 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestService.cs @@ -0,0 +1,198 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + using System; + using System.Linq; + using System.Collections.Generic; + using System.Diagnostics; + 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; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial class AutoRestParameterGroupingTestService : ServiceClient, IAutoRestParameterGroupingTestService, IAzureClient + { + /// + /// The base URI of the service. + /// + public Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + public JsonSerializerSettings SerializationSettings { get; private set; } + + /// + /// Gets or sets json deserialization settings. + /// + public JsonSerializerSettings DeserializationSettings { get; private set; } + + /// + /// The management credentials for Azure. + /// + public ServiceClientCredentials Credentials { get; private set; } + + /// + /// Gets or sets the preferred language for the response. + /// + public string AcceptLanguage { get; set; } + + /// + /// The retry timeout for Long Running Operations. + /// + public int? LongRunningOperationRetryTimeout { get; set; } + + public virtual IParameterGroupingOperations ParameterGrouping { get; private set; } + + /// + /// Initializes a new instance of the AutoRestParameterGroupingTestService class. + /// + public AutoRestParameterGroupingTestService() : base() + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestParameterGroupingTestService class. + /// + /// + /// Optional. The set of delegating handlers to insert in the http + /// client pipeline. + /// + public AutoRestParameterGroupingTestService(params DelegatingHandler[] handlers) : base(handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestParameterGroupingTestService class. + /// + /// + /// Optional. The http client handler used to handle http transport. + /// + /// + /// Optional. The set of delegating handlers to insert in the http + /// client pipeline. + /// + public AutoRestParameterGroupingTestService(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers) + { + this.Initialize(); + } + + /// + /// Initializes a new instance of the AutoRestParameterGroupingTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Optional. The set of delegating handlers to insert in the http + /// client pipeline. + /// + public AutoRestParameterGroupingTestService(Uri baseUri, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + this.BaseUri = baseUri; + } + + /// + /// Initializes a new instance of the AutoRestParameterGroupingTestService class. + /// + /// + /// Required. The management credentials for Azure. + /// + /// + /// Optional. The set of delegating handlers to insert in the http + /// client pipeline. + /// + public AutoRestParameterGroupingTestService(ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.Credentials = credentials; + } + + /// + /// Initializes a new instance of the AutoRestParameterGroupingTestService class. + /// + /// + /// Optional. The base URI of the service. + /// + /// + /// Required. The management credentials for Azure. + /// + /// + /// Optional. The set of delegating handlers to insert in the http + /// client pipeline. + /// + public AutoRestParameterGroupingTestService(Uri baseUri, ServiceClientCredentials credentials, params DelegatingHandler[] handlers) : this(handlers) + { + if (baseUri == null) + { + throw new ArgumentNullException("baseUri"); + } + if (credentials == null) + { + throw new ArgumentNullException("credentials"); + } + this.BaseUri = baseUri; + this.Credentials = credentials; + } + + /// + /// Initializes client properties. + /// + private void Initialize() + { + this.ParameterGrouping = new ParameterGroupingOperations(this); + this.BaseUri = new Uri("https://localhost"); + this.AcceptLanguage = "en-US"; + if (this.Credentials != null) + { + this.Credentials.InitializeServiceClient(this); + } + SerializationSettings = new JsonSerializerSettings + { + Formatting = Formatting.Indented, + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver() + }; + SerializationSettings.Converters.Add(new ResourceJsonConverter()); + DeserializationSettings = new JsonSerializerSettings{ + DateFormatHandling = DateFormatHandling.IsoDateFormat, + DateTimeZoneHandling = DateTimeZoneHandling.Utc, + NullValueHandling = NullValueHandling.Ignore, + ReferenceLoopHandling = ReferenceLoopHandling.Serialize, + ContractResolver = new ReadOnlyJsonContractResolver() + }; + DeserializationSettings.Converters.Add(new ResourceJsonConverter()); + DeserializationSettings.Converters.Add(new CloudErrorJsonConverter()); + } + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceExtensions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceExtensions.cs new file mode 100644 index 0000000000..0db3b10076 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/AutoRestParameterGroupingTestServiceExtensions.cs @@ -0,0 +1,23 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + public static partial class AutoRestParameterGroupingTestServiceExtensions + { + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestService.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestService.cs new file mode 100644 index 0000000000..a7e98a0267 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IAutoRestParameterGroupingTestService.cs @@ -0,0 +1,60 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// Test Infrastructure for AutoRest + /// + public partial interface IAutoRestParameterGroupingTestService + { + /// + /// The base URI of the service. + /// + Uri BaseUri { get; set; } + + /// + /// Gets or sets json serialization settings. + /// + JsonSerializerSettings SerializationSettings { get; } + + /// + /// Gets or sets json deserialization settings. + /// + JsonSerializerSettings DeserializationSettings { get; } + + /// + /// The management credentials for Azure. + /// + ServiceClientCredentials Credentials { get; } + + /// + /// Gets or sets the preferred language for the response. + /// + string AcceptLanguage { get; set; } + + /// + /// The retry timeout for Long Running Operations. + /// + int? LongRunningOperationRetryTimeout { get; set; } + + + IParameterGroupingOperations ParameterGrouping { get; } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IParameterGroupingOperations.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IParameterGroupingOperations.cs new file mode 100644 index 0000000000..1a572aa727 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/IParameterGroupingOperations.cs @@ -0,0 +1,52 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + using System; + using System.Collections.Generic; + using System.Net.Http; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + /// + /// ParameterGroupingOperations operations. + /// + public partial interface IParameterGroupingOperations + { + /// + /// Post a bunch of required parameters grouped + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task PostRequiredWithHttpMessagesAsync(ParameterGroupingPostRequiredParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + /// + /// Post a bunch of optional parameters grouped + /// + /// + /// Additional parameters for the operation + /// + /// + /// The headers that will be added to request. + /// + /// + /// The cancellation token. + /// + Task PostOptionalWithHttpMessagesAsync(ParameterGroupingPostOptionalParameters parameters = default(ParameterGroupingPostOptionalParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)); + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/Error.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/Error.cs new file mode 100644 index 0000000000..f9b65c703b --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Models/Error.cs @@ -0,0 +1,34 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping.Models +{ + using System; + using System.Linq; + using System.Collections.Generic; + using Newtonsoft.Json; + using Microsoft.Rest; + using Microsoft.Rest.Serialization; + using Microsoft.Rest.Azure; + + /// + /// + public partial class Error + { + /// + /// + [JsonProperty(PropertyName = "status")] + public int? Status { get; set; } + + /// + /// + [JsonProperty(PropertyName = "message")] + public string Message { get; set; } + + } +} 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 new file mode 100644 index 0000000000..fc18ac3877 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperations.cs @@ -0,0 +1,319 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + 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 Newtonsoft.Json; + using Microsoft.Rest.Azure; + using Models; + + /// + /// ParameterGroupingOperations operations. + /// + internal partial class ParameterGroupingOperations : IServiceOperations, IParameterGroupingOperations + { + /// + /// Initializes a new instance of the ParameterGroupingOperations class. + /// + /// + /// Reference to the service client. + /// + internal ParameterGroupingOperations(AutoRestParameterGroupingTestService client) + { + if (client == null) + { + throw new ArgumentNullException("client"); + } + this.Client = client; + } + + /// + /// Gets a reference to the AutoRestParameterGroupingTestService + /// + public AutoRestParameterGroupingTestService Client { get; private set; } + + /// + /// Post a bunch of required parameters grouped + /// + /// + /// Additional parameters for the operation/// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task PostRequiredWithHttpMessagesAsync(ParameterGroupingPostRequiredParameters parameters, Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var parametersBody = (parameters == null ? default(int?) : parameters.Body); + var parametersHeader = (parameters == null ? default(string) : parameters.Header); + var parametersQuery = (parameters == null ? default(int?) : parameters.Query); + var parametersPath = (parameters == null ? default(string) : parameters.Path); + if (parametersBody == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "body"); + } + if (parametersPath == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "path"); + } + if (parameters == null) + { + throw new ValidationException(ValidationRules.CannotBeNull, "parameters"); + } + // Tracing + bool shouldTrace = ServiceClientTracing.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("body", parametersBody); + tracingParameters.Add("header", parametersHeader); + tracingParameters.Add("query", parametersQuery); + tracingParameters.Add("path", parametersPath); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(invocationId, this, "PostRequired", tracingParameters); + } + // Construct URL + var url = new Uri(this.Client.BaseUri, "parameterGrouping/postRequired/{path}").ToString(); + url = url.Replace("{path}", Uri.EscapeDataString(parametersPath)); + List queryParameters = new List(); + if (parametersQuery != null) + { + queryParameters.Add(string.Format("query={0}", Uri.EscapeDataString(JsonConvert.SerializeObject(parametersQuery, this.Client.SerializationSettings).Trim('"')))); + } + if (queryParameters.Count > 0) + { + url += "?" + string.Join("&", queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage httpRequest = new HttpRequestMessage(); + httpRequest.Method = new HttpMethod("POST"); + httpRequest.RequestUri = new Uri(url); + // Set Headers + httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + if (parametersHeader != null) + { + if (httpRequest.Headers.Contains("header")) + { + httpRequest.Headers.Remove("header"); + } + httpRequest.Headers.TryAddWithoutValidation("header", parametersHeader); + } + if (this.Client.AcceptLanguage != null) + { + if (httpRequest.Headers.Contains("accept-language")) + { + httpRequest.Headers.Remove("accept-language"); + } + httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var header in customHeaders) + { + if (httpRequest.Headers.Contains(header.Key)) + { + httpRequest.Headers.Remove(header.Key); + } + httpRequest.Headers.TryAddWithoutValidation(header.Key, header.Value); + } + } + + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + } + // Serialize Request + string requestContent = JsonConvert.SerializeObject(parametersBody, this.Client.SerializationSettings); + httpRequest.Content = new StringContent(requestContent, Encoding.UTF8); + httpRequest.Content.Headers.ContentType = MediaTypeHeaderValue.Parse("application/json; charset=utf-8"); + // Send Request + if (shouldTrace) + { + ServiceClientTracing.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + ServiceClientTracing.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + if (!(statusCode == (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), "OK"))) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", statusCode)); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error errorBody = JsonConvert.DeserializeObject(responseContent, this.Client.DeserializationSettings); + if (errorBody != null) + { + ex.Body = errorBody; + } + ex.Request = httpRequest; + ex.Response = httpResponse; + if (shouldTrace) + { + ServiceClientTracing.Error(invocationId, ex); + } + throw ex; + } + // Create Result + var result = new AzureOperationResponse(); + result.Request = httpRequest; + result.Response = httpResponse; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (shouldTrace) + { + ServiceClientTracing.Exit(invocationId, result); + } + return result; + } + + /// + /// Post a bunch of optional parameters grouped + /// + /// + /// Additional parameters for the operation/// + /// + /// Headers that will be added to request. + /// + /// + /// The cancellation token. + /// + public async Task PostOptionalWithHttpMessagesAsync(ParameterGroupingPostOptionalParameters parameters = default(ParameterGroupingPostOptionalParameters), Dictionary> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken)) + { + var parametersHeader = (parameters == null ? default(string) : parameters.Header); + var parametersQuery = (parameters == null ? default(int?) : parameters.Query); + // Tracing + bool shouldTrace = ServiceClientTracing.IsEnabled; + string invocationId = null; + if (shouldTrace) + { + invocationId = ServiceClientTracing.NextInvocationId.ToString(); + Dictionary tracingParameters = new Dictionary(); + tracingParameters.Add("header", parametersHeader); + tracingParameters.Add("query", parametersQuery); + tracingParameters.Add("cancellationToken", cancellationToken); + ServiceClientTracing.Enter(invocationId, this, "PostOptional", tracingParameters); + } + // Construct URL + var url = new Uri(this.Client.BaseUri, "parameterGrouping/postOptional").ToString(); + List queryParameters = new List(); + if (parametersQuery != null) + { + queryParameters.Add(string.Format("query={0}", Uri.EscapeDataString(JsonConvert.SerializeObject(parametersQuery, this.Client.SerializationSettings).Trim('"')))); + } + if (queryParameters.Count > 0) + { + url += "?" + string.Join("&", queryParameters); + } + // Create HTTP transport objects + HttpRequestMessage httpRequest = new HttpRequestMessage(); + httpRequest.Method = new HttpMethod("POST"); + httpRequest.RequestUri = new Uri(url); + // Set Headers + httpRequest.Headers.TryAddWithoutValidation("x-ms-client-request-id", Guid.NewGuid().ToString()); + if (parametersHeader != null) + { + if (httpRequest.Headers.Contains("header")) + { + httpRequest.Headers.Remove("header"); + } + httpRequest.Headers.TryAddWithoutValidation("header", parametersHeader); + } + if (this.Client.AcceptLanguage != null) + { + if (httpRequest.Headers.Contains("accept-language")) + { + httpRequest.Headers.Remove("accept-language"); + } + httpRequest.Headers.TryAddWithoutValidation("accept-language", this.Client.AcceptLanguage); + } + if (customHeaders != null) + { + foreach(var header in customHeaders) + { + if (httpRequest.Headers.Contains(header.Key)) + { + httpRequest.Headers.Remove(header.Key); + } + httpRequest.Headers.TryAddWithoutValidation(header.Key, header.Value); + } + } + + // Set Credentials + if (this.Client.Credentials != null) + { + cancellationToken.ThrowIfCancellationRequested(); + await this.Client.Credentials.ProcessHttpRequestAsync(httpRequest, cancellationToken).ConfigureAwait(false); + } + // Send Request + if (shouldTrace) + { + ServiceClientTracing.SendRequest(invocationId, httpRequest); + } + cancellationToken.ThrowIfCancellationRequested(); + HttpResponseMessage httpResponse = await this.Client.HttpClient.SendAsync(httpRequest, cancellationToken).ConfigureAwait(false); + if (shouldTrace) + { + ServiceClientTracing.ReceiveResponse(invocationId, httpResponse); + } + HttpStatusCode statusCode = httpResponse.StatusCode; + cancellationToken.ThrowIfCancellationRequested(); + if (!(statusCode == (HttpStatusCode)Enum.Parse(typeof(HttpStatusCode), "OK"))) + { + var ex = new HttpOperationException(string.Format("Operation returned an invalid status code '{0}'", statusCode)); + string responseContent = await httpResponse.Content.ReadAsStringAsync().ConfigureAwait(false); + Error errorBody = JsonConvert.DeserializeObject(responseContent, this.Client.DeserializationSettings); + if (errorBody != null) + { + ex.Body = errorBody; + } + ex.Request = httpRequest; + ex.Response = httpResponse; + if (shouldTrace) + { + ServiceClientTracing.Error(invocationId, ex); + } + throw ex; + } + // Create Result + var result = new AzureOperationResponse(); + result.Request = httpRequest; + result.Response = httpResponse; + if (httpResponse.Headers.Contains("x-ms-request-id")) + { + result.RequestId = httpResponse.Headers.GetValues("x-ms-request-id").FirstOrDefault(); + } + if (shouldTrace) + { + ServiceClientTracing.Exit(invocationId, result); + } + return result; + } + + } +} diff --git a/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperationsExtensions.cs b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperationsExtensions.cs new file mode 100644 index 0000000000..51650ae5d3 --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/ParameterGroupingOperationsExtensions.cs @@ -0,0 +1,85 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + using System; + using System.Collections; + using System.Collections.Generic; + using System.Threading; + using System.Threading.Tasks; + using Microsoft.Rest; + using Microsoft.Rest.Azure; + using Models; + + public static partial class ParameterGroupingOperationsExtensions + { + /// + /// Post a bunch of required parameters grouped + /// + /// + /// The operations group for this extension method. + /// + /// + /// Additional parameters for the operation + /// + public static void PostRequired(this IParameterGroupingOperations operations, ParameterGroupingPostRequiredParameters parameters) + { + Task.Factory.StartNew(s => ((IParameterGroupingOperations)s).PostRequiredAsync(parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Post a bunch of required parameters grouped + /// + /// + /// The operations group for this extension method. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task PostRequiredAsync( this IParameterGroupingOperations operations, ParameterGroupingPostRequiredParameters parameters, CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.PostRequiredWithHttpMessagesAsync(parameters, null, cancellationToken).ConfigureAwait(false); + } + + /// + /// Post a bunch of optional parameters grouped + /// + /// + /// The operations group for this extension method. + /// + /// + /// Additional parameters for the operation + /// + public static void PostOptional(this IParameterGroupingOperations operations, ParameterGroupingPostOptionalParameters parameters = default(ParameterGroupingPostOptionalParameters)) + { + Task.Factory.StartNew(s => ((IParameterGroupingOperations)s).PostOptionalAsync(parameters), operations, CancellationToken.None, TaskCreationOptions.None, TaskScheduler.Default).Unwrap().GetAwaiter().GetResult(); + } + + /// + /// Post a bunch of optional parameters grouped + /// + /// + /// The operations group for this extension method. + /// + /// + /// Additional parameters for the operation + /// + /// + /// The cancellation token. + /// + public static async Task PostOptionalAsync( this IParameterGroupingOperations operations, ParameterGroupingPostOptionalParameters parameters = default(ParameterGroupingPostOptionalParameters), CancellationToken cancellationToken = default(CancellationToken)) + { + await operations.PostOptionalWithHttpMessagesAsync(parameters, null, cancellationToken).ConfigureAwait(false); + } + + } +} 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/Parameters/ParameterGroupingPostOptionalParameters.cs new file mode 100644 index 0000000000..09209a503a --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostOptionalParameters.cs @@ -0,0 +1,55 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + 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. + /// + public partial class ParameterGroupingPostOptionalParameters + { + /// + /// Initializes a new instance of the + /// ParameterGroupingPostOptionalParameters class. + /// + /// + /// + /// + /// Query parameter with default + /// + public ParameterGroupingPostOptionalParameters(string header = default(string), int? query = default(int?)) + { + Header = header; + Query = query; + } + + /// + /// + public string Header {get;set;} + + /// + /// Query parameter with default + /// + public int? Query {get;set;} + + } +} 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/Parameters/ParameterGroupingPostRequiredParameters.cs new file mode 100644 index 0000000000..6e5bcec83c --- /dev/null +++ b/AutoRest/Generators/CSharp/Azure.CSharp.Tests/Expected/AcceptanceTests/AzureParameterGrouping/Parameters/ParameterGroupingPostRequiredParameters.cs @@ -0,0 +1,71 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for +// license information. +// +// Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 +// Changes may cause incorrect behavior and will be lost if the code is +// regenerated. + +namespace Fixtures.Azure.AcceptanceTestsAzureParameterGrouping +{ + 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. + /// + public partial class ParameterGroupingPostRequiredParameters + { + /// + /// Initializes a new instance of the + /// ParameterGroupingPostRequiredParameters class. + /// + /// + /// + /// + /// + /// + /// Query parameter with default + /// + /// + /// Path parameter + /// + public ParameterGroupingPostRequiredParameters(int? body, string path, string header = default(string), int? query = default(int?)) + { + Body = body; + Header = header; + Query = query; + Path = path; + } + + /// + /// + public int? Body {get;set;} + + /// + /// + public string Header {get;set;} + + /// + /// Query parameter with default + /// + public int? Query {get;set;} + + /// + /// Path parameter + /// + public string Path {get;set;} + + } +} 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 7504ccb5ff..69baead23d 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyArray/Array.cs @@ -11,6 +11,7 @@ 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 8fb48838d4..873ec4b311 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyBoolean/BoolModel.cs @@ -11,6 +11,7 @@ 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 9f1a6c8507..fab6662661 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyByte/ByteModel.cs @@ -11,6 +11,7 @@ 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 7e554e8a5c..bce16d0935 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Array.cs @@ -11,6 +11,7 @@ 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 3e272ce7ae..2958e4c0cd 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/BasicOperations.cs @@ -11,6 +11,7 @@ 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 d41f01a870..b830fca80b 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Dictionary.cs @@ -11,6 +11,7 @@ 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 2a7e7410ad..226bc19347 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Inheritance.cs @@ -11,6 +11,7 @@ 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 a9c2e937e2..87778b372e 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphicrecursive.cs @@ -11,6 +11,7 @@ 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 e8d5a5a34b..d2469af0cd 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Polymorphism.cs @@ -11,6 +11,7 @@ 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 8b8e83ffba..9eb5485a1a 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyComplex/Primitive.cs @@ -11,6 +11,7 @@ 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 3c79de70ab..043a6db0eb 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDate/Date.cs @@ -11,6 +11,7 @@ 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 c98afb7672..16b4a2db54 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDateTime/Datetime.cs @@ -11,6 +11,7 @@ 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 3b923536ea..0a17ab0b67 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyDictionary/Dictionary.cs @@ -11,6 +11,7 @@ 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/BodyFile/Files.cs b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs index a8c6185125..939294a834 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyFile/Files.cs @@ -11,6 +11,7 @@ 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 8c8d66817c..398b0d691f 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyInteger/IntModel.cs @@ -11,6 +11,7 @@ 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 c00fbd342c..776fd0912f 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyNumber/Number.cs @@ -11,6 +11,7 @@ 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 61d53fce48..c3aa91cedf 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/EnumModel.cs @@ -11,6 +11,7 @@ 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 b634d1338a..be3d63669d 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/BodyString/StringModel.cs @@ -11,6 +11,7 @@ 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 f86143b462..b3fbc17166 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Header/Header.cs @@ -11,6 +11,7 @@ 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 66e5c47c2b..52006f8e94 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpClientFailure.cs @@ -11,6 +11,7 @@ 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 90eeae480c..9278a553da 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpFailure.cs @@ -11,6 +11,7 @@ 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 cd0bc20b6b..a1ec5d38da 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRedirects.cs @@ -11,6 +11,7 @@ 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 55fad84135..8d48d7eed7 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpRetry.cs @@ -11,6 +11,7 @@ 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 b92e932eac..20809701ef 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpServerFailure.cs @@ -11,6 +11,7 @@ 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 74fc45121f..f73bc51ff7 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/HttpSuccess.cs @@ -11,6 +11,7 @@ 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 2834c5543b..7311e337ff 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Http/MultipleResponses.cs @@ -11,6 +11,7 @@ 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 0381e79c85..e38094cccf 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ExplicitModel.cs @@ -11,6 +11,7 @@ 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 7b98b41b53..dbec3e5933 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/RequiredOptional/ImplicitModel.cs @@ -11,6 +11,7 @@ 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 92b2efd7de..adf7d22f69 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/PathItems.cs @@ -11,6 +11,7 @@ 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 c464fce199..e746f92dc7 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Paths.cs @@ -11,6 +11,7 @@ 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 1181adace2..2e7889b5e6 100644 --- a/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs +++ b/AutoRest/Generators/CSharp/CSharp.Tests/Expected/AcceptanceTests/Url/Queries.cs @@ -11,6 +11,7 @@ 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/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java new file mode 100644 index 0000000000..b8ad30e8fe --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestService.java @@ -0,0 +1,66 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azureparametergrouping; + +import com.microsoft.rest.credentials.ServiceClientCredentials; + +/** + * The interface for AutoRestParameterGroupingTestService class. + */ +public interface AutoRestParameterGroupingTestService { + /** + * Gets the URI used as the base for all cloud service requests. + * @return The BaseUri value. + */ + String getBaseUri(); + + /** + * Gets The management credentials for Azure.. + * + * @return the credentials value. + */ + ServiceClientCredentials getCredentials(); + + /** + * Gets Gets or sets the preferred language for the response.. + * + * @return the acceptLanguage value. + */ + String getAcceptLanguage(); + + /** + * Sets Gets or sets the preferred language for the response.. + * + * @param acceptLanguage the acceptLanguage value. + */ + void setAcceptLanguage(String acceptLanguage); + + /** + * Gets The retry timeout for Long Running Operations.. + * + * @return the longRunningOperationRetryTimeout value. + */ + int getLongRunningOperationRetryTimeout(); + + /** + * Sets The retry timeout for Long Running Operations.. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + */ + void setLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout); + + /** + * Gets the ParameterGrouping object to access its operations. + * @return the parameterGrouping value. + */ + ParameterGrouping getParameterGrouping(); + +} 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 new file mode 100644 index 0000000000..5e854859a3 --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/AutoRestParameterGroupingTestServiceImpl.java @@ -0,0 +1,132 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azureparametergrouping; + +import com.microsoft.rest.credentials.ServiceClientCredentials; +import com.microsoft.rest.ServiceClient; +import com.squareup.okhttp.OkHttpClient; +import retrofit.RestAdapter; + +/** + * Initializes a new instance of the AutoRestParameterGroupingTestService class. + */ +public class AutoRestParameterGroupingTestServiceImpl extends ServiceClient implements AutoRestParameterGroupingTestService { + private String baseUri; + + /** + * Gets the URI used as the base for all cloud service requests. + * @return The BaseUri value. + */ + public String getBaseUri() { + return this.baseUri; + } + + private ServiceClientCredentials credentials; + + /** + * Gets The management credentials for Azure. + * + * @return the credentials value. + */ + public ServiceClientCredentials getCredentials() { + return this.credentials; + } + + private String acceptLanguage; + + /** + * Gets Gets or sets the preferred language for the response. + * + * @return the acceptLanguage value. + */ + public String getAcceptLanguage() { + return this.acceptLanguage; + } + + /** + * Sets Gets or sets the preferred language for the response. + * + * @param acceptLanguage the acceptLanguage value. + */ + public void setAcceptLanguage(String acceptLanguage) { + this.acceptLanguage = acceptLanguage; + } + + private int longRunningOperationRetryTimeout; + + /** + * Gets The retry timeout for Long Running Operations. + * + * @return the longRunningOperationRetryTimeout value. + */ + public int getLongRunningOperationRetryTimeout() { + return this.longRunningOperationRetryTimeout; + } + + /** + * Sets The retry timeout for Long Running Operations. + * + * @param longRunningOperationRetryTimeout the longRunningOperationRetryTimeout value. + */ + public void setLongRunningOperationRetryTimeout(int longRunningOperationRetryTimeout) { + this.longRunningOperationRetryTimeout = longRunningOperationRetryTimeout; + } + + private ParameterGrouping parameterGrouping; + + /** + * Gets the ParameterGrouping object to access its operations. + * @return the parameterGrouping value. + */ + public ParameterGrouping getParameterGrouping() { + return this.parameterGrouping; + } + + /** + * Initializes an instance of AutoRestParameterGroupingTestService client. + */ + public AutoRestParameterGroupingTestServiceImpl() { + this("https://localhost"); + } + + /** + * Initializes an instance of AutoRestParameterGroupingTestService client. + * + * @param baseUri the base URI of the host + */ + public AutoRestParameterGroupingTestServiceImpl(String baseUri) { + super(); + this.baseUri = baseUri; + initialize(); + } + + /** + * Initializes an instance of AutoRestParameterGroupingTestService client. + * + * @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} + */ + public AutoRestParameterGroupingTestServiceImpl(String baseUri, OkHttpClient client, RestAdapter.Builder restAdapterBuilder) { + super(client, restAdapterBuilder); + this.baseUri = baseUri; + initialize(); + } + + private void initialize() { + if (this.credentials != null) + { + this.credentials.applyCredentialsFilter(this); + } + RestAdapter restAdapter = restAdapterBuilder.setEndpoint(baseUri).build(); + this.parameterGrouping = new ParameterGroupingImpl(restAdapter, 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 new file mode 100644 index 0000000000..3537e58f44 --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGrouping.java @@ -0,0 +1,86 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azureparametergrouping; + +import com.microsoft.rest.ServiceCallback; +import com.microsoft.rest.ServiceException; +import com.microsoft.rest.ServiceResponseCallback; +import retrofit.client.Response; +import retrofit.http.POST; +import retrofit.http.Body; +import retrofit.http.Header; +import retrofit.http.Query; +import retrofit.http.Path; + +/** + * An instance of this class provides access to all the operations defined + * in ParameterGrouping. + */ +public interface ParameterGrouping { + /** + * The interface defining all the services for ParameterGrouping to be + * used by Retrofit to perform actually REST calls. + */ + 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); + + @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 a bunch of required parameters grouped + * + * @param body the int value + * @param path Path parameter + * @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; + + /** + * Post a bunch of required parameters grouped + * + * @param body the int value + * @param path Path parameter + * @param headerParameter the String value + * @param query Query parameter with default + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + */ + void postRequiredAsync(int body, String path, String headerParameter, Integer query, final ServiceCallback serviceCallback); + + /** + * Post a bunch of optional parameters grouped + * + * @param headerParameter the String value + * @param query Query parameter with default + * @throws ServiceException the exception wrapped in ServiceException if failed. + */ + void postOptional(String headerParameter, Integer query) throws ServiceException; + + /** + * Post a bunch of optional parameters grouped + * + * @param headerParameter the String value + * @param query Query parameter with default + * @param serviceCallback the async ServiceCallback to handle successful and failed responses. + */ + void postOptionalAsync(String headerParameter, Integer query, 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 new file mode 100644 index 0000000000..07ecd88c13 --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/ParameterGroupingImpl.java @@ -0,0 +1,133 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azureparametergrouping; + +import com.google.gson.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 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); + this.client = client; + } + + /** + * Post a bunch of required parameters grouped + * + * @param body the int value + * @param path Path parameter + * @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 { + 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); + response.getBody(); + } + } + + /** + * Post a bunch of required parameters grouped + * + * @param body the int value + * @param path Path parameter + * @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) { + 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() { + @Override + public void response(Response response, RetrofitError error) { + try { + serviceCallback.success(postRequiredDelegate(response, error)); + } catch (ServiceException exception) { + serviceCallback.failure(exception); + } + } + }); + } + + private ServiceResponse postRequiredDelegate(Response response, RetrofitError error) throws ServiceException { + return new ServiceResponseBuilder() + .register(200, new TypeToken(){}.getType()) + .registerError(new TypeToken(){}.getType()) + .build(response, error); + } + + /** + * Post a bunch of optional parameters grouped + * + * @param headerParameter the String value + * @param query Query parameter with default + * @throws ServiceException the exception wrapped in ServiceException if failed. + */ + 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); + response.getBody(); + } + } + + /** + * Post a bunch of optional parameters grouped + * + * @param headerParameter the String value + * @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() { + @Override + public void response(Response response, RetrofitError error) { + try { + serviceCallback.success(postOptionalDelegate(response, error)); + } catch (ServiceException exception) { + serviceCallback.failure(exception); + } + } + }); + } + + private ServiceResponse postOptionalDelegate(Response response, RetrofitError error) throws ServiceException { + return new ServiceResponseBuilder() + .register(200, new TypeToken(){}.getType()) + .registerError(new TypeToken(){}.getType()) + .build(response, error); + } + +} diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/CloudError.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/CloudError.java new file mode 100644 index 0000000000..e40f9ac2e4 --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/CloudError.java @@ -0,0 +1,18 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azureparametergrouping.models; + + +/** + * The CloudError model. + */ +public class CloudError { +} diff --git a/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/Error.java b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/Error.java new file mode 100644 index 0000000000..279d935d2a --- /dev/null +++ b/AutoRest/Generators/Java/Azure.Java.Tests/src/main/java/fixtures/azureparametergrouping/models/Error.java @@ -0,0 +1,64 @@ +/** + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +package fixtures.azureparametergrouping.models; + + +/** + * The Error model. + */ +public class Error { + /** + * The status property. + */ + private Integer status; + + /** + * The message property. + */ + private String message; + + /** + * Get the status value. + * + * @return the status value + */ + public Integer getStatus() { + return this.status; + } + + /** + * Set the status value. + * + * @param status the status value to set + */ + public void setStatus(Integer status) { + this.status = status; + } + + /** + * Get the message value. + * + * @return the message value + */ + public String getMessage() { + return this.message; + } + + /** + * Set the message value. + * + * @param message the message value to set + */ + public void setMessage(String message) { + this.message = message; + } + +} diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/coverage.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/coverage.js index ba7c546c00..4ff42172c0 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/coverage.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/coverage.js @@ -29,6 +29,7 @@ describe('nodejs', function () { testClient.getReport(function (error, result) { should.not.exist(error); //console.log('The test coverage for azure is ' + util.inspect(result)); + var total = _.keys(result).length; var passed = 0; _.keys(result).forEach(function(item) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/parameterGrouping.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/parameterGrouping.js new file mode 100644 index 0000000000..2a837eb2c4 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/parameterGrouping.js @@ -0,0 +1,84 @@ +// Copyright (c) Microsoft Corporation. All rights reserved. +// Licensed under the MIT License. See License.txt in the project root for license information. + +'use strict'; + +var should = require('should'); +var http = require('http'); +var util = require('util'); +var assert = require('assert'); +var msRestAzure = require('ms-rest-azure'); + +var parametersTestClient = require('../Expected/AcceptanceTests/AzureParameterGrouping/autoRestParameterGroupingTestService'); +var dummyToken = 'dummy12321343423'; +var credentials = new msRestAzure.TokenCredentials(dummyToken); + +var clientOptions = {}; +var baseUri = 'http://localhost:3000'; + +describe('nodejs', function () { + var body = 1234; + var header = "header"; + var query = 21; + var path = "path"; + + describe('Azure Parameter Grouping', function () { + var testClient = new parametersTestClient(credentials, baseUri, clientOptions); + it('should accept valid required parameters', function (done) { + testClient.parameterGrouping.postRequired({body: body, header: header, query: query, path: path}, + function (error, result, request, response) { + should.not.exist(error); + response.statusCode.should.equal(200); + done(); + }); + }); + + it('should accept required parameters but null optional parameters', function (done) { + testClient.parameterGrouping.postRequired({body: body, path: path}, + function (error, result, request, response) { + should.not.exist(error); + response.statusCode.should.equal(200); + done(); + }); + }); + + it('should reject required parameters with missing required property', function (done) { + testClient.parameterGrouping.postRequired({path: path}, + function (error, result, request, response) { + should.exist(error); + error.message.should.match(/.*cannot be null or undefined.*/); + should.not.exist(result); + should.not.exist(response); + done(); + }); + }); + + it('should reject null required parameters', function (done) { + testClient.parameterGrouping.postRequired(null, function (error, result, request, response) { + should.exist(error); + error.message.should.match(/.*cannot be null or undefined.*/); + should.not.exist(result); + should.not.exist(response); + done(); + }); + }); + + it('should accept valid optional parameters', function (done) { + testClient.parameterGrouping.postOptional({header: header, query: query}, + function (error, result, request, response) { + should.not.exist(error); + response.statusCode.should.equal(200); + done(); + }); + }); + + it('should accept null optional parameters', function (done) { + testClient.parameterGrouping.postOptional(null, function (error, result, request, response) { + should.not.exist(error); + response.statusCode.should.equal(200); + done(); + }); + }); + + }); +}); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/testlist.txt b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/testlist.txt index 1339a2dd39..6506c9244f 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/testlist.txt +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/AcceptanceTests/testlist.txt @@ -8,5 +8,6 @@ head.js resourceFlattening.js subscriptionIdApiVersion.js azureSpecialProperties.js +parameterGrouping.js #####The following test will always be executed as the last test to get test coverage coverage.js diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Azure.NodeJS.Tests.njsproj b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Azure.NodeJS.Tests.njsproj index e628aa3e39..291a04747a 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Azure.NodeJS.Tests.njsproj +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Azure.NodeJS.Tests.njsproj @@ -19,6 +19,9 @@ + + Mocha + @@ -38,76 +41,7 @@ Mocha - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - + @@ -148,6 +82,9 @@ + + + diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autoRestParameterGroupingTestService.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autoRestParameterGroupingTestService.js new file mode 100644 index 0000000000..5b18fc1473 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/autoRestParameterGroupingTestService.js @@ -0,0 +1,67 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var util = require('util'); +var msRest = require('ms-rest'); +var msRestAzure = require('ms-rest-azure'); +var ServiceClient = msRestAzure.AzureServiceClient; +var WebResource = msRest.WebResource; + +var models = require('./models'); +var operations = require('./operations'); + +/** + * @class + * Initializes a new instance of the AutoRestParameterGroupingTestService class. + * @constructor + * + * @param {ServiceClientCredentials} credentials The management credentials for Azure. + * + * @param {string} [baseUri] - The base URI of the service. + * + * @param {object} [options] - The parameter options + * + * @param {Array} [options.filters] - Filters to be added to the request pipeline + * + * @param {object} [options.requestOptions] - Options for the underlying request object + * {@link https://github.com/request/request#requestoptions-callback Options doc} + * + * @param {bool} [options.noRetryPolicy] - If set to true, turn off default retry policy + */ +function AutoRestParameterGroupingTestService(credentials, baseUri, options) { + if (credentials === null || credentials === undefined) { + throw new Error('\'credentials\' cannot be null.'); + } + + if (!options) options = {}; + + AutoRestParameterGroupingTestService['super_'].call(this, credentials, options); + this.baseUri = baseUri; + if (!this.baseUri) { + this.baseUri = 'https://localhost'; + } + this.credentials = credentials; + + if(!this.acceptLanguage) { + this.acceptLanguage = 'en-US'; + } + this.parameterGrouping = new operations.ParameterGrouping(this); + this._models = models; +} + +util.inherits(AutoRestParameterGroupingTestService, ServiceClient); + +module.exports = AutoRestParameterGroupingTestService; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/errorModel.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/errorModel.js new file mode 100644 index 0000000000..e93e9897a5 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/errorModel.js @@ -0,0 +1,79 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +/** + * @class + * Initializes a new instance of the ErrorModel class. + * @constructor + * @member {number} [status] + * + * @member {string} [message] + * + */ +function ErrorModel(parameters) { + if (parameters !== null && parameters !== undefined) { + if (parameters.status !== undefined) { + this.status = parameters.status; + } + if (parameters.message !== undefined) { + this.message = parameters.message; + } + } +} + + +/** + * Validate the payload against the ErrorModel schema + * + * @param {JSON} payload + * + */ +ErrorModel.prototype.serialize = function () { + var payload = {}; + if (this['status'] !== null && this['status'] !== undefined) { + if (typeof this['status'] !== 'number') { + throw new Error('this[\'status\'] must be of type number.'); + } + payload['status'] = this['status']; + } + + if (this['message'] !== null && this['message'] !== undefined) { + if (typeof this['message'].valueOf() !== 'string') { + throw new Error('this[\'message\'] must be of type string.'); + } + payload['message'] = this['message']; + } + + return payload; +}; + +/** + * Deserialize the instance to ErrorModel schema + * + * @param {JSON} instance + * + */ +ErrorModel.prototype.deserialize = function (instance) { + if (instance) { + if (instance['status'] !== undefined) { + this['status'] = instance['status']; + } + + if (instance['message'] !== undefined) { + this['message'] = instance['message']; + } + } + + return this; +}; + +module.exports = ErrorModel; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/index.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/index.js new file mode 100644 index 0000000000..561fa2de84 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/models/index.js @@ -0,0 +1,22 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +var msRestAzure = require('ms-rest-azure'); + +exports.Resource = msRestAzure.Resource; +exports.SubResource = msRestAzure.SubResource; +exports.CloudError = msRestAzure.CloudError; +exports.ErrorModel = require('./errorModel'); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/index.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/index.js new file mode 100644 index 0000000000..21240e1182 --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/index.js @@ -0,0 +1,17 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +/* jshint latedef:false */ +/* jshint forin:false */ +/* jshint noempty:false */ + +'use strict'; + +exports.ParameterGrouping = require('./parameterGrouping'); diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/parameterGrouping.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/parameterGrouping.js new file mode 100644 index 0000000000..8a7fc15a6f --- /dev/null +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureParameterGrouping/operations/parameterGrouping.js @@ -0,0 +1,309 @@ +/* + * Copyright (c) Microsoft Corporation. All rights reserved. + * Licensed under the MIT License. See License.txt in the project root for + * license information. + * + * Code generated by Microsoft (R) AutoRest Code Generator 0.11.0.0 + * Changes may cause incorrect behavior and will be lost if the code is + * regenerated. + */ + +'use strict'; + +var util = require('util'); +var msRest = require('ms-rest'); +var msRestAzure = require('ms-rest-azure'); +var ServiceClient = msRest.ServiceClient; +var WebResource = msRest.WebResource; + +var models = require('../models'); + +/** + * @class + * ParameterGrouping + * __NOTE__: An instance of this class is automatically created for an + * instance of the AutoRestParameterGroupingTestService. + * Initializes a new instance of the ParameterGrouping class. + * @constructor + * + * @param {AutoRestParameterGroupingTestService} client Reference to the service client. + */ +function ParameterGrouping(client) { + this.client = client; +} + +/** + * Post a bunch of required parameters grouped + * + * @param {object} parameters Additional parameters for the operation + * + * @param {number} [parameters.body] + * + * @param {string} [parameters.header] + * + * @param {number} [parameters.query] Query parameter with default + * + * @param {string} [parameters.path] Path parameter + * + * @param {object} [options] + * + * @param {object} [options.customHeaders] headers that will be added to + * request + * + * @param {function} callback + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +ParameterGrouping.prototype.postRequired = function (parameters, options, callback) { + var client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + var parametersBody = (parameters ? parameters.body : undefined); + var parametersHeader = (parameters ? parameters.header : undefined); + var parametersQuery = (parameters ? parameters.query : undefined); + var parametersPath = (parameters ? parameters.path : undefined); + // Validate + try { + if (parametersBody === null || parametersBody === undefined || typeof parametersBody !== 'number') { + throw new Error('parametersBody cannot be null or undefined and it must be of type number.'); + } + if (parametersHeader !== null && parametersHeader !== undefined && typeof parametersHeader.valueOf() !== 'string') { + throw new Error('parametersHeader must be of type string.'); + } + if (parametersQuery !== null && parametersQuery !== undefined && typeof parametersQuery !== 'number') { + throw new Error('parametersQuery must be of type number.'); + } + if (parametersPath === null || parametersPath === undefined || typeof parametersPath.valueOf() !== 'string') { + throw new Error('parametersPath cannot be null or undefined and it must be of type string.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + if (parameters === null || parameters === undefined) { + throw new Error('parameters cannot be null or undefined.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + var requestUrl = this.client.baseUri + + '//parameterGrouping/postRequired/{path}'; + requestUrl = requestUrl.replace('{path}', encodeURIComponent(parametersPath)); + var queryParameters = []; + if (parametersQuery !== null && parametersQuery !== undefined) { + queryParameters.push('query=' + encodeURIComponent(parametersQuery.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + // trim all duplicate forward slashes in the url + var regex = /([^:]\/)\/+/gi; + requestUrl = requestUrl.replace(regex, '$1'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.headers = {}; + httpRequest.url = requestUrl; + // Set Headers + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + if (parametersHeader !== undefined && parametersHeader !== null) { + httpRequest.headers['header'] = parametersHeader; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(var headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + // Serialize Request + var requestContent = null; + var requestModel = null; + try { + if (parametersBody === null || parametersBody === undefined || typeof parametersBody !== 'number') { + throw new Error('parametersBody cannot be null or undefined and it must be of type number.'); + } + requestModel = parametersBody; + requestContent = JSON.stringify(requestModel); + } catch (error) { + var serializationError = new Error(util.format('Error "%s" occurred in serializing the payload - "%s"', error, util.inspect(requestModel, {depth: null}))); + return callback(serializationError); + } + httpRequest.body = requestContent; + httpRequest.headers['Content-Length'] = Buffer.isBuffer(requestContent) ? requestContent.length : Buffer.byteLength(requestContent, 'UTF8'); + // Send Request + return client.pipeline(httpRequest, function (err, response, responseBody) { + if (err) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = httpRequest; + error.response = response; + if (responseBody === '') responseBody = null; + var parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + error.body = new client._models['ErrorModel'](); + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + error.body.deserialize(parsedErrorResponse); + } + } catch (defaultError) { + error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody); + return callback(error); + } + return callback(error); + } + // Create Result + var result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +}; + +/** + * Post a bunch of optional parameters grouped + * + * @param {object} [parameters] Additional parameters for the operation + * + * @param {string} [parameters.header] + * + * @param {number} [parameters.query] Query parameter with default + * + * @param {object} [options] + * + * @param {object} [options.customHeaders] headers that will be added to + * request + * + * @param {function} callback + * + * @returns {function} callback(err, result, request, response) + * + * {Error} err - The Error object if an error occurred, null otherwise. + * + * {null} [result] - The deserialized result object. + * + * {object} [request] - The HTTP Request object if an error did not occur. + * + * {stream} [response] - The HTTP Response stream if an error did not occur. + */ +ParameterGrouping.prototype.postOptional = function (parameters, options, callback) { + var client = this.client; + if(!callback && typeof options === 'function') { + callback = options; + options = null; + } + if (!callback) { + throw new Error('callback cannot be null.'); + } + var parametersHeader = (parameters ? parameters.header : undefined); + var parametersQuery = (parameters ? parameters.query : undefined); + // Validate + try { + if (parametersHeader !== null && parametersHeader !== undefined && typeof parametersHeader.valueOf() !== 'string') { + throw new Error('parametersHeader must be of type string.'); + } + if (parametersQuery !== null && parametersQuery !== undefined && typeof parametersQuery !== 'number') { + throw new Error('parametersQuery must be of type number.'); + } + if (this.client.acceptLanguage !== null && this.client.acceptLanguage !== undefined && typeof this.client.acceptLanguage.valueOf() !== 'string') { + throw new Error('this.client.acceptLanguage must be of type string.'); + } + } catch (error) { + return callback(error); + } + + // Construct URL + var requestUrl = this.client.baseUri + + '//parameterGrouping/postOptional'; + var queryParameters = []; + if (parametersQuery !== null && parametersQuery !== undefined) { + queryParameters.push('query=' + encodeURIComponent(parametersQuery.toString())); + } + if (queryParameters.length > 0) { + requestUrl += '?' + queryParameters.join('&'); + } + // trim all duplicate forward slashes in the url + var regex = /([^:]\/)\/+/gi; + requestUrl = requestUrl.replace(regex, '$1'); + + // Create HTTP transport objects + var httpRequest = new WebResource(); + httpRequest.method = 'POST'; + httpRequest.headers = {}; + httpRequest.url = requestUrl; + // Set Headers + httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); + if (parametersHeader !== undefined && parametersHeader !== null) { + httpRequest.headers['header'] = parametersHeader; + } + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { + httpRequest.headers['accept-language'] = this.client.acceptLanguage; + } + if(options) { + for(var headerName in options['customHeaders']) { + if (options['customHeaders'].hasOwnProperty(headerName)) { + httpRequest.headers[headerName] = options['customHeaders'][headerName]; + } + } + } + httpRequest.headers['Content-Type'] = 'application/json; charset=utf-8'; + httpRequest.body = null; + httpRequest.headers['Content-Length'] = 0; + // Send Request + return client.pipeline(httpRequest, function (err, response, responseBody) { + if (err) { + return callback(err); + } + var statusCode = response.statusCode; + if (statusCode !== 200) { + var error = new Error(responseBody); + error.statusCode = response.statusCode; + error.request = httpRequest; + error.response = response; + if (responseBody === '') responseBody = null; + var parsedErrorResponse; + try { + parsedErrorResponse = JSON.parse(responseBody); + error.body = new client._models['ErrorModel'](); + if (parsedErrorResponse !== null && parsedErrorResponse !== undefined) { + error.body.deserialize(parsedErrorResponse); + } + } catch (defaultError) { + error.message = util.format('Error "%s" occurred in deserializing the responseBody - "%s" for the default response.', defaultError, responseBody); + return callback(error); + } + return callback(error); + } + // Create Result + var result = null; + if (responseBody === '') responseBody = null; + + return callback(null, result, httpRequest, response); + }); +}; + + +module.exports = ParameterGrouping; diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureReport/autoRestReportServiceForAzure.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureReport/autoRestReportServiceForAzure.js index eef5113d30..019e409950 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureReport/autoRestReportServiceForAzure.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureReport/autoRestReportServiceForAzure.js @@ -118,7 +118,7 @@ AutoRestReportServiceForAzure.prototype.getReport = function (options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionDefault.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionDefault.js index bc21ce3c90..8dbdb4f0d7 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionDefault.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionDefault.js @@ -92,7 +92,7 @@ ApiVersionDefault.prototype.getMethodGlobalValid = function (options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -198,7 +198,7 @@ ApiVersionDefault.prototype.getMethodGlobalNotProvidedValid = function (options, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -304,7 +304,7 @@ ApiVersionDefault.prototype.getPathGlobalValid = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -410,7 +410,7 @@ ApiVersionDefault.prototype.getSwaggerGlobalValid = function (options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionLocal.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionLocal.js index 5a911c29a3..0c89242abd 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionLocal.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/apiVersionLocal.js @@ -96,7 +96,7 @@ ApiVersionLocal.prototype.getMethodLocalValid = function (apiVersion, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -208,7 +208,7 @@ ApiVersionLocal.prototype.getMethodLocalNull = function (apiVersion, options, ca httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -318,7 +318,7 @@ ApiVersionLocal.prototype.getPathLocalValid = function (apiVersion, options, cal httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -428,7 +428,7 @@ ApiVersionLocal.prototype.getSwaggerLocalValid = function (apiVersion, options, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js index c6fbef648f..6b5397bb40 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/header.js @@ -94,10 +94,10 @@ Header.prototype.customNamedRequestId = function (fooClientRequestId, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['foo-client-request-id'] = msRestAzure.generateUuid(); - if (fooClientRequestId !== null) { + if (fooClientRequestId !== undefined && fooClientRequestId !== null) { httpRequest.headers['foo-client-request-id'] = fooClientRequestId; } - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/skipUrlEncoding.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/skipUrlEncoding.js index 29793280c8..b91f72b67b 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/skipUrlEncoding.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/skipUrlEncoding.js @@ -95,7 +95,7 @@ SkipUrlEncoding.prototype.getMethodPathValid = function (unencodedPathParam, opt httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -204,7 +204,7 @@ SkipUrlEncoding.prototype.getPathPathValid = function (unencodedPathParam, optio httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -314,7 +314,7 @@ SkipUrlEncoding.prototype.getSwaggerPathValid = function (unencodedPathParam, op httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -424,7 +424,7 @@ SkipUrlEncoding.prototype.getMethodQueryValid = function (q1, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -534,7 +534,7 @@ SkipUrlEncoding.prototype.getMethodQueryNull = function (q1, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -644,7 +644,7 @@ SkipUrlEncoding.prototype.getPathQueryValid = function (q1, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -757,7 +757,7 @@ SkipUrlEncoding.prototype.getSwaggerQueryValid = function (q1, options, callback httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInCredentials.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInCredentials.js index 778ff25d88..1857506eca 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInCredentials.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInCredentials.js @@ -93,7 +93,7 @@ SubscriptionInCredentials.prototype.postMethodGlobalValid = function (options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -201,7 +201,7 @@ SubscriptionInCredentials.prototype.postMethodGlobalNull = function (options, ca httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -312,7 +312,7 @@ SubscriptionInCredentials.prototype.postMethodGlobalNotProvidedValid = function httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -419,7 +419,7 @@ SubscriptionInCredentials.prototype.postPathGlobalValid = function (options, cal httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -526,7 +526,7 @@ SubscriptionInCredentials.prototype.postSwaggerGlobalValid = function (options, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInMethod.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInMethod.js index 003207a4f2..1d3807689a 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInMethod.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/subscriptionInMethod.js @@ -96,7 +96,7 @@ SubscriptionInMethod.prototype.postMethodLocalValid = function (subscriptionId, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -207,7 +207,7 @@ SubscriptionInMethod.prototype.postMethodLocalNull = function (subscriptionId, o httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -317,7 +317,7 @@ SubscriptionInMethod.prototype.postPathLocalValid = function (subscriptionId, op httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -427,7 +427,7 @@ SubscriptionInMethod.prototype.postSwaggerLocalValid = function (subscriptionId, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/xMsClientRequestId.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/xMsClientRequestId.js index 92e515c89a..9f747c51eb 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/xMsClientRequestId.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/AzureSpecials/operations/xMsClientRequestId.js @@ -89,7 +89,7 @@ XMsClientRequestId.prototype.get = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -198,10 +198,10 @@ XMsClientRequestId.prototype.paramGet = function (xMsClientRequestId, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (xMsClientRequestId !== null) { + if (xMsClientRequestId !== undefined && xMsClientRequestId !== null) { httpRequest.headers['x-ms-client-request-id'] = xMsClientRequestId; } - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Head/operations/httpSuccess.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Head/operations/httpSuccess.js index e2e9274d51..041dd1e1ca 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Head/operations/httpSuccess.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Head/operations/httpSuccess.js @@ -88,7 +88,7 @@ HttpSuccess.prototype.head204 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -191,7 +191,7 @@ HttpSuccess.prototype.head404 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lRORetrys.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lRORetrys.js index 9a87aca89e..31a158142f 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lRORetrys.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lRORetrys.js @@ -187,7 +187,7 @@ LRORetrys.prototype.beginPut201CreatingSucceeded200 = function (product, options httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -442,7 +442,7 @@ LRORetrys.prototype.beginPutAsyncRelativeRetrySucceeded = function (product, opt httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -662,7 +662,7 @@ LRORetrys.prototype.beginDeleteProvisioning202Accepted200Succeeded = function (o httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -865,7 +865,7 @@ LRORetrys.prototype.beginDelete202Retry200 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1030,7 +1030,7 @@ LRORetrys.prototype.beginDeleteAsyncRelativeRetrySucceeded = function (options, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1211,7 +1211,7 @@ LRORetrys.prototype.beginPost202Retry200 = function (product, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1410,7 +1410,7 @@ LRORetrys.prototype.beginPostAsyncRelativeRetrySucceeded = function (product, op httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROSADs.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROSADs.js index 406cbc743d..c32a848045 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROSADs.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROSADs.js @@ -181,7 +181,7 @@ LROSADs.prototype.beginPutNonRetry400 = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -432,7 +432,7 @@ LROSADs.prototype.beginPutNonRetry201Creating400 = function (product, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -685,7 +685,7 @@ LROSADs.prototype.beginPutAsyncRelativeRetry400 = function (product, options, ca httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -881,7 +881,7 @@ LROSADs.prototype.beginDeleteNonRetry400 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1042,7 +1042,7 @@ LROSADs.prototype.beginDelete202NonRetry400 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1207,7 +1207,7 @@ LROSADs.prototype.beginDeleteAsyncRelativeRetry400 = function (options, callback httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1384,7 +1384,7 @@ LROSADs.prototype.beginPostNonRetry400 = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1577,7 +1577,7 @@ LROSADs.prototype.beginPost202NonRetry400 = function (product, options, callback httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1774,7 +1774,7 @@ LROSADs.prototype.beginPostAsyncRelativeRetry400 = function (product, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1987,7 +1987,7 @@ LROSADs.prototype.beginPutError201NoProvisioningStatePayload = function (product httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2240,7 +2240,7 @@ LROSADs.prototype.beginPutAsyncRelativeRetryNoStatus = function (product, option httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2474,7 +2474,7 @@ LROSADs.prototype.beginPutAsyncRelativeRetryNoStatusPayload = function (product, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2672,7 +2672,7 @@ LROSADs.prototype.beginDelete204Succeeded = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2837,7 +2837,7 @@ LROSADs.prototype.beginDeleteAsyncRelativeRetryNoStatus = function (options, cal httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3016,7 +3016,7 @@ LROSADs.prototype.beginPost202NoLocation = function (product, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3213,7 +3213,7 @@ LROSADs.prototype.beginPostAsyncRelativeRetryNoPayload = function (product, opti httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3426,7 +3426,7 @@ LROSADs.prototype.beginPut200InvalidJson = function (product, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3660,7 +3660,7 @@ LROSADs.prototype.beginPutAsyncRelativeRetryInvalidHeader = function (product, o httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3894,7 +3894,7 @@ LROSADs.prototype.beginPutAsyncRelativeRetryInvalidJsonPolling = function (produ httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4092,7 +4092,7 @@ LROSADs.prototype.beginDelete202RetryInvalidHeader = function (options, callback httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4255,7 +4255,7 @@ LROSADs.prototype.beginDeleteAsyncRelativeRetryInvalidHeader = function (options httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4420,7 +4420,7 @@ LROSADs.prototype.beginDeleteAsyncRelativeRetryInvalidJsonPolling = function (op httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4599,7 +4599,7 @@ LROSADs.prototype.beginPost202RetryInvalidHeader = function (product, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4796,7 +4796,7 @@ LROSADs.prototype.beginPostAsyncRelativeRetryInvalidHeader = function (product, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4993,7 +4993,7 @@ LROSADs.prototype.beginPostAsyncRelativeRetryInvalidJsonPolling = function (prod httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROs.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROs.js index dcc7981858..42fd0687a3 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROs.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROs.js @@ -183,7 +183,7 @@ LROs.prototype.beginPut200Succeeded = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -415,7 +415,7 @@ LROs.prototype.beginPut200SucceededNoState = function (product, options, callbac httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -649,7 +649,7 @@ LROs.prototype.beginPut202Retry200 = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -885,7 +885,7 @@ LROs.prototype.beginPut201CreatingSucceeded200 = function (product, options, cal httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1140,7 +1140,7 @@ LROs.prototype.beginPut200UpdatingSucceeded204 = function (product, options, cal httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1376,7 +1376,7 @@ LROs.prototype.beginPut201CreatingFailed200 = function (product, options, callba httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1631,7 +1631,7 @@ LROs.prototype.beginPut200Acceptedcanceled200 = function (product, options, call httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1865,7 +1865,7 @@ LROs.prototype.beginPutNoHeaderInRetry = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2099,7 +2099,7 @@ LROs.prototype.beginPutAsyncRetrySucceeded = function (product, options, callbac httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2333,7 +2333,7 @@ LROs.prototype.beginPutAsyncNoRetrySucceeded = function (product, options, callb httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2567,7 +2567,7 @@ LROs.prototype.beginPutAsyncRetryFailed = function (product, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -2801,7 +2801,7 @@ LROs.prototype.beginPutAsyncNoRetrycanceled = function (product, options, callba httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3035,7 +3035,7 @@ LROs.prototype.beginPutAsyncNoHeaderInRetry = function (product, options, callba httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3261,7 +3261,7 @@ LROs.prototype.beginPutNonResource = function (sku, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3487,7 +3487,7 @@ LROs.prototype.beginPutAsyncNonResource = function (sku, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3709,7 +3709,7 @@ LROs.prototype.beginPutSubResource = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -3931,7 +3931,7 @@ LROs.prototype.beginPutAsyncSubResource = function (product, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4151,7 +4151,7 @@ LROs.prototype.beginDeleteProvisioning202Accepted200Succeeded = function (option httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4374,7 +4374,7 @@ LROs.prototype.beginDeleteProvisioning202DeletingFailed200 = function (options, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4597,7 +4597,7 @@ LROs.prototype.beginDeleteProvisioning202Deletingcanceled200 = function (options httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4796,7 +4796,7 @@ LROs.prototype.beginDelete204Succeeded = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -4979,7 +4979,7 @@ LROs.prototype.beginDelete202Retry200 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -5181,7 +5181,7 @@ LROs.prototype.beginDelete202NoRetry204 = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -5365,7 +5365,7 @@ LROs.prototype.beginDeleteNoHeaderInRetry = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -5530,7 +5530,7 @@ LROs.prototype.beginDeleteAsyncNoHeaderInRetry = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -5695,7 +5695,7 @@ LROs.prototype.beginDeleteAsyncRetrySucceeded = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -5860,7 +5860,7 @@ LROs.prototype.beginDeleteAsyncNoRetrySucceeded = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -6025,7 +6025,7 @@ LROs.prototype.beginDeleteAsyncRetryFailed = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -6190,7 +6190,7 @@ LROs.prototype.beginDeleteAsyncRetrycanceled = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -6373,7 +6373,7 @@ LROs.prototype.beginPost200WithPayload = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -6592,7 +6592,7 @@ LROs.prototype.beginPost202Retry200 = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -6805,7 +6805,7 @@ LROs.prototype.beginPost202NoRetry204 = function (product, options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -7039,7 +7039,7 @@ LROs.prototype.beginPostAsyncRetrySucceeded = function (product, options, callba httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -7273,7 +7273,7 @@ LROs.prototype.beginPostAsyncNoRetrySucceeded = function (product, options, call httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -7489,7 +7489,7 @@ LROs.prototype.beginPostAsyncRetryFailed = function (product, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -7686,7 +7686,7 @@ LROs.prototype.beginPostAsyncRetrycanceled = function (product, options, callbac httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROsCustomHeader.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROsCustomHeader.js index 98f3bdce0d..93049f4ff9 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROsCustomHeader.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Lro/operations/lROsCustomHeader.js @@ -189,7 +189,7 @@ LROsCustomHeader.prototype.beginPutAsyncRetrySucceeded = function (product, opti httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -427,7 +427,7 @@ LROsCustomHeader.prototype.beginPut201CreatingSucceeded200 = function (product, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -664,7 +664,7 @@ LROsCustomHeader.prototype.beginPost202Retry200 = function (product, options, ca httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -865,7 +865,7 @@ LROsCustomHeader.prototype.beginPostAsyncRetrySucceeded = function (product, opt httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js index 38a6e9ff15..bef349df03 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/Paging/operations/paging.js @@ -89,7 +89,7 @@ Paging.prototype.getSinglePages = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -211,7 +211,7 @@ Paging.prototype.getMultiplePages = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -334,7 +334,7 @@ Paging.prototype.getMultiplePagesRetryFirst = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -458,7 +458,7 @@ Paging.prototype.getMultiplePagesRetrySecond = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -580,7 +580,7 @@ Paging.prototype.getSinglePagesFailure = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -702,7 +702,7 @@ Paging.prototype.getMultiplePagesFailure = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -824,7 +824,7 @@ Paging.prototype.getMultiplePagesFailureUri = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -948,7 +948,7 @@ Paging.prototype.getSinglePagesNext = function (nextPageLink, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1072,7 +1072,7 @@ Paging.prototype.getMultiplePagesNext = function (nextPageLink, options, callbac httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1197,7 +1197,7 @@ Paging.prototype.getMultiplePagesRetryFirstNext = function (nextPageLink, option httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1323,7 +1323,7 @@ Paging.prototype.getMultiplePagesRetrySecondNext = function (nextPageLink, optio httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1447,7 +1447,7 @@ Paging.prototype.getSinglePagesFailureNext = function (nextPageLink, options, ca httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1571,7 +1571,7 @@ Paging.prototype.getMultiplePagesFailureNext = function (nextPageLink, options, httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1695,7 +1695,7 @@ Paging.prototype.getMultiplePagesFailureUriNext = function (nextPageLink, option httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/ResourceFlattening/autoRestResourceFlatteningTestService.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/ResourceFlattening/autoRestResourceFlatteningTestService.js index 09a127e40f..a3ee98dbb1 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/ResourceFlattening/autoRestResourceFlatteningTestService.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/ResourceFlattening/autoRestResourceFlatteningTestService.js @@ -120,7 +120,7 @@ AutoRestResourceFlatteningTestService.prototype.putArray = function (resourceArr httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { @@ -249,7 +249,7 @@ AutoRestResourceFlatteningTestService.prototype.getArray = function (options, ca httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { @@ -384,7 +384,7 @@ AutoRestResourceFlatteningTestService.prototype.putDictionary = function (resour httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { @@ -513,7 +513,7 @@ AutoRestResourceFlatteningTestService.prototype.getDictionary = function (option httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { @@ -663,7 +663,7 @@ AutoRestResourceFlatteningTestService.prototype.putResourceCollection = function httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { @@ -782,7 +782,7 @@ AutoRestResourceFlatteningTestService.prototype.getResourceCollection = function httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.acceptLanguage !== null) { + if (this.acceptLanguage !== undefined && this.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/storageAccounts.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/storageAccounts.js index f6720d44c0..e799569bc0 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/storageAccounts.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/storageAccounts.js @@ -109,7 +109,7 @@ StorageAccounts.prototype.checkNameAvailability = function (accountName, options httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -386,7 +386,7 @@ StorageAccounts.prototype.beginCreate = function (resourceGroupName, accountName httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -546,7 +546,7 @@ StorageAccounts.prototype.deleteMethod = function (resourceGroupName, accountNam httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -670,7 +670,7 @@ StorageAccounts.prototype.getProperties = function (resourceGroupName, accountNa httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -854,7 +854,7 @@ StorageAccounts.prototype.update = function (resourceGroupName, accountName, par httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1012,7 +1012,7 @@ StorageAccounts.prototype.listKeys = function (resourceGroupName, accountName, o httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1144,7 +1144,7 @@ StorageAccounts.prototype.list = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1284,7 +1284,7 @@ StorageAccounts.prototype.listByResourceGroup = function (resourceGroupName, opt httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1438,7 +1438,7 @@ StorageAccounts.prototype.regenerateKey = function (resourceGroupName, accountNa httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1580,7 +1580,7 @@ StorageAccounts.prototype.listNext = function (nextPageLink, options, callback) httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { @@ -1707,7 +1707,7 @@ StorageAccounts.prototype.listByResourceGroupNext = function (nextPageLink, opti httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/usageOperations.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/usageOperations.js index 9010defdc8..f682a0b509 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/usageOperations.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/StorageManagementClient/operations/usageOperations.js @@ -98,7 +98,7 @@ UsageOperations.prototype.list = function (options, callback) { httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/operations/group.js b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/operations/group.js index 641074b51b..b02c869293 100644 --- a/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/operations/group.js +++ b/AutoRest/Generators/NodeJS/Azure.NodeJS.Tests/Expected/AcceptanceTests/SubscriptionIdApiVersion/operations/group.js @@ -103,7 +103,7 @@ Group.prototype.getSampleResourceGroup = function (resourceGroupName, options, c httpRequest.url = requestUrl; // Set Headers httpRequest.headers['x-ms-client-request-id'] = msRestAzure.generateUuid(); - if (this.client.acceptLanguage !== null) { + if (this.client.acceptLanguage !== undefined && this.client.acceptLanguage !== null) { httpRequest.headers['accept-language'] = this.client.acceptLanguage; } if(options) { diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/Header/operations/header.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/Header/operations/header.js index ca3f9a1dfc..26599e12d7 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/Header/operations/header.js +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/Header/operations/header.js @@ -85,7 +85,7 @@ Header.prototype.paramExistingKey = function (userAgent, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (userAgent !== null) { + if (userAgent !== undefined && userAgent !== null) { httpRequest.headers['User-Agent'] = userAgent; } if(options) { @@ -271,7 +271,7 @@ Header.prototype.paramProtectedKey = function (contentType, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (contentType !== null) { + if (contentType !== undefined && contentType !== null) { httpRequest.headers['Content-Type'] = contentType; } if(options) { @@ -463,10 +463,10 @@ Header.prototype.paramInteger = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value.toString(); } if(options) { @@ -566,7 +566,7 @@ Header.prototype.responseInteger = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -672,10 +672,10 @@ Header.prototype.paramLong = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value.toString(); } if(options) { @@ -775,7 +775,7 @@ Header.prototype.responseLong = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -881,10 +881,10 @@ Header.prototype.paramFloat = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value.toString(); } if(options) { @@ -984,7 +984,7 @@ Header.prototype.responseFloat = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -1090,10 +1090,10 @@ Header.prototype.paramDouble = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value.toString(); } if(options) { @@ -1193,7 +1193,7 @@ Header.prototype.responseDouble = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -1299,10 +1299,10 @@ Header.prototype.paramBool = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value.toString(); } if(options) { @@ -1402,7 +1402,7 @@ Header.prototype.responseBool = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -1510,10 +1510,10 @@ Header.prototype.paramString = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value; } if(options) { @@ -1614,7 +1614,7 @@ Header.prototype.responseString = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -1722,10 +1722,10 @@ Header.prototype.paramDate = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = msRest.serializeObject(value).replace(/[Tt].*[Zz]/, ''); } if(options) { @@ -1825,7 +1825,7 @@ Header.prototype.responseDate = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -1934,10 +1934,10 @@ Header.prototype.paramDatetime = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = msRest.serializeObject(value); } if(options) { @@ -2038,7 +2038,7 @@ Header.prototype.responseDatetime = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -2144,10 +2144,10 @@ Header.prototype.paramByte = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = msRest.serializeObject(value); } if(options) { @@ -2247,7 +2247,7 @@ Header.prototype.responseByte = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { @@ -2357,10 +2357,10 @@ Header.prototype.paramEnum = function (scenario, value, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } - if (value !== null) { + if (value !== undefined && value !== null) { httpRequest.headers['value'] = value; } if(options) { @@ -2460,7 +2460,7 @@ Header.prototype.responseEnum = function (scenario, options, callback) { httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (scenario !== null) { + if (scenario !== undefined && scenario !== null) { httpRequest.headers['scenario'] = scenario; } if(options) { diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/explicit.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/explicit.js index 5ab111fcc5..2040f7d3ce 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/explicit.js +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/explicit.js @@ -564,7 +564,7 @@ Explicit.prototype.postRequiredIntegerHeader = function (headerParameter, option httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (headerParameter !== null) { + if (headerParameter !== undefined && headerParameter !== null) { httpRequest.headers['headerParameter'] = headerParameter.toString(); } if(options) { @@ -680,7 +680,7 @@ Explicit.prototype.postOptionalIntegerHeader = function (headerParameter, option httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (headerParameter !== null) { + if (headerParameter !== undefined && headerParameter !== null) { httpRequest.headers['headerParameter'] = headerParameter.toString(); } if(options) { @@ -1259,7 +1259,7 @@ Explicit.prototype.postRequiredStringHeader = function (headerParameter, options httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (headerParameter !== null) { + if (headerParameter !== undefined && headerParameter !== null) { httpRequest.headers['headerParameter'] = headerParameter; } if(options) { @@ -1375,7 +1375,7 @@ Explicit.prototype.postOptionalStringHeader = function (bodyParameter, options, httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (bodyParameter !== null) { + if (bodyParameter !== undefined && bodyParameter !== null) { httpRequest.headers['bodyParameter'] = bodyParameter; } if(options) { @@ -2471,7 +2471,7 @@ Explicit.prototype.postRequiredArrayHeader = function (headerParameter, options, httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (headerParameter !== null) { + if (headerParameter !== undefined && headerParameter !== null) { httpRequest.headers['headerParameter'] = headerParameter.toString(); } if(options) { @@ -2591,7 +2591,7 @@ Explicit.prototype.postOptionalArrayHeader = function (headerParameter, options, httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (headerParameter !== null) { + if (headerParameter !== undefined && headerParameter !== null) { httpRequest.headers['headerParameter'] = headerParameter.toString(); } if(options) { diff --git a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/implicit.js b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/implicit.js index 8f4682365f..037503ec59 100644 --- a/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/implicit.js +++ b/AutoRest/Generators/NodeJS/NodeJS.Tests/Expected/AcceptanceTests/RequiredOptional/operations/implicit.js @@ -301,7 +301,7 @@ Implicit.prototype.putOptionalHeader = function (queryParameter, options, callba httpRequest.headers = {}; httpRequest.url = requestUrl; // Set Headers - if (queryParameter !== null) { + if (queryParameter !== undefined && queryParameter !== null) { httpRequest.headers['queryParameter'] = queryParameter; } if(options) { diff --git a/AutoRest/Generators/NodeJS/NodeJS/ClientModelExtensions.cs b/AutoRest/Generators/NodeJS/NodeJS/ClientModelExtensions.cs index 9f5e1c3044..4f6bf118c1 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/ClientModelExtensions.cs +++ b/AutoRest/Generators/NodeJS/NodeJS/ClientModelExtensions.cs @@ -28,7 +28,7 @@ public static string GetHttpMethod(this HttpMethod method) /// /// The parameter to format /// A reference to the formatted parameter value - public static string GetFormattedReferenceValue(this Parameter parameter) + public static string GetFormattedReferenceValue(this ParameterTemplateModel parameter) { if (parameter == null) { @@ -38,7 +38,7 @@ public static string GetFormattedReferenceValue(this Parameter parameter) SequenceType sequence = parameter.Type as SequenceType; if (sequence == null) { - return parameter.Type.ToString(parameter.Name); + return parameter.Type.ToString(parameter.ParameterAccessor); } PrimaryType primaryType = sequence.ElementType as PrimaryType; @@ -57,7 +57,7 @@ public static string GetFormattedReferenceValue(this Parameter parameter) } return string.Format(CultureInfo.InvariantCulture, - "{0}.join('{1}')", parameter.Name, parameter.CollectionFormat.GetSeparator()); + "{0}.join('{1}')", parameter.ParameterAccessor, parameter.CollectionFormat.GetSeparator()); } /// diff --git a/AutoRest/Generators/NodeJS/NodeJS/Templates/MethodTemplate.cshtml b/AutoRest/Generators/NodeJS/NodeJS/Templates/MethodTemplate.cshtml index 7fb4a979e5..32eb0d80b3 100644 --- a/AutoRest/Generators/NodeJS/NodeJS/Templates/MethodTemplate.cshtml +++ b/AutoRest/Generators/NodeJS/NodeJS/Templates/MethodTemplate.cshtml @@ -59,7 +59,7 @@ var type = groupParameter.Type as CompositeType; foreach (var property in type.Properties) { - @:var @(groupParameter.Name)@(CodeNamer.PascalCase(property.Name)) = @string.Format(CultureInfo.InvariantCulture, "({0} ? undefined : {0}.{1})", groupParameter.Name, property.Name); + @:var @(groupParameter.Name)@(CodeNamer.PascalCase(property.Name)) = @string.Format(CultureInfo.InvariantCulture, "({0} ? {0}.{1} : undefined)", groupParameter.Name, property.Name); } } diff --git a/AutoRest/TestServer/server/SwaggerBATServer.njsproj b/AutoRest/TestServer/server/SwaggerBATServer.njsproj index 14d2c307e1..1b47013786 100644 --- a/AutoRest/TestServer/server/SwaggerBATServer.njsproj +++ b/AutoRest/TestServer/server/SwaggerBATServer.njsproj @@ -44,6 +44,7 @@ + diff --git a/AutoRest/TestServer/server/app.js b/AutoRest/TestServer/server/app.js index 248182349f..2d0b393b1b 100644 --- a/AutoRest/TestServer/server/app.js +++ b/AutoRest/TestServer/server/app.js @@ -30,6 +30,7 @@ var paging = require('./routes/paging'); var resourceFlatten = require('./routes/resource-flatten'); var azureUrl = require('./routes/azureUrl'); var azureSpecial = require('./routes/azureSpecials'); +var parameterGrouping = require('./routes/azureParameterGrouping.js'); var util = require('util'); var app = express(); @@ -372,7 +373,7 @@ var coverage = { "HeaderResponseDateMin": 0, "HeaderResponseDateTimeValid": 0, "HeaderResponseDateTimeMin": 0, - "HeaderResponseBytesValid": 0 + "HeaderResponseBytesValid": 0, }; // view engine setup @@ -411,6 +412,7 @@ app.use('/azure/resource-flatten', new resourceFlatten(azurecoverage).router); app.use('/azurespecials', new azureSpecial(azurecoverage).router); app.use('/report', new report(coverage, azurecoverage).router); app.use('/subscriptions', new azureUrl(azurecoverage).router); +app.use('/parameterGrouping', new parameterGrouping(azurecoverage).router); // catch 404 and forward to error handler app.use(function(req, res, next) { diff --git a/AutoRest/TestServer/server/routes/azureParameterGrouping.js b/AutoRest/TestServer/server/routes/azureParameterGrouping.js new file mode 100644 index 0000000000..46beef8d4e --- /dev/null +++ b/AutoRest/TestServer/server/routes/azureParameterGrouping.js @@ -0,0 +1,35 @@ +var express = require('express'); +var router = express.Router(); +var util = require('util'); +var utils = require('../util/utils') + +var parameterGrouping = function(coverage) { + coverage['postParameterGroupingOptionalParameters'] = 0; + coverage['postParameterGroupingRequiredParameters'] = 0; + + router.post('/postRequired/:path', function(req, res, next) { + if (req.body === 1234 && req.params.path === 'path' && + (req.get('header') === 'header' || req.get('header') === undefined) && + (req.query['query'] === '21' || req.query['query'] === undefined)) { + coverage['postParameterGroupingRequiredParameters']++; + res.status(200).end(); + } else { + utils.send400(res, next, "Did not like the values in the req. Body: " + util.inspect(req.body) + + ", Path: " + req.params.path + ", header: " + req.get('header') + ", query: " + req.query['query']); + } + }); + + router.post('/postOptional', function(req, res, next) { + if ((req.get('header') === 'header' || req.get('header') === undefined) && + (req.query['query'] === '21' || req.query['query'] === undefined)) { + coverage['postParameterGroupingOptionalParameters']++; + res.status(200).end(); + } else { + utils.send400(res, next, "Did not like the values in the req. header: " + req.get('header') + ", query: " + req.query['query']); + } + }); +} + +parameterGrouping.prototype.router = router; + +module.exports = parameterGrouping; \ No newline at end of file diff --git a/AutoRest/TestServer/swagger/azure-parameter-grouping.json b/AutoRest/TestServer/swagger/azure-parameter-grouping.json new file mode 100644 index 0000000000..9c9fcbc7bc --- /dev/null +++ b/AutoRest/TestServer/swagger/azure-parameter-grouping.json @@ -0,0 +1,135 @@ +{ + "swagger": "2.0", + "info": { + "title": "AutoRest Parameter Grouping Test Service", + "description": "Test Infrastructure for AutoRest", + "version": "1.0.0" + }, + "host": "localhost", + "schemes": [ + "https" + ], + "produces": [ + "application/json" + ], + "consumes": [ + "application/json" + ], + "paths": { + "/parameterGrouping/postRequired/{path}": { + "post": { + "operationId": "parameterGrouping_postRequired", + "description": "Post a bunch of required parameters grouped", + "parameters": [ + { + "name": "body", + "in": "body", + "schema": { + "type": "integer", + "format": "int32" + }, + "required": true, + "x-ms-parameter-grouping": { + "value": true + } + }, + { + "name": "header", + "in": "header", + "type": "string", + "required": false, + "x-ms-parameter-grouping": { + "value": true + } + }, + { + "name": "query", + "in": "query", + "required": false, + "type": "integer", + "format": "int32", + "default": 30, + "description": "Query parameter with default", + "x-ms-parameter-grouping": { + "value": true + } + }, + { + "name": "path", + "in": "path", + "required": true, + "type": "string", + "description": "Path parameter", + "x-ms-parameter-grouping": { + "value": true + } + }, + ], + "responses": { + "200": { + "description": "Success" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + "/parameterGrouping/postOptional": { + "post": { + "operationId": "parameterGrouping_postOptional", + "description": "Post a bunch of optional parameters grouped", + "parameters": [ + { + "name": "header", + "in": "header", + "type": "string", + "required": false, + "x-ms-parameter-grouping": { + "value": true + } + }, + { + "name": "query", + "in": "query", + "required": false, + "type": "integer", + "format": "int32", + "default": 30, + "description": "Query parameter with default", + "x-ms-parameter-grouping": { + "value": true + } + }, + ], + "responses": { + "200": { + "description": "Success" + }, + "default": { + "description": "Unexpected error", + "schema": { + "$ref": "#/definitions/Error" + } + } + } + } + }, + }, + "definitions": { + "Error": { + "properties": { + "status": { + "type": "integer", + "format": "int32" + }, + "message": { + "type": "string" + } + } + } + } +} \ No newline at end of file diff --git a/gulpfile.js b/gulpfile.js index 23ba3107d9..c3766b8c9c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -82,6 +82,7 @@ var defaultAzureMappings = { 'AcceptanceTests/Lro': '../../../TestServer/swagger/lro.json', 'AcceptanceTests/Paging': '../../../TestServer/swagger/paging.json', 'AcceptanceTests/AzureReport': '../../../TestServer/swagger/azure-report.json', + 'AcceptanceTests/AzureParameterGrouping': '../../../TestServer/swagger/azure-parameter-grouping.json', 'AcceptanceTests/ResourceFlattening': '../../../TestServer/swagger/resource-flattening.json', 'AcceptanceTests/Head': '../../../TestServer/swagger/head.json', 'AcceptanceTests/SubscriptionIdApiVersion': '../../../TestServer/swagger/subscriptionId-apiVersion.json',