Skip to content

Commit

Permalink
Enhancement to x-ms-parameterized-host extension
Browse files Browse the repository at this point in the history
  • Loading branch information
amarzavery committed Apr 8, 2016
1 parent b73c784 commit 63b9fd6
Show file tree
Hide file tree
Showing 47 changed files with 2,378 additions and 17 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,9 @@
<Compile Include="Properties\AssemblyInfo.cs" />
</ItemGroup>
<ItemGroup>
<None Include="packages.config" />
<None Include="packages.config">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\AzureResourceSchema\AutoRest.Generator.AzureResourceSchema.csproj">
Expand Down
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
<?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="xunit" version="2.1.0" targetFramework="net452" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net452" />
<package id="xunit.assert" version="2.1.0" targetFramework="net452" />
<package id="xunit.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net452" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net452" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net452" />
<package id="xunit" version="2.1.0" targetFramework="net45" />
<package id="xunit.abstractions" version="2.0.0" targetFramework="net451" />
<package id="xunit.assert" version="2.1.0" targetFramework="net45" />
<package id="xunit.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.core" version="2.1.0" targetFramework="net45" />
<package id="xunit.extensibility.execution" version="2.1.0" targetFramework="net45" />
<package id="xunit.runner.visualstudio" version="2.1.0" targetFramework="net45" />
</packages>
16 changes: 16 additions & 0 deletions AutoRest/Generators/CSharp/CSharp.Tests/AcceptanceTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
using Fixtures.PetstoreV2;
using Fixtures.AcceptanceTestsCompositeBoolIntClient;
using Fixtures.AcceptanceTestsCustomBaseUri;
using Fixtures.AcceptanceTestsCustomBaseUriMoreOptions;
using System.Net.Http;
using Fixtures.AcceptanceTestsModelFlattening;
using Fixtures.AcceptanceTestsModelFlattening.Models;
Expand Down Expand Up @@ -1951,6 +1952,21 @@ public void CustomBaseUriTests()
}
}

[Fact]
public void CustomBaseUriMoreOptionsTests()
{
SwaggerSpecRunner.RunTests(
SwaggerPath("custom-baseUrl-more-options.json"), ExpectedPath("CustomBaseUriMoreOptions"));
using (var client = new AutoRestParameterizedCustomHostTestClient())
{
client.SubscriptionId = "test12";
// small modification to the "host" portion to include the port and the '.'
client.DnsSuffix = string.Format(CultureInfo.InvariantCulture, "{0}.:{1}", "host", Fixture.Port);
Assert.Equal(HttpStatusCode.OK,
client.Paths.GetEmptyWithHttpMessagesAsync("http://lo", "cal", "key1").Result.Response.StatusCode);
}
}

