Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Extend paging functionality #955

Merged
merged 26 commits into from
Apr 16, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
965e722
Adding a method in the AzureClientExtensions to handle the PutOrPatch…
parvezah Apr 5, 2016
016cef6
Enhancement to "x-ms-parameterized-host" extension (#929)
amarzavery Apr 9, 2016
0e2d13a
Update swagger-extensions.md
amarzavery Apr 11, 2016
56a20fa
Merge pull request #917 from AzCiS/master
tbombach Apr 12, 2016
296bb25
Correct bug link re: multi (#939)
brodyberg Apr 13, 2016
cd746ab
Okio 1.7.0
jianghaolu Apr 15, 2016
14b4e56
Merge pull request #951 from jianghaolu/master
jianghaolu Apr 15, 2016
29dc46d
Python Bug Fixes (#928)
annatisch Apr 15, 2016
b7de51d
Rename method groups without Operations suffix
jianghaolu Mar 31, 2016
3a885ff
Shorten operations names to simple plurals
jianghaolu Mar 31, 2016
4c181b2
Address code analysis
jianghaolu Apr 1, 2016
c009c93
Rename AutoRestException to RestException
jianghaolu Apr 1, 2016
5573dc8
Move impl classes to implementation subpackage
jianghaolu Apr 1, 2016
c0b92a9
Remove get prefix on model property getters
jianghaolu Apr 6, 2016
cd01cf8
Remove interfaces for method groups and service clients
jianghaolu Apr 6, 2016
b877cbf
Seperate type name generation and client name generation
jianghaolu Apr 6, 2016
175a66e
Rename models to end with impl
jianghaolu Apr 6, 2016
51f17c3
Move into implementation.api subpackage
jianghaolu Apr 6, 2016
6333912
Rename only top level parameters & responses to Inner
jianghaolu Apr 7, 2016
8bd5afd
Rename method group impl to inner
jianghaolu Apr 7, 2016
07bda32
Address code analysis errors
jianghaolu Apr 7, 2016
3d236fe
Regenerate after merge
jianghaolu Apr 7, 2016
8b1aeed
Extend functionality for paged lists
jianghaolu Apr 8, 2016
88c8aad
Fix paged list to use hasNextPage() for hasNext()
jianghaolu Apr 15, 2016
42a3277
Use String for OData
jianghaolu Apr 15, 2016
f674f3c
Add fluent to pageimpl
jianghaolu Apr 15, 2016
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
The table of contents is too big for display.
Diff view
Diff view
  •  
  •  
  •  
13 changes: 11 additions & 2 deletions AutoRest/AutoRest.Core/CodeNamer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ public virtual void NormalizeClientModel(ServiceClient client)
throw new ArgumentNullException("client");
}

client.Name = GetTypeName(client.Name);
client.Name = GetClientName(client.Name);
client.Namespace = GetNamespaceName(client.Namespace);

NormalizeClientProperties(client);
Expand Down Expand Up @@ -392,6 +392,15 @@ public virtual string GetMethodGroupName(string name)
return PascalCase(RemoveInvalidCharacters(GetEscapedReservedName(name, "Model")));
}

public virtual string GetClientName(string name)
{
if (string.IsNullOrWhiteSpace(name))
{
return name;
}
return PascalCase(RemoveInvalidCharacters(GetEscapedReservedName(name, "Model")));
}

/// <summary>
/// Formats a string for naming a local variable using Camel case by default.
/// </summary>
Expand Down Expand Up @@ -680,7 +689,7 @@ protected virtual void ResolveMethodGroupNameCollision(ServiceClient serviceClie
}
}

private static string ResolveNameConflict(
protected static string ResolveNameConflict(
Dictionary<string, string> exclusionDictionary,
string typeName,
string type,
Expand Down
1 change: 1 addition & 0 deletions AutoRest/AutoRest.Core/GlobalSuppressions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -60,3 +60,4 @@
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.ServiceClient.#Methods")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.ServiceClient.#Properties")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1002:DoNotExposeGenericLists", Scope = "member", Target = "Microsoft.Rest.Generator.ClientModel.ParameterTransformation.#ParameterMappings")]
[assembly: System.Diagnostics.CodeAnalysis.SuppressMessage("Microsoft.Design", "CA1062:Validate arguments of public methods", MessageId = "0", Scope = "member", Target = "Microsoft.Rest.Generator.CodeNamer.#ResolveNameConflict(System.Collections.Generic.Dictionary`2<System.String,System.String>,System.String,System.String,System.String)")]
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