[Fact]
public void CustomBaseUriNegativeTests()
{
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,128 @@
// 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.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Fixtures.AcceptanceTestsCustomBaseUriMoreOptions
{
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 Models;

/// <summary>
/// Test Infrastructure for AutoRest
/// </summary>
public partial class AutoRestParameterizedCustomHostTestClient : ServiceClient<AutoRestParameterizedCustomHostTestClient>, IAutoRestParameterizedCustomHostTestClient
{
/// <summary>
/// The base URI of the service.
/// </summary>
internal string BaseUri {get; set;}

/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
public JsonSerializerSettings SerializationSettings { get; private set; }

/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
public JsonSerializerSettings DeserializationSettings { get; private set; }

/// <summary>
/// The subscription id with value 'test12'.
/// </summary>
public string SubscriptionId { get; set; }

/// <summary>
/// A string value that is used as a global part of the parameterized host.
/// Default value 'host'.
/// </summary>
public string DnsSuffix { get; set; }

/// <summary>
/// Gets the IPaths.
/// </summary>
public virtual IPaths Paths { get; private set; }

/// <summary>
/// Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class.
/// </summary>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
public AutoRestParameterizedCustomHostTestClient(params DelegatingHandler[] handlers) : base(handlers)
{
this.Initialize();
}

/// <summary>
/// Initializes a new instance of the AutoRestParameterizedCustomHostTestClient class.
/// </summary>
/// <param name='rootHandler'>
/// Optional. The http client handler used to handle http transport.
/// </param>
/// <param name='handlers'>
/// Optional. The delegating handlers to add to the http client pipeline.
/// </param>
public AutoRestParameterizedCustomHostTestClient(HttpClientHandler rootHandler, params DelegatingHandler[] handlers) : base(rootHandler, handlers)
{
this.Initialize();
}

/// <summary>
/// An optional partial-method to perform custom initialization.
///</summary>
partial void CustomInitialize();
/// <summary>
/// Initializes client properties.
/// </summary>
private void Initialize()
{
this.Paths = new Paths(this);
this.BaseUri = "{vault}{secret}{dnsSuffix}";
this.DnsSuffix = "host";
SerializationSettings = new JsonSerializerSettings
{
Formatting = Formatting.Indented,
DateFormatHandling = DateFormatHandling.IsoDateFormat,
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
NullValueHandling = NullValueHandling.Ignore,
ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
ContractResolver = new ReadOnlyJsonContractResolver(),
Converters = new List<JsonConverter>
{
new Iso8601TimeSpanConverter()
}
};
DeserializationSettings = new JsonSerializerSettings
{
DateFormatHandling = DateFormatHandling.IsoDateFormat,
DateTimeZoneHandling = DateTimeZoneHandling.Utc,
NullValueHandling = NullValueHandling.Ignore,
ReferenceLoopHandling = ReferenceLoopHandling.Serialize,
ContractResolver = new ReadOnlyJsonContractResolver(),
Converters = new List<JsonConverter>
{
new Iso8601TimeSpanConverter()
}
};
CustomInitialize();
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
// 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.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Fixtures.AcceptanceTestsCustomBaseUriMoreOptions
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Newtonsoft.Json;
using Microsoft.Rest;
using Models;

/// <summary>
/// Test Infrastructure for AutoRest
/// </summary>
public partial interface IAutoRestParameterizedCustomHostTestClient : IDisposable
{
/// <summary>
/// The base URI of the service.
/// </summary>

/// <summary>
/// Gets or sets json serialization settings.
/// </summary>
JsonSerializerSettings SerializationSettings { get; }

/// <summary>
/// Gets or sets json deserialization settings.
/// </summary>
JsonSerializerSettings DeserializationSettings { get; }

/// <summary>
/// The subscription id with value 'test12'.
/// </summary>
string SubscriptionId { get; set; }

/// <summary>
/// A string value that is used as a global part of the parameterized
/// host. Default value 'host'.
/// </summary>
string DnsSuffix { get; set; }


/// <summary>
/// Gets the IPaths.
/// </summary>
IPaths Paths { get; }

}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
// 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.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Fixtures.AcceptanceTestsCustomBaseUriMoreOptions
{
using System;
using System.Collections.Generic;
using System.Net.Http;
using System.Threading;
using System.Threading.Tasks;
using Microsoft.Rest;
using Models;

/// <summary>
/// Paths operations.
/// </summary>
public partial interface IPaths
{
/// <summary>
/// Get a 200 to test a valid base uri
/// </summary>
/// <param name='vault'>
/// The vault name, e.g. https://myvault
/// </param>
/// <param name='secret'>
/// Secret value.
/// </param>
/// <param name='keyName'>
/// The key name with value 'key1'.
/// </param>
/// <param name='keyVersion'>
/// The key version. Default value 'v1'.
/// </param>
/// <param name='customHeaders'>
/// The headers that will be added to request.
/// </param>
/// <param name='cancellationToken'>
/// The cancellation token.
/// </param>
Task<HttpOperationResponse> GetEmptyWithHttpMessagesAsync(string vault, string secret, string keyName, string keyVersion = "v1", Dictionary<string, List<string>> customHeaders = null, CancellationToken cancellationToken = default(CancellationToken));
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
// 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.
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.

namespace Fixtures.AcceptanceTestsCustomBaseUriMoreOptions.Models
{
using System;
using System.Linq;
using System.Collections.Generic;
using Newtonsoft.Json;
using Microsoft.Rest;
using Microsoft.Rest.Serialization;

public partial class Error
{
/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error() { }

/// <summary>
/// Initializes a new instance of the Error class.
/// </summary>
public Error(int? status = default(int?), string message = default(string))
{
Status = status;
Message = message;
}

/// <summary>
/// </summary>
[JsonProperty(PropertyName = "status")]
public int? Status { get; set; }

/// <summary>
/// </summary>
[JsonProperty(PropertyName = "message")]
public string Message { get; set; }

}
}
Loading

0 comments on commit 63b9fd6

Please sign in to comment.