diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index b1a96910c9..49fb793e64 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -29,6 +29,13 @@ "kiota" ], "rollForward": false + }, + "nswag.consolecore": { + "version": "14.6.3", + "commands": [ + "nswag" + ], + "rollForward": false } } } \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs index 1c556d9279..d482d7c416 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/CodeGenerationTests.cs @@ -3,12 +3,7 @@ using System.Reflection; using System.Security.Cryptography; using System.Text; -using Microsoft.AspNetCore.Http; -using Microsoft.Kiota.Abstractions.Authentication; -using Microsoft.Kiota.Http.HttpClientLibrary; using Microsoft.OpenApi; -using TodoApp.Client; -using TodoApp.Client.Models; namespace Swashbuckle.AspNetCore.IntegrationTests; @@ -88,254 +83,19 @@ await VerifyDirectory( } [Fact] - public async Task Can_Manage_Todo_Items_With_Api() - { - // Arrange - await WithTodoAppClientAsync(async (client) => - { - var cancellationToken = TestContext.Current.CancellationToken; - - // Act - Get all the items - var items = await client.Api.Items.GetAsync(cancellationToken: cancellationToken); - - // Assert - There should be no items - Assert.NotNull(items); - Assert.NotNull(items.Items); - - var beforeCount = items.Items.Count; - - // Arrange - var text = "Buy eggs"; - - // Act - Add a new item - var createdItem = await client.Api.Items.PostAsync( - new() { Text = text }, - cancellationToken: cancellationToken); - - // Assert - An item was created - Assert.NotNull(createdItem); - Assert.NotEqual(default, createdItem.Id); - - // Arrange - Get the new item's URL and Id - var itemId = createdItem.Id; - - // Act - Get the item - var item = await client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken); - - // Assert - Verify the item was created correctly - Assert.NotNull(item); - Assert.Equal(itemId, item.Id); - Assert.Null(item.CompletedAt); - Assert.NotEqual(default, item.CreatedAt); - Assert.Equal(item.CreatedAt.Value, item.LastUpdated); - Assert.Null(item.Priority); - Assert.Equal(text, item.Text); - - // Act - Update the item to be high priority - await client.Api.Items[new(itemId)].Priority.PatchAsync( - new() { Priority = TodoPriority.High }, - cancellationToken: cancellationToken); - - item = await client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken); - - Assert.NotNull(item); - Assert.Equal(itemId, item.Id); - Assert.Null(item.CompletedAt); - Assert.NotEqual(default, item.CreatedAt); - Assert.Equal(item.CreatedAt.Value, item.LastUpdated); - Assert.Equal(TodoPriority.High, item.Priority); - Assert.Equal(text, item.Text); - - // Act - Mark the item as being completed - await client.Api.Items[new(itemId)].Complete.PostAsync(cancellationToken: cancellationToken); - - item = await client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken); - - Assert.NotNull(item); - Assert.Equal(itemId, item.Id); - Assert.Equal(text, item.Text); - Assert.NotNull(item.CompletedAt); - Assert.Equal(item.CompletedAt.Value, item.LastUpdated); - Assert.True(item.CompletedAt.Value > item.CreatedAt); - - // Act - Get all the items - items = await client.Api.Items.GetAsync(cancellationToken: cancellationToken); - - // Assert - The item was completed - Assert.NotNull(items); - Assert.NotNull(items.Items); - Assert.Equal(beforeCount + 1, items.Items.Count); - Assert.Contains(items.Items, (x) => x.Id == itemId); - - item = items.Items.Last(); - - Assert.NotNull(item); - Assert.Equal(itemId, item.Id); - Assert.Equal(text, item.Text); - Assert.NotNull(item.CompletedAt); - Assert.Equal(item.CompletedAt.Value, item.LastUpdated); - Assert.True(item.CompletedAt.Value > item.CreatedAt); - - // Act - Delete the item - await client.Api.Items[new(itemId)].DeleteAsync(cancellationToken: cancellationToken); - - // Assert - The item no longer exists - items = await client.Api.Items.GetAsync(cancellationToken: cancellationToken); - - Assert.NotNull(items); - Assert.NotNull(items.Items); - Assert.Equal(beforeCount, items.Items.Count); - Assert.DoesNotContain(items.Items, (x) => x.Id == itemId); - - // Act - var problem = await Assert.ThrowsAsync( - () => client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status404NotFound, problem.Status); - Assert.Equal("Not Found", problem.Title); - Assert.Equal("Item not found.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); - Assert.Null(problem.Instance); - - // Act - problem = await Assert.ThrowsAsync( - () => client.Api.Items[new(itemId)].Complete.PostAsync(cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status404NotFound, problem.Status); - Assert.Equal("Not Found", problem.Title); - Assert.Equal("Item not found.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); - Assert.Null(problem.Instance); - - // Act - problem = await Assert.ThrowsAsync( - () => client.Api.Items[new(itemId)].Priority.PatchAsync(new() { Priority = TodoPriority.Low }, cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status404NotFound, problem.Status); - Assert.Equal("Not Found", problem.Title); - Assert.Equal("Item not found.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); - Assert.Null(problem.Instance); - }); - } - - [Fact] - public async Task Cannot_Create_Todo_Item_With_No_Text() - { - // Arrange - await WithTodoAppClientAsync(async (client) => - { - var cancellationToken = TestContext.Current.CancellationToken; - - // Act - var problem = await Assert.ThrowsAsync( - () => client.Api.Items.PostAsync(new() { Text = string.Empty }, cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status400BadRequest, problem.Status); - Assert.Equal("Bad Request", problem.Title); - Assert.Equal("No item text specified.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.1", problem.Type); - Assert.Null(problem.Instance); - }); - } - - [Fact] - public async Task Cannot_Complete_Todo_Item_Multiple_Times() - { - // Arrange - await WithTodoAppClientAsync(async (client) => - { - var cancellationToken = TestContext.Current.CancellationToken; - - var createdItem = await client.Api.Items.PostAsync( - new() { Text = "Something" }, - cancellationToken: cancellationToken); - - await client.Api.Items[new(createdItem.Id)].Complete.PostAsync(cancellationToken: cancellationToken); - - // Act - var problem = await Assert.ThrowsAsync( - () => client.Api.Items[new(createdItem.Id)].Complete.PostAsync(cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status400BadRequest, problem.Status); - Assert.Equal("Bad Request", problem.Title); - Assert.Equal("Item already completed.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.1", problem.Type); - Assert.Null(problem.Instance); - }); - } - - [Fact] - public async Task Cannot_Complete_Deleted_Todo_Item() - { - // Arrange - await WithTodoAppClientAsync(async (client) => - { - var cancellationToken = TestContext.Current.CancellationToken; - - var createdItem = await client.Api.Items.PostAsync( - new() { Text = "Something" }, - cancellationToken: cancellationToken); - - await client.Api.Items[new(createdItem.Id)].DeleteAsync(cancellationToken: cancellationToken); - - // Act - var problem = await Assert.ThrowsAsync( - () => client.Api.Items[new(createdItem.Id)].Complete.PostAsync(cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status404NotFound, problem.Status); - Assert.Equal("Not Found", problem.Title); - Assert.Equal("Item not found.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); - Assert.Null(problem.Instance); - }); - } - - [Fact] - public async Task Cannot_Delete_Todo_Item_Multiple_Times() + public async Task VerifyKiotaTodoAppClient() { - // Arrange - await WithTodoAppClientAsync(async (client) => - { - var cancellationToken = TestContext.Current.CancellationToken; - - var createdItem = await client.Api.Items.PostAsync( - new() { Text = "Something" }, - cancellationToken: cancellationToken); - - await client.Api.Items[new(createdItem.Id)].DeleteAsync(cancellationToken: cancellationToken); - - // Act - var problem = await Assert.ThrowsAsync( - () => client.Api.Items[new(createdItem.Id)].DeleteAsync(cancellationToken: cancellationToken)); - - // Assert - Assert.NotNull(problem); - Assert.Equal(StatusCodes.Status404NotFound, problem.Status); - Assert.Equal("Not Found", problem.Title); - Assert.Equal("Item not found.", problem.Detail); - Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); - Assert.Null(problem.Instance); - }); + await VerifyDirectory( + Path.Combine(GetProjectRoot(), "KiotaTodoClient"), + pattern: "*.cs", + options: new() { RecurseSubdirectories = true }).UseDirectory("snapshots"); } [Fact] - public async Task VerifyKiotaTodoAppClient() + public async Task VerifyNSwagTodoAppClient() { await VerifyDirectory( - Path.Combine(GetProjectRoot(), "TodoClient"), + Path.Combine(GetProjectRoot(), "NSwagTodoClient"), pattern: "*.cs", options: new() { RecurseSubdirectories = true }).UseDirectory("snapshots"); } @@ -345,18 +105,6 @@ private static string GetProjectRoot() => .GetCustomAttributes() .First((p) => p.Key is "ProjectRoot") .Value!; - - private static async Task WithTodoAppClientAsync(Func callback) - { - using var httpClient = SwaggerIntegrationTests.GetHttpClientForTestApplication(typeof(TodoApp.Program)); - - var provider = new AnonymousAuthenticationProvider(); - using var request = new HttpClientRequestAdapter(provider, httpClient: httpClient); - - var client = new TodoApiClient(request); - - await callback(client); - } } #endif diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaClientTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaClientTests.cs new file mode 100644 index 0000000000..ef794721c5 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaClientTests.cs @@ -0,0 +1,266 @@ +#if NET10_0_OR_GREATER + +using Microsoft.AspNetCore.Http; +using Microsoft.Kiota.Abstractions.Authentication; +using Microsoft.Kiota.Http.HttpClientLibrary; +using TodoApp.KiotaClient; +using TodoApp.KiotaClient.Models; + +namespace Swashbuckle.AspNetCore.IntegrationTests; + +public class KiotaClientTests +{ + [Fact] + public async Task Can_Manage_Todo_Items_With_Api() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + // Act - Get all the items + var items = await client.Api.Items.GetAsync(cancellationToken: cancellationToken); + + // Assert - There should be no items + Assert.NotNull(items); + Assert.NotNull(items.Items); + + // Arrange + var text = "Buy eggs"; + + // Act - Add a new item + var createdItem = await client.Api.Items.PostAsync( + new() { Text = text }, + cancellationToken: cancellationToken); + + // Assert - An item was created + Assert.NotNull(createdItem); + Assert.NotEqual(default, createdItem.Id); + + // Arrange - Get the new item's URL and Id + var itemId = createdItem.Id; + + // Act - Get the item + var item = await client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken); + + // Assert - Verify the item was created correctly + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Null(item.CompletedAt); + Assert.NotEqual(default, item.CreatedAt); + Assert.Equal(item.CreatedAt.Value, item.LastUpdated); + Assert.Null(item.Priority); + Assert.Equal(text, item.Text); + + // Act - Update the item to be high priority + await client.Api.Items[new(itemId)].Priority.PatchAsync( + new() { Priority = TodoPriority.High }, + cancellationToken: cancellationToken); + + item = await client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken); + + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Null(item.CompletedAt); + Assert.NotEqual(default, item.CreatedAt); + Assert.Equal(item.CreatedAt.Value, item.LastUpdated); + Assert.Equal(TodoPriority.High, item.Priority); + Assert.Equal(text, item.Text); + + // Act - Mark the item as being completed + await client.Api.Items[new(itemId)].Complete.PostAsync(cancellationToken: cancellationToken); + + item = await client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken); + + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Equal(text, item.Text); + Assert.NotNull(item.CompletedAt); + Assert.Equal(item.CompletedAt.Value, item.LastUpdated); + Assert.True(item.CompletedAt.Value > item.CreatedAt); + + // Act - Get all the items + items = await client.Api.Items.GetAsync(cancellationToken: cancellationToken); + + // Assert - The item was completed + Assert.NotNull(items); + Assert.NotNull(items.Items); + Assert.Contains(items.Items, (x) => x.Id == itemId); + + item = items.Items.Single((p) => p.Id == itemId); + + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Equal(text, item.Text); + Assert.NotNull(item.CompletedAt); + Assert.Equal(item.CompletedAt.Value, item.LastUpdated); + Assert.True(item.CompletedAt.Value > item.CreatedAt); + + // Act - Delete the item + await client.Api.Items[new(itemId)].DeleteAsync(cancellationToken: cancellationToken); + + // Assert - The item no longer exists + items = await client.Api.Items.GetAsync(cancellationToken: cancellationToken); + + Assert.NotNull(items); + Assert.NotNull(items.Items); + Assert.DoesNotContain(items.Items, (x) => x.Id == itemId); + + // Act + var problem = await Assert.ThrowsAsync( + () => client.Api.Items[new(itemId)].GetAsync(cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + + // Act + problem = await Assert.ThrowsAsync( + () => client.Api.Items[new(itemId)].Complete.PostAsync(cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + + // Act + problem = await Assert.ThrowsAsync( + () => client.Api.Items[new(itemId)].Priority.PatchAsync(new() { Priority = TodoPriority.Low }, cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Create_Todo_Item_With_No_Text() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + // Act + var problem = await Assert.ThrowsAsync( + () => client.Api.Items.PostAsync(new() { Text = string.Empty }, cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status400BadRequest, problem.Status); + Assert.Equal("Bad Request", problem.Title); + Assert.Equal("No item text specified.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.1", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Complete_Todo_Item_Multiple_Times() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + var createdItem = await client.Api.Items.PostAsync( + new() { Text = "Something" }, + cancellationToken: cancellationToken); + + await client.Api.Items[new(createdItem.Id)].Complete.PostAsync(cancellationToken: cancellationToken); + + // Act + var problem = await Assert.ThrowsAsync( + () => client.Api.Items[new(createdItem.Id)].Complete.PostAsync(cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status400BadRequest, problem.Status); + Assert.Equal("Bad Request", problem.Title); + Assert.Equal("Item already completed.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.1", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Complete_Deleted_Todo_Item() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + var createdItem = await client.Api.Items.PostAsync( + new() { Text = "Something" }, + cancellationToken: cancellationToken); + + await client.Api.Items[new(createdItem.Id)].DeleteAsync(cancellationToken: cancellationToken); + + // Act + var problem = await Assert.ThrowsAsync( + () => client.Api.Items[new(createdItem.Id)].Complete.PostAsync(cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Delete_Todo_Item_Multiple_Times() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + var createdItem = await client.Api.Items.PostAsync( + new() { Text = "Something" }, + cancellationToken: cancellationToken); + + await client.Api.Items[new(createdItem.Id)].DeleteAsync(cancellationToken: cancellationToken); + + // Act + var problem = await Assert.ThrowsAsync( + () => client.Api.Items[new(createdItem.Id)].DeleteAsync(cancellationToken: cancellationToken)); + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + }); + } + + private static async Task WithTodoAppClientAsync(Func callback) + { + using var httpClient = SwaggerIntegrationTests.GetHttpClientForTestApplication(typeof(TodoApp.Program)); + + var provider = new AnonymousAuthenticationProvider(); + using var request = new HttpClientRequestAdapter(provider, httpClient: httpClient); + + var client = new KiotaTodoApiClient(request); + + await callback(client); + } +} + +#endif diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/ApiRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/ApiRequestBuilder.cs similarity index 72% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/ApiRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/ApiRequestBuilder.cs index 41b43725aa..cf1d7dfbba 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/ApiRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/ApiRequestBuilder.cs @@ -6,8 +6,8 @@ using System.IO; using System.Threading.Tasks; using System; -using TodoApp.Client.Api.Items; -namespace TodoApp.Client.Api +using TodoApp.KiotaClient.Api.Items; +namespace TodoApp.KiotaClient.Api { /// /// Builds and executes requests for operations under \api @@ -16,12 +16,12 @@ namespace TodoApp.Client.Api public partial class ApiRequestBuilder : BaseRequestBuilder { /// The items property - public global::TodoApp.Client.Api.Items.ItemsRequestBuilder Items + public global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder Items { - get => new global::TodoApp.Client.Api.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -29,7 +29,7 @@ public ApiRequestBuilder(Dictionary pathParameters, IRequestAdap { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Find/FindRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Find/FindRequestBuilder.cs similarity index 66% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Find/FindRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Find/FindRequestBuilder.cs index 88a9b963c9..9a58727fdb 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Find/FindRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Find/FindRequestBuilder.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Find +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Find { /// /// Builds and executes requests for operations under \api\items\find @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.Find public partial class FindRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,37 +26,37 @@ public FindRequestBuilder(Dictionary pathParameters, IRequestAda { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. public FindRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/items/find?IsCompleted={IsCompleted}&Text={Text}", rawUrl) { } - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); } /// A /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -67,11 +67,11 @@ public RequestInformation ToGetRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Find.FindRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Find.FindRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder(rawUrl, RequestAdapter); } [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] #pragma warning disable CS1591 diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/GetAfter/GetAfterRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/GetAfter/GetAfterRequestBuilder.cs similarity index 63% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/GetAfter/GetAfterRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/GetAfter/GetAfterRequestBuilder.cs index 08a2cd13ad..00bdb7d2c2 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/GetAfter/GetAfterRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/GetAfter/GetAfterRequestBuilder.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.GetAfter +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.GetAfter { /// /// Builds and executes requests for operations under \api\items\getAfter @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.GetAfter public partial class GetAfterRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,37 +26,37 @@ public GetAfterRequestBuilder(Dictionary pathParameters, IReques { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. public GetAfterRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/items/getAfter?value={value}", rawUrl) { } - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); } /// A /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -67,11 +67,11 @@ public RequestInformation ToGetRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder(rawUrl, RequestAdapter); } [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] #pragma warning disable CS1591 diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/Complete/CompleteRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/Complete/CompleteRequestBuilder.cs similarity index 76% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/Complete/CompleteRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/Complete/CompleteRequestBuilder.cs index d60b464e51..6066898ce7 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/Complete/CompleteRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/Complete/CompleteRequestBuilder.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Item.Complete +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Item.Complete { /// /// Builds and executes requests for operations under \api\items\{id}\complete @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.Item.Complete public partial class CompleteRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,7 +26,7 @@ public CompleteRequestBuilder(Dictionary pathParameters, IReques { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -38,8 +38,8 @@ public CompleteRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : b /// /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 400 status code - /// When receiving a 404 status code + /// When receiving a 400 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable public async Task PostAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) @@ -52,8 +52,8 @@ public async Task PostAsync(Action> var requestInfo = ToPostRequestInformation(requestConfiguration); var errorMapping = new Dictionary> { - { "400", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "400", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); } @@ -79,11 +79,11 @@ public RequestInformation ToPostRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/ItemsItemRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/ItemsItemRequestBuilder.cs similarity index 70% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/ItemsItemRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/ItemsItemRequestBuilder.cs index 7a7d75d5df..6b623d4b2c 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/ItemsItemRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/ItemsItemRequestBuilder.cs @@ -8,10 +8,10 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Api.Items.Item.Complete; -using TodoApp.Client.Api.Items.Item.Priority; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Item +using TodoApp.KiotaClient.Api.Items.Item.Complete; +using TodoApp.KiotaClient.Api.Items.Item.Priority; +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Item { /// /// Builds and executes requests for operations under \api\items\{id} @@ -20,17 +20,17 @@ namespace TodoApp.Client.Api.Items.Item public partial class ItemsItemRequestBuilder : BaseRequestBuilder { /// The complete property - public global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder Complete + public global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder Complete { - get => new global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder(PathParameters, RequestAdapter); } /// The priority property - public global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder Priority + public global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder Priority { - get => new global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder(PathParameters, RequestAdapter); } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -38,7 +38,7 @@ public ItemsItemRequestBuilder(Dictionary pathParameters, IReque { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -50,7 +50,7 @@ public ItemsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : /// /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 404 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) @@ -63,32 +63,32 @@ public async Task DeleteAsync(Action> { - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); } /// /// Gets the todo item with the specified ID. /// - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 404 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); var errorMapping = new Dictionary> { - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); } /// /// Deletes the todo item with the specified ID. @@ -131,11 +131,11 @@ public RequestInformation ToGetRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/Priority/PriorityRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/Priority/PriorityRequestBuilder.cs similarity index 66% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/Priority/PriorityRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/Priority/PriorityRequestBuilder.cs index 52e95a1cb8..e5fbaa60b9 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/Item/Priority/PriorityRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/Item/Priority/PriorityRequestBuilder.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Item.Priority +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Item.Priority { /// /// Builds and executes requests for operations under \api\items\{id}\priority @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.Item.Priority public partial class PriorityRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,7 +26,7 @@ public PriorityRequestBuilder(Dictionary pathParameters, IReques { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -39,23 +39,23 @@ public PriorityRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : b /// Represents the model for updating the priority of a Todo item. /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 400 status code - /// When receiving a 404 status code + /// When receiving a 400 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task PatchAsync(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PatchAsync(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task PatchAsync(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PatchAsync(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); var requestInfo = ToPatchRequestInformation(body, requestConfiguration); var errorMapping = new Dictionary> { - { "400", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "400", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); } @@ -67,11 +67,11 @@ public async Task PatchAsync(global::TodoApp.Client.Models.UpdateTodoItemPriorit /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToPatchRequestInformation(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default) + public RequestInformation ToPatchRequestInformation(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToPatchRequestInformation(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default) + public RequestInformation ToPatchRequestInformation(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); @@ -84,11 +84,11 @@ public RequestInformation ToPatchRequestInformation(global::TodoApp.Client.Model /// /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/ItemsRequestBuilder.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/ItemsRequestBuilder.cs similarity index 60% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/ItemsRequestBuilder.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/ItemsRequestBuilder.cs index 489335512c..d71a1c9e4b 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Api/Items/ItemsRequestBuilder.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Api/Items/ItemsRequestBuilder.cs @@ -8,11 +8,11 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Api.Items.Find; -using TodoApp.Client.Api.Items.GetAfter; -using TodoApp.Client.Api.Items.Item; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items +using TodoApp.KiotaClient.Api.Items.Find; +using TodoApp.KiotaClient.Api.Items.GetAfter; +using TodoApp.KiotaClient.Api.Items.Item; +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items { /// /// Builds and executes requests for operations under \api\items @@ -21,29 +21,29 @@ namespace TodoApp.Client.Api.Items public partial class ItemsRequestBuilder : BaseRequestBuilder { /// The find property - public global::TodoApp.Client.Api.Items.Find.FindRequestBuilder Find + public global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder Find { - get => new global::TodoApp.Client.Api.Items.Find.FindRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder(PathParameters, RequestAdapter); } /// The getAfter property - public global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder GetAfter + public global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder GetAfter { - get => new global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder(PathParameters, RequestAdapter); } - /// Gets an item from the TodoApp.Client.api.items.item collection + /// Gets an item from the TodoApp.KiotaClient.api.items.item collection /// The Todo item's ID. - /// A - public global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder this[Guid position] + /// A + public global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder this[Guid position] { get { var urlTplParams = new Dictionary(PathParameters); urlTplParams.Add("id", position); - return new global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder(urlTplParams, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder(urlTplParams, RequestAdapter); } } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -51,7 +51,7 @@ public ItemsRequestBuilder(Dictionary pathParameters, IRequestAd { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -61,45 +61,45 @@ public ItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base /// /// Gets all of the current user's todo items. /// - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); } /// /// Creates a new todo item for the current user and returns its ID. /// - /// A + /// A /// Represents the model for creating a new Todo item. /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 400 status code + /// When receiving a 400 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task PostAsync(global::TodoApp.Client.Models.CreateTodoItemModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PostAsync(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task PostAsync(global::TodoApp.Client.Models.CreateTodoItemModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PostAsync(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); var requestInfo = ToPostRequestInformation(body, requestConfiguration); var errorMapping = new Dictionary> { - { "400", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "400", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.CreatedTodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.CreatedTodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); } /// /// Gets all of the current user's todo items. @@ -128,11 +128,11 @@ public RequestInformation ToGetRequestInformation(ActionConfiguration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToPostRequestInformation(global::TodoApp.Client.Models.CreateTodoItemModel body, Action>? requestConfiguration = default) + public RequestInformation ToPostRequestInformation(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToPostRequestInformation(global::TodoApp.Client.Models.CreateTodoItemModel body, Action> requestConfiguration = default) + public RequestInformation ToPostRequestInformation(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action> requestConfiguration = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); @@ -145,11 +145,11 @@ public RequestInformation ToPostRequestInformation(global::TodoApp.Client.Models /// /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.ItemsRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.ItemsRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/TodoApiClient.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/KiotaTodoApiClient.cs similarity index 72% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/TodoApiClient.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/KiotaTodoApiClient.cs index 0d5631bb7d..8004d932a7 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/TodoApiClient.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/KiotaTodoApiClient.cs @@ -10,25 +10,25 @@ using System.IO; using System.Threading.Tasks; using System; -using TodoApp.Client.Api; -namespace TodoApp.Client +using TodoApp.KiotaClient.Api; +namespace TodoApp.KiotaClient { /// /// The main entry point of the SDK, exposes the configuration and the fluent API. /// [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] - public partial class TodoApiClient : BaseRequestBuilder + public partial class KiotaTodoApiClient : BaseRequestBuilder { /// The api property - public global::TodoApp.Client.Api.ApiRequestBuilder Api + public global::TodoApp.KiotaClient.Api.ApiRequestBuilder Api { - get => new global::TodoApp.Client.Api.ApiRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.ApiRequestBuilder(PathParameters, RequestAdapter); } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The request adapter to use to execute the requests. - public TodoApiClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary()) + public KiotaTodoApiClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary()) { ApiClientBuilder.RegisterDefaultSerializer(); ApiClientBuilder.RegisterDefaultSerializer(); diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/CreateTodoItemModel.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/CreateTodoItemModel.cs similarity index 85% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/CreateTodoItemModel.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/CreateTodoItemModel.cs index 997121bab3..03601c216e 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/CreateTodoItemModel.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/CreateTodoItemModel.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents the model for creating a new Todo item. @@ -24,12 +24,12 @@ public partial class CreateTodoItemModel : IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.CreateTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.CreateTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.CreateTodoItemModel(); + return new global::TodoApp.KiotaClient.Models.CreateTodoItemModel(); } /// /// The deserialization information for the current model diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/CreatedTodoItemModel.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/CreatedTodoItemModel.cs similarity index 85% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/CreatedTodoItemModel.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/CreatedTodoItemModel.cs index e3ebeb104f..fa8df5aed1 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/CreatedTodoItemModel.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/CreatedTodoItemModel.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents the model for a created Todo item. @@ -24,12 +24,12 @@ public partial class CreatedTodoItemModel : IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.CreatedTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.CreatedTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.CreatedTodoItemModel(); + return new global::TodoApp.KiotaClient.Models.CreatedTodoItemModel(); } /// /// The deserialization information for the current model diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/ProblemDetails.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/ProblemDetails.cs similarity index 91% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/ProblemDetails.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/ProblemDetails.cs index 49aa45adb4..39192b24dc 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/ProblemDetails.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/ProblemDetails.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] #pragma warning disable CS1591 @@ -52,12 +52,12 @@ public partial class ProblemDetails : ApiException, IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.ProblemDetails CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.ProblemDetails CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.ProblemDetails(); + return new global::TodoApp.KiotaClient.Models.ProblemDetails(); } /// /// The deserialization information for the current model diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoItemModel.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoItemModel.cs similarity index 85% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoItemModel.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoItemModel.cs index 10a9a52b98..8633f21341 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoItemModel.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoItemModel.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents a Todo item. @@ -28,7 +28,7 @@ public partial class TodoItemModel : IParsable /// Gets or sets the date and time the Todo item was last updated. public DateTimeOffset? LastUpdated { get; set; } /// Gets or sets the optional priority of the Todo item. - public global::TodoApp.Client.Models.TodoPriority? Priority { get; set; } + public global::TodoApp.KiotaClient.Models.TodoPriority? Priority { get; set; } /// Gets or sets the text of the Todo item. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable @@ -40,12 +40,12 @@ public partial class TodoItemModel : IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.TodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.TodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.TodoItemModel(); + return new global::TodoApp.KiotaClient.Models.TodoItemModel(); } /// /// The deserialization information for the current model @@ -59,7 +59,7 @@ public virtual IDictionary> GetFieldDeserializers() { "createdAt", n => { CreatedAt = n.GetDateTimeOffsetValue(); } }, { "id", n => { Id = n.GetStringValue(); } }, { "lastUpdated", n => { LastUpdated = n.GetDateTimeOffsetValue(); } }, - { "priority", n => { Priority = n.GetEnumValue(); } }, + { "priority", n => { Priority = n.GetEnumValue(); } }, { "text", n => { Text = n.GetStringValue(); } }, }; } @@ -74,7 +74,7 @@ public virtual void Serialize(ISerializationWriter writer) writer.WriteDateTimeOffsetValue("createdAt", CreatedAt); writer.WriteStringValue("id", Id); writer.WriteDateTimeOffsetValue("lastUpdated", LastUpdated); - writer.WriteEnumValue("priority", Priority); + writer.WriteEnumValue("priority", Priority); writer.WriteStringValue("text", Text); } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoListViewModel.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoListViewModel.cs similarity index 72% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoListViewModel.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoListViewModel.cs index d7fb2e91ac..956d7a4bc2 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoListViewModel.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoListViewModel.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents a collection of Todo items. @@ -16,20 +16,20 @@ public partial class TodoListViewModel : IParsable /// Gets or sets the Todo item(s). #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public List? Items { get; set; } + public List? Items { get; set; } #nullable restore #else - public List Items { get; set; } + public List Items { get; set; } #endif /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.TodoListViewModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.TodoListViewModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.TodoListViewModel(); + return new global::TodoApp.KiotaClient.Models.TodoListViewModel(); } /// /// The deserialization information for the current model @@ -39,7 +39,7 @@ public virtual IDictionary> GetFieldDeserializers() { return new Dictionary> { - { "items", n => { Items = n.GetCollectionOfObjectValues(global::TodoApp.Client.Models.TodoItemModel.CreateFromDiscriminatorValue)?.AsList(); } }, + { "items", n => { Items = n.GetCollectionOfObjectValues(global::TodoApp.KiotaClient.Models.TodoItemModel.CreateFromDiscriminatorValue)?.AsList(); } }, }; } /// @@ -49,7 +49,7 @@ public virtual IDictionary> GetFieldDeserializers() public virtual void Serialize(ISerializationWriter writer) { if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("items", Items); + writer.WriteCollectionOfObjectValues("items", Items); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoPriority.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoPriority.cs similarity index 94% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoPriority.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoPriority.cs index 5200deb280..6121c0347d 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/TodoPriority.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/TodoPriority.cs @@ -1,7 +1,7 @@ // using System.Runtime.Serialization; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// The priority levels for a Todo item. [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/UpdateTodoItemPriorityModel.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/UpdateTodoItemPriorityModel.cs similarity index 74% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/UpdateTodoItemPriorityModel.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/UpdateTodoItemPriorityModel.cs index f2a9c6e583..cbd30b12e5 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/Models/UpdateTodoItemPriorityModel.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/Models/UpdateTodoItemPriorityModel.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents the model for updating the priority of a Todo item. @@ -14,16 +14,16 @@ namespace TodoApp.Client.Models public partial class UpdateTodoItemPriorityModel : IParsable { /// Gets or sets the new priority of the Todo item. - public global::TodoApp.Client.Models.TodoPriority? Priority { get; set; } + public global::TodoApp.KiotaClient.Models.TodoPriority? Priority { get; set; } /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.UpdateTodoItemPriorityModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.UpdateTodoItemPriorityModel(); + return new global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel(); } /// /// The deserialization information for the current model @@ -33,7 +33,7 @@ public virtual IDictionary> GetFieldDeserializers() { return new Dictionary> { - { "priority", n => { Priority = n.GetEnumValue(); } }, + { "priority", n => { Priority = n.GetEnumValue(); } }, }; } /// @@ -43,7 +43,7 @@ public virtual IDictionary> GetFieldDeserializers() public virtual void Serialize(ISerializationWriter writer) { if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); - writer.WriteEnumValue("priority", Priority); + writer.WriteEnumValue("priority", Priority); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/kiota-lock.json b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/kiota-lock.json similarity index 93% rename from test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/kiota-lock.json rename to test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/kiota-lock.json index 497c46d4b3..3804519fed 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/TodoClient/kiota-lock.json +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/KiotaTodoClient/kiota-lock.json @@ -3,9 +3,9 @@ "descriptionLocation": "../snapshots/VerifyTests.Swagger_IsValidJson_No_Startup_entryPointType=TodoApp.Program_swaggerRequestUri=v1.DotNet10_0.verified.txt", "lockFileVersion": "1.0.0", "kiotaVersion": "1.29.0", - "clientClassName": "TodoApiClient", + "clientClassName": "KiotaTodoApiClient", "typeAccessModifier": "Public", - "clientNamespaceName": "TodoApp.Client", + "clientNamespaceName": "TodoApp.KiotaClient", "language": "CSharp", "usesBackingStore": false, "excludeBackwardCompatible": true, diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/NSwagClientTests.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/NSwagClientTests.cs new file mode 100644 index 0000000000..5d40b19bf7 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/NSwagClientTests.cs @@ -0,0 +1,275 @@ +#if NET10_0_OR_GREATER + +using Microsoft.AspNetCore.Http; +using TodoApp.NSwagClient; + +namespace Swashbuckle.AspNetCore.IntegrationTests; + +public class NSwagClientTests +{ + [Fact] + public async Task Can_Manage_Todo_Items_With_Api() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + // Act - Get all the items + var items = await client.ListTodosAsync(cancellationToken); + + // Assert + Assert.NotNull(items); + Assert.NotNull(items.Items); + + // Arrange + var text = "Buy eggs"; + + // Act - Add a new item + var createdItem = await client.CreateTodoAsync( + new() { Text = text }, + cancellationToken); + + // Assert - An item was created + Assert.NotNull(createdItem); + Assert.NotEqual(default, createdItem.Id); + + // Arrange - Get the new item's URL and Id + var itemId = createdItem.Id; + + // Act - Get the item + var item = await client.GetTodoAsync(new(itemId), cancellationToken); + + // Assert - Verify the item was created correctly + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Null(item.CompletedAt); + Assert.NotEqual(default, item.CreatedAt); + Assert.Equal(item.CreatedAt, item.LastUpdated); + Assert.Equal(TodoPriority.Normal, item.Priority); + Assert.Equal(text, item.Text); + + // Act - Update the item to be high priority + await client.UpdateTodoPriorityAsync( + new(itemId), + new() { Priority = TodoPriority.High }, + cancellationToken); + + item = await client.GetTodoAsync(new(itemId), cancellationToken); + + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Null(item.CompletedAt); + Assert.NotEqual(default, item.CreatedAt); + Assert.Equal(item.CreatedAt, item.LastUpdated); + Assert.Equal(TodoPriority.High, item.Priority); + Assert.Equal(text, item.Text); + + // Act - Mark the item as being completed + await client.CompleteTodoAsync(new(itemId), cancellationToken); + + item = await client.GetTodoAsync(new(itemId), cancellationToken); + + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Equal(text, item.Text); + Assert.NotNull(item.CompletedAt); + Assert.Equal(item.CompletedAt.Value, item.LastUpdated); + Assert.True(item.CompletedAt.Value > item.CreatedAt); + + // Act - Get all the items + items = await client.ListTodosAsync(cancellationToken); + + // Assert - The item was completed + Assert.NotNull(items); + Assert.NotNull(items.Items); + Assert.Contains(items.Items, (x) => x.Id == itemId); + + item = items.Items.Single((p) => p.Id == itemId); + + Assert.NotNull(item); + Assert.Equal(itemId, item.Id); + Assert.Equal(text, item.Text); + Assert.NotNull(item.CompletedAt); + Assert.Equal(item.CompletedAt.Value, item.LastUpdated); + Assert.True(item.CompletedAt.Value > item.CreatedAt); + + // Act - Delete the item + await client.DeleteTodoAsync(new(itemId), cancellationToken); + + // Assert - The item no longer exists + items = await client.ListTodosAsync(cancellationToken); + + Assert.NotNull(items); + Assert.NotNull(items.Items); + Assert.DoesNotContain(items.Items, (x) => x.Id == itemId); + + // Act + var error = await Assert.ThrowsAsync>( + () => client.GetTodoAsync(new(itemId), cancellationToken)); + + var problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + + // Act + error = await Assert.ThrowsAsync>( + () => client.CompleteTodoAsync(new(itemId), cancellationToken)); + + problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + + // Act + error = await Assert.ThrowsAsync>( + () => client.UpdateTodoPriorityAsync(new(itemId), new() { Priority = TodoPriority.Low }, cancellationToken)); + + problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Create_Todo_Item_With_No_Text() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + // Act + var error = await Assert.ThrowsAsync>( + () => client.CreateTodoAsync(new() { Text = string.Empty }, cancellationToken)); + + var problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status400BadRequest, problem.Status); + Assert.Equal("Bad Request", problem.Title); + Assert.Equal("No item text specified.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.1", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Complete_Todo_Item_Multiple_Times() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + var createdItem = await client.CreateTodoAsync( + new() { Text = "Something" }, + cancellationToken); + + await client.CompleteTodoAsync(new(createdItem.Id), cancellationToken); + + // Act + var error = await Assert.ThrowsAsync>( + () => client.CompleteTodoAsync(new(createdItem.Id), cancellationToken)); + + var problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status400BadRequest, problem.Status); + Assert.Equal("Bad Request", problem.Title); + Assert.Equal("Item already completed.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.1", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Complete_Deleted_Todo_Item() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + var createdItem = await client.CreateTodoAsync( + new() { Text = "Something" }, + cancellationToken); + + await client.DeleteTodoAsync(new(createdItem.Id), cancellationToken); + + // Act + var error = await Assert.ThrowsAsync>( + () => client.CompleteTodoAsync(new(createdItem.Id), cancellationToken)); + + var problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + }); + } + + [Fact] + public async Task Cannot_Delete_Todo_Item_Multiple_Times() + { + // Arrange + await WithTodoAppClientAsync(async (client) => + { + var cancellationToken = TestContext.Current.CancellationToken; + + var createdItem = await client.CreateTodoAsync( + new() { Text = "Something" }, + cancellationToken); + + await client.DeleteTodoAsync(new(createdItem.Id), cancellationToken); + + // Act + var error = await Assert.ThrowsAsync>( + () => client.DeleteTodoAsync(new(createdItem.Id), cancellationToken)); + + var problem = error.Result; + + // Assert + Assert.NotNull(problem); + Assert.Equal(StatusCodes.Status404NotFound, problem.Status); + Assert.Equal("Not Found", problem.Title); + Assert.Equal("Item not found.", problem.Detail); + Assert.Equal("https://tools.ietf.org/html/rfc9110#section-15.5.5", problem.Type); + Assert.Null(problem.Instance); + }); + } + + private static async Task WithTodoAppClientAsync(Func callback) + { + using var httpClient = SwaggerIntegrationTests.GetHttpClientForTestApplication(typeof(TodoApp.Program)); + + var client = new NSwagTodoApiClient(httpClient.BaseAddress.ToString(), httpClient); + + await callback(client); + } +} + +#endif diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/NSwagTodoClient/NSwagTodoClient.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/NSwagTodoClient/NSwagTodoClient.cs new file mode 100644 index 0000000000..5fcf225438 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/NSwagTodoClient/NSwagTodoClient.cs @@ -0,0 +1,1224 @@ +//---------------------- +// +// Generated using the NSwag toolchain v14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) +// +//---------------------- + +#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." +#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." +#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' +#pragma warning disable 612 // Disable "CS0612 '...' is obsolete" +#pragma warning disable 649 // Disable "CS0649 Field is never assigned to, and will always have its default value null" +#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... +#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." +#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" +#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" +#pragma warning disable 8600 // Disable "CS8600 Converting null literal or possible null value to non-nullable type" +#pragma warning disable 8602 // Disable "CS8602 Dereference of a possibly null reference" +#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" +#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter" +#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type" +#pragma warning disable 8765 // Disable "CS8765 Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes)." + +namespace TodoApp.NSwagClient +{ + using System = global::System; + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class NSwagTodoApiClient + { + #pragma warning disable 8618 + private string _baseUrl; + #pragma warning restore 8618 + + private System.Net.Http.HttpClient _httpClient; + private static System.Lazy _settings = new System.Lazy(CreateSerializerSettings, true); + private Newtonsoft.Json.JsonSerializerSettings _instanceSettings; + + #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public NSwagTodoApiClient(string baseUrl, System.Net.Http.HttpClient httpClient) + #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + { + BaseUrl = baseUrl; + _httpClient = httpClient; + Initialize(); + } + + private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() + { + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + UpdateJsonSerializerSettings(settings); + return settings; + } + + public string BaseUrl + { + get { return _baseUrl; } + set + { + _baseUrl = value; + if (!string.IsNullOrEmpty(_baseUrl) && !_baseUrl.EndsWith("/")) + _baseUrl += '/'; + } + } + + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _instanceSettings ?? _settings.Value; } } + + static partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); + + partial void Initialize(); + + partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); + partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); + partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); + + /// + /// Get all Todo items + /// + /// + /// Gets all of the current user's todo items. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task ListTodosAsync() + { + return ListTodosAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get all Todo items + /// + /// + /// Gets all of the current user's todo items. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task ListTodosAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items" + urlBuilder_.Append("api/items"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Create a new Todo item + /// + /// + /// Creates a new todo item for the current user and returns its ID. + /// + /// Created + /// A server side error occurred. + public virtual System.Threading.Tasks.Task CreateTodoAsync(CreateTodoItemModel body) + { + return CreateTodoAsync(body, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Create a new Todo item + /// + /// + /// Creates a new todo item for the current user and returns its ID. + /// + /// Created + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task CreateTodoAsync(CreateTodoItemModel body, System.Threading.CancellationToken cancellationToken) + { + if (body == null) + throw new System.ArgumentNullException("body"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); + var content_ = new System.Net.Http.StringContent(json_); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; + request_.Method = new System.Net.Http.HttpMethod("POST"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items" + urlBuilder_.Append("api/items"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 201) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + if (status_ == 400) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Get a specific Todo item + /// + /// + /// Gets the todo item with the specified ID. + /// + /// The Todo item's ID. + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetTodoAsync(System.Guid id) + { + return GetTodoAsync(id, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get a specific Todo item + /// + /// + /// Gets the todo item with the specified ID. + /// + /// The Todo item's ID. + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetTodoAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Delete a Todo item + /// + /// + /// Deletes the todo item with the specified ID. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual System.Threading.Tasks.Task DeleteTodoAsync(System.Guid id) + { + return DeleteTodoAsync(id, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Delete a Todo item + /// + /// + /// Deletes the todo item with the specified ID. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task DeleteTodoAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("DELETE"); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 204) + { + return; + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Mark a Todo item as completed + /// + /// + /// Marks the todo item with the specified ID as complete. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual System.Threading.Tasks.Task CompleteTodoAsync(System.Guid id) + { + return CompleteTodoAsync(id, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Mark a Todo item as completed + /// + /// + /// Marks the todo item with the specified ID as complete. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task CompleteTodoAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); + request_.Method = new System.Net.Http.HttpMethod("POST"); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}/complete" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("/complete"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 204) + { + return; + } + else + if (status_ == 400) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Updates the priority of a Todo item + /// + /// + /// Updates the priority of the todo item with the specified ID to the specified priority. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual System.Threading.Tasks.Task UpdateTodoPriorityAsync(System.Guid id, UpdateTodoItemPriorityModel body) + { + return UpdateTodoPriorityAsync(id, body, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Updates the priority of a Todo item + /// + /// + /// Updates the priority of the todo item with the specified ID to the specified priority. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task UpdateTodoPriorityAsync(System.Guid id, UpdateTodoItemPriorityModel body, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + if (body == null) + throw new System.ArgumentNullException("body"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); + var content_ = new System.Net.Http.StringContent(json_); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; + request_.Method = new System.Net.Http.HttpMethod("PATCH"); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}/priority" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("/priority"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 204) + { + return; + } + else + if (status_ == 400) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// Gets or sets the text of the filter. + /// Gets or sets a value indicating whether to search completed Todo items. + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task FindTodoAsync(string text, bool isCompleted) + { + return FindTodoAsync(text, isCompleted, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// Gets or sets the text of the filter. + /// Gets or sets a value indicating whether to search completed Todo items. + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task FindTodoAsync(string text, bool isCompleted, System.Threading.CancellationToken cancellationToken) + { + if (text == null) + throw new System.ArgumentNullException("text"); + + if (isCompleted == null) + throw new System.ArgumentNullException("isCompleted"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/find" + urlBuilder_.Append("api/items/find"); + urlBuilder_.Append('?'); + urlBuilder_.Append(System.Uri.EscapeDataString("Text")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(text, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Append(System.Uri.EscapeDataString("IsCompleted")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(isCompleted, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Length--; + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetAfterDateAsync(System.DateTimeOffset value) + { + return GetAfterDateAsync(value, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetAfterDateAsync(System.DateTimeOffset value, System.Threading.CancellationToken cancellationToken) + { + if (value == null) + throw new System.ArgumentNullException("value"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/getAfter" + urlBuilder_.Append("api/items/getAfter"); + urlBuilder_.Append('?'); + urlBuilder_.Append(System.Uri.EscapeDataString("value")).Append('=').Append(System.Uri.EscapeDataString(value.ToString("s", System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Length--; + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + protected struct ObjectResponseResult + { + public ObjectResponseResult(T responseObject, string responseText) + { + this.Object = responseObject; + this.Text = responseText; + } + + public T Object { get; } + + public string Text { get; } + } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + private static System.Threading.Tasks.Task ReadAsStringAsync(System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken) + { + #if NET5_0_OR_GREATER + return content.ReadAsStringAsync(cancellationToken); + #else + return content.ReadAsStringAsync(); + #endif + } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + private static System.Threading.Tasks.Task ReadAsStreamAsync(System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken) + { + #if NET5_0_OR_GREATER + return content.ReadAsStreamAsync(cancellationToken); + #else + return content.ReadAsStreamAsync(); + #endif + } + + public bool ReadResponseAsString { get; set; } + + protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) + { + if (response == null || response.Content == null) + { + return new ObjectResponseResult(default(T), string.Empty); + } + + if (ReadResponseAsString) + { + var responseText = await ReadAsStringAsync(response.Content, cancellationToken).ConfigureAwait(false); + try + { + var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); + return new ObjectResponseResult(typedBody, responseText); + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; + throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); + } + } + else + { + try + { + using (var responseStream = await ReadAsStreamAsync(response.Content, cancellationToken).ConfigureAwait(false)) + using (var streamReader = new System.IO.StreamReader(responseStream)) + using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) + { + var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); + var typedBody = serializer.Deserialize(jsonTextReader); + return new ObjectResponseResult(typedBody, string.Empty); + } + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; + throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); + } + } + } + + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) + { + if (value == null) + { + return ""; + } + + if (value is System.Enum) + { + var name = System.Enum.GetName(value.GetType(), value); + if (name != null) + { + var field_ = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); + if (field_ != null) + { + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field_, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + as System.Runtime.Serialization.EnumMemberAttribute; + if (attribute != null) + { + return attribute.Value != null ? attribute.Value : name; + } + } + + var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); + return converted == null ? string.Empty : converted; + } + } + else if (value is bool) + { + return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); + } + else if (value is byte[]) + { + return System.Convert.ToBase64String((byte[]) value); + } + else if (value is string[]) + { + return string.Join(",", (string[])value); + } + else if (value.GetType().IsArray) + { + var valueArray = (System.Array)value; + var valueTextArray = new string[valueArray.Length]; + for (var i = 0; i < valueArray.Length; i++) + { + valueTextArray[i] = ConvertToString(valueArray.GetValue(i), cultureInfo); + } + return string.Join(",", valueTextArray); + } + + var result = System.Convert.ToString(value, cultureInfo); + return result == null ? "" : result; + } + } + + /// + /// Represents the model for creating a new Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class CreateTodoItemModel + { + + /// + /// Gets or sets the text of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("text", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Text { get; set; } + + } + + /// + /// Represents the model for a created Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class CreatedTodoItemModel + { + + /// + /// Gets or sets the ID of the created Todo item. + /// + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Id { get; set; } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ProblemDetails + { + + [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Type { get; set; } + + [Newtonsoft.Json.JsonProperty("title", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Title { get; set; } + + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int? Status { get; set; } + + [Newtonsoft.Json.JsonProperty("detail", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Detail { get; set; } + + [Newtonsoft.Json.JsonProperty("instance", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Instance { get; set; } + + private System.Collections.Generic.IDictionary _additionalProperties; + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary AdditionalProperties + { + get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary()); } + set { _additionalProperties = value; } + } + + } + + /// + /// Represents a Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class TodoItemModel + { + + /// + /// Gets or sets the ID of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Id { get; set; } + + /// + /// Gets or sets the text of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("text", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Text { get; set; } + + /// + /// Gets or sets the date and time the item was created. + /// + [Newtonsoft.Json.JsonProperty("createdAt", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset CreatedAt { get; set; } + + /// + /// Gets or sets the date and time the item was completed. + /// + [Newtonsoft.Json.JsonProperty("completedAt", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? CompletedAt { get; set; } + + /// + /// Gets or sets the date and time the Todo item was last updated. + /// + [Newtonsoft.Json.JsonProperty("lastUpdated", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset LastUpdated { get; set; } + + /// + /// Gets or sets the optional priority of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("priority", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public TodoPriority Priority { get; set; } + + } + + /// + /// Represents a collection of Todo items. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class TodoListViewModel + { + + /// + /// Gets or sets the Todo item(s). + /// + [Newtonsoft.Json.JsonProperty("items", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection Items { get; set; } + + } + + /// + /// The priority levels for a Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public enum TodoPriority + { + + [System.Runtime.Serialization.EnumMember(Value = @"Normal")] + Normal = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"Low")] + Low = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"High")] + High = 2, + + } + + /// + /// Represents the model for updating the priority of a Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class UpdateTodoItemPriorityModel + { + + /// + /// Gets or sets the new priority of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("priority", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public TodoPriority Priority { get; set; } + + } + + + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ApiException : System.Exception + { + public int StatusCode { get; private set; } + + public string Response { get; private set; } + + public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } + + public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) + { + StatusCode = statusCode; + Response = response; + Headers = headers; + } + + public override string ToString() + { + return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); + } + } + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ApiException : ApiException + { + public TResult Result { get; private set; } + + public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) + : base(message, statusCode, response, headers, innerException) + { + Result = result; + } + } + +} + +#pragma warning restore 108 +#pragma warning restore 114 +#pragma warning restore 472 +#pragma warning restore 612 +#pragma warning restore 649 +#pragma warning restore 1573 +#pragma warning restore 1591 +#pragma warning restore 8073 +#pragma warning restore 3016 +#pragma warning restore 8600 +#pragma warning restore 8602 +#pragma warning restore 8603 +#pragma warning restore 8604 +#pragma warning restore 8625 +#pragma warning restore 8765 \ No newline at end of file diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/generate-todo-client.ps1 b/test/Swashbuckle.AspNetCore.IntegrationTests/generate-todo-client.ps1 deleted file mode 100644 index 2e5ff31862..0000000000 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/generate-todo-client.ps1 +++ /dev/null @@ -1,28 +0,0 @@ -#! /usr/bin/env pwsh - -param( - [Parameter(Mandatory = $false)][string] $OpenApiUrl = "./snapshots/VerifyTests.Swagger_IsValidJson_No_Startup_entryPointType=TodoApp.Program_swaggerRequestUri=v1.DotNet10_0.verified.txt", - [Parameter(Mandatory = $false)][switch] $Regenerate -) - -$ErrorActionPreference = "Stop" -$ProgressPreference = "SilentlyContinue" - -$env:KIOTA_TUTORIAL_ENABLED = "false" - -$OutputPath = "./TodoClient" - -dotnet kiota generate ` - --additional-data false ` - --class-name TodoApiClient ` - --clean-output ` - --exclude-backward-compatible ` - --language csharp ` - --namespace-name TodoApp.Client ` - --openapi $OpenApiUrl ` - --output $OutputPath ` - --structured-mime-types "application/json" - -if ($LASTEXITCODE -ne 0) { - throw "Kiota generation failed with exit code ${LASTEXITCODE}" -} diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/generate-todo-clients.ps1 b/test/Swashbuckle.AspNetCore.IntegrationTests/generate-todo-clients.ps1 new file mode 100644 index 0000000000..bee39b60a2 --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/generate-todo-clients.ps1 @@ -0,0 +1,36 @@ +#! /usr/bin/env pwsh + +param( + [Parameter(Mandatory = $false)][string] $OpenApiDocument = "./snapshots/VerifyTests.Swagger_IsValidJson_No_Startup_entryPointType=TodoApp.Program_swaggerRequestUri=v1.DotNet10_0.verified.txt", + [Parameter(Mandatory = $false)][switch] $Regenerate +) + +$ErrorActionPreference = "Stop" +$ProgressPreference = "SilentlyContinue" + +$env:KIOTA_TUTORIAL_ENABLED = "false" + +dotnet kiota generate ` + --additional-data false ` + --class-name KiotaTodoApiClient ` + --clean-output ` + --exclude-backward-compatible ` + --language csharp ` + --namespace-name TodoApp.KiotaClient ` + --openapi $OpenApiDocument ` + --output "./KiotaTodoClient" ` + --structured-mime-types "application/json" + +if ($LASTEXITCODE -ne 0) { + throw "Kiota client generation failed with exit code ${LASTEXITCODE}" +} + +dotnet nswag openapi2csclient ` + "/input:${OpenApiDocument}" ` + /classname:NSwagTodoApiClient ` + /namespace:TodoApp.NSwagClient ` + /output:./NSwagTodoClient/NSwagTodoClient.cs + +if ($LASTEXITCODE -ne 0) { + throw "NSwag client generation failed with exit code ${LASTEXITCODE}" +} diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/ApiRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/ApiRequestBuilder.verified.cs index 3089b919fb..23c2da6714 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/ApiRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/ApiRequestBuilder.verified.cs @@ -6,8 +6,8 @@ using System.IO; using System.Threading.Tasks; using System; -using TodoApp.Client.Api.Items; -namespace TodoApp.Client.Api +using TodoApp.KiotaClient.Api.Items; +namespace TodoApp.KiotaClient.Api { /// /// Builds and executes requests for operations under \api @@ -16,12 +16,12 @@ namespace TodoApp.Client.Api public partial class ApiRequestBuilder : BaseRequestBuilder { /// The items property - public global::TodoApp.Client.Api.Items.ItemsRequestBuilder Items + public global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder Items { - get => new global::TodoApp.Client.Api.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder(PathParameters, RequestAdapter); } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -29,7 +29,7 @@ public ApiRequestBuilder(Dictionary pathParameters, IRequestAdap { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Find/FindRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Find/FindRequestBuilder.verified.cs index 1e6da55fa3..4d77429bf3 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Find/FindRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Find/FindRequestBuilder.verified.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Find +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Find { /// /// Builds and executes requests for operations under \api\items\find @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.Find public partial class FindRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,37 +26,37 @@ public FindRequestBuilder(Dictionary pathParameters, IRequestAda { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. public FindRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/items/find?IsCompleted={IsCompleted}&Text={Text}", rawUrl) { } - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); } /// A /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -67,11 +67,11 @@ public RequestInformation ToGetRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Find.FindRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Find.FindRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder(rawUrl, RequestAdapter); } [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] #pragma warning disable CS1591 diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/GetAfter/GetAfterRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/GetAfter/GetAfterRequestBuilder.verified.cs index d420636015..cf1dfea93c 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/GetAfter/GetAfterRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/GetAfter/GetAfterRequestBuilder.verified.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.GetAfter +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.GetAfter { /// /// Builds and executes requests for operations under \api\items\getAfter @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.GetAfter public partial class GetAfterRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,37 +26,37 @@ public GetAfterRequestBuilder(Dictionary pathParameters, IReques { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. public GetAfterRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/items/getAfter?value={value}", rawUrl) { } - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); } /// A /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { #endif var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); @@ -67,11 +67,11 @@ public RequestInformation ToGetRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder(rawUrl, RequestAdapter); } [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] #pragma warning disable CS1591 diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Complete/CompleteRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Complete/CompleteRequestBuilder.verified.cs index 09e8901d32..05d127eb59 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Complete/CompleteRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Complete/CompleteRequestBuilder.verified.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Item.Complete +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Item.Complete { /// /// Builds and executes requests for operations under \api\items\{id}\complete @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.Item.Complete public partial class CompleteRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,7 +26,7 @@ public CompleteRequestBuilder(Dictionary pathParameters, IReques { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -38,8 +38,8 @@ public CompleteRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : b /// /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 400 status code - /// When receiving a 404 status code + /// When receiving a 400 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable public async Task PostAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) @@ -52,8 +52,8 @@ public async Task PostAsync(Action> var requestInfo = ToPostRequestInformation(requestConfiguration); var errorMapping = new Dictionary> { - { "400", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "400", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); } @@ -79,11 +79,11 @@ public RequestInformation ToPostRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/ItemsItemRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/ItemsItemRequestBuilder.verified.cs index e3acec88bd..aef5dbdf24 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/ItemsItemRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/ItemsItemRequestBuilder.verified.cs @@ -8,10 +8,10 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Api.Items.Item.Complete; -using TodoApp.Client.Api.Items.Item.Priority; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Item +using TodoApp.KiotaClient.Api.Items.Item.Complete; +using TodoApp.KiotaClient.Api.Items.Item.Priority; +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Item { /// /// Builds and executes requests for operations under \api\items\{id} @@ -20,17 +20,17 @@ namespace TodoApp.Client.Api.Items.Item public partial class ItemsItemRequestBuilder : BaseRequestBuilder { /// The complete property - public global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder Complete + public global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder Complete { - get => new global::TodoApp.Client.Api.Items.Item.Complete.CompleteRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.Item.Complete.CompleteRequestBuilder(PathParameters, RequestAdapter); } /// The priority property - public global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder Priority + public global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder Priority { - get => new global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder(PathParameters, RequestAdapter); } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -38,7 +38,7 @@ public ItemsItemRequestBuilder(Dictionary pathParameters, IReque { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -50,7 +50,7 @@ public ItemsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : /// /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 404 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) @@ -63,32 +63,32 @@ public async Task DeleteAsync(Action> { - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); } /// /// Gets the todo item with the specified ID. /// - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 404 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); var errorMapping = new Dictionary> { - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); } /// /// Deletes the todo item with the specified ID. @@ -131,11 +131,11 @@ public RequestInformation ToGetRequestInformation(Action /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Priority/PriorityRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Priority/PriorityRequestBuilder.verified.cs index 6df4f2ccf7..53e25d63fc 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Priority/PriorityRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/Item/Priority/PriorityRequestBuilder.verified.cs @@ -8,8 +8,8 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items.Item.Priority +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items.Item.Priority { /// /// Builds and executes requests for operations under \api\items\{id}\priority @@ -18,7 +18,7 @@ namespace TodoApp.Client.Api.Items.Item.Priority public partial class PriorityRequestBuilder : BaseRequestBuilder { /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -26,7 +26,7 @@ public PriorityRequestBuilder(Dictionary pathParameters, IReques { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -39,23 +39,23 @@ public PriorityRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : b /// Represents the model for updating the priority of a Todo item. /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 400 status code - /// When receiving a 404 status code + /// When receiving a 400 status code + /// When receiving a 404 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task PatchAsync(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PatchAsync(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task PatchAsync(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PatchAsync(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); var requestInfo = ToPatchRequestInformation(body, requestConfiguration); var errorMapping = new Dictionary> { - { "400", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, - { "404", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "400", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "404", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); } @@ -67,11 +67,11 @@ public async Task PatchAsync(global::TodoApp.Client.Models.UpdateTodoItemPriorit /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToPatchRequestInformation(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default) + public RequestInformation ToPatchRequestInformation(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToPatchRequestInformation(global::TodoApp.Client.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default) + public RequestInformation ToPatchRequestInformation(global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel body, Action> requestConfiguration = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); @@ -84,11 +84,11 @@ public RequestInformation ToPatchRequestInformation(global::TodoApp.Client.Model /// /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.Item.Priority.PriorityRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.Priority.PriorityRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/ItemsRequestBuilder.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/ItemsRequestBuilder.verified.cs index af6df99c5b..4725388527 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/ItemsRequestBuilder.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Api/Items/ItemsRequestBuilder.verified.cs @@ -8,11 +8,11 @@ using System.Threading.Tasks; using System.Threading; using System; -using TodoApp.Client.Api.Items.Find; -using TodoApp.Client.Api.Items.GetAfter; -using TodoApp.Client.Api.Items.Item; -using TodoApp.Client.Models; -namespace TodoApp.Client.Api.Items +using TodoApp.KiotaClient.Api.Items.Find; +using TodoApp.KiotaClient.Api.Items.GetAfter; +using TodoApp.KiotaClient.Api.Items.Item; +using TodoApp.KiotaClient.Models; +namespace TodoApp.KiotaClient.Api.Items { /// /// Builds and executes requests for operations under \api\items @@ -21,29 +21,29 @@ namespace TodoApp.Client.Api.Items public partial class ItemsRequestBuilder : BaseRequestBuilder { /// The find property - public global::TodoApp.Client.Api.Items.Find.FindRequestBuilder Find + public global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder Find { - get => new global::TodoApp.Client.Api.Items.Find.FindRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.Find.FindRequestBuilder(PathParameters, RequestAdapter); } /// The getAfter property - public global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder GetAfter + public global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder GetAfter { - get => new global::TodoApp.Client.Api.Items.GetAfter.GetAfterRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.Items.GetAfter.GetAfterRequestBuilder(PathParameters, RequestAdapter); } - /// Gets an item from the TodoApp.Client.api.items.item collection + /// Gets an item from the TodoApp.KiotaClient.api.items.item collection /// The Todo item's ID. - /// A - public global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder this[Guid position] + /// A + public global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder this[Guid position] { get { var urlTplParams = new Dictionary(PathParameters); urlTplParams.Add("id", position); - return new global::TodoApp.Client.Api.Items.Item.ItemsItemRequestBuilder(urlTplParams, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.Item.ItemsItemRequestBuilder(urlTplParams, RequestAdapter); } } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// Path parameters for the request /// The request adapter to use to execute the requests. @@ -51,7 +51,7 @@ public ItemsRequestBuilder(Dictionary pathParameters, IRequestAd { } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The raw URL to use for the request builder. /// The request adapter to use to execute the requests. @@ -61,45 +61,45 @@ public ItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base /// /// Gets all of the current user's todo items. /// - /// A + /// A /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif var requestInfo = ToGetRequestInformation(requestConfiguration); - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.TodoListViewModel.CreateFromDiscriminatorValue, default, cancellationToken).ConfigureAwait(false); } /// /// Creates a new todo item for the current user and returns its ID. /// - /// A + /// A /// Represents the model for creating a new Todo item. /// Cancellation token to use when cancelling requests /// Configuration for the request such as headers, query parameters, and middleware options. - /// When receiving a 400 status code + /// When receiving a 400 status code #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public async Task PostAsync(global::TodoApp.Client.Models.CreateTodoItemModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PostAsync(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { #nullable restore #else - public async Task PostAsync(global::TodoApp.Client.Models.CreateTodoItemModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) + public async Task PostAsync(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); var requestInfo = ToPostRequestInformation(body, requestConfiguration); var errorMapping = new Dictionary> { - { "400", global::TodoApp.Client.Models.ProblemDetails.CreateFromDiscriminatorValue }, + { "400", global::TodoApp.KiotaClient.Models.ProblemDetails.CreateFromDiscriminatorValue }, }; - return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.Client.Models.CreatedTodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + return await RequestAdapter.SendAsync(requestInfo, global::TodoApp.KiotaClient.Models.CreatedTodoItemModel.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); } /// /// Gets all of the current user's todo items. @@ -128,11 +128,11 @@ public RequestInformation ToGetRequestInformation(ActionConfiguration for the request such as headers, query parameters, and middleware options. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public RequestInformation ToPostRequestInformation(global::TodoApp.Client.Models.CreateTodoItemModel body, Action>? requestConfiguration = default) + public RequestInformation ToPostRequestInformation(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action>? requestConfiguration = default) { #nullable restore #else - public RequestInformation ToPostRequestInformation(global::TodoApp.Client.Models.CreateTodoItemModel body, Action> requestConfiguration = default) + public RequestInformation ToPostRequestInformation(global::TodoApp.KiotaClient.Models.CreateTodoItemModel body, Action> requestConfiguration = default) { #endif if(ReferenceEquals(body, null)) throw new ArgumentNullException(nameof(body)); @@ -145,11 +145,11 @@ public RequestInformation ToPostRequestInformation(global::TodoApp.Client.Models /// /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. /// - /// A + /// A /// The raw URL to use for the request builder. - public global::TodoApp.Client.Api.Items.ItemsRequestBuilder WithUrl(string rawUrl) + public global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder WithUrl(string rawUrl) { - return new global::TodoApp.Client.Api.Items.ItemsRequestBuilder(rawUrl, RequestAdapter); + return new global::TodoApp.KiotaClient.Api.Items.ItemsRequestBuilder(rawUrl, RequestAdapter); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/TodoApiClient.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/KiotaTodoApiClient.verified.cs similarity index 72% rename from test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/TodoApiClient.verified.cs rename to test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/KiotaTodoApiClient.verified.cs index a78b7241a4..0ce9940d36 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/TodoApiClient.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/KiotaTodoApiClient.verified.cs @@ -10,25 +10,25 @@ using System.IO; using System.Threading.Tasks; using System; -using TodoApp.Client.Api; -namespace TodoApp.Client +using TodoApp.KiotaClient.Api; +namespace TodoApp.KiotaClient { /// /// The main entry point of the SDK, exposes the configuration and the fluent API. /// [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] - public partial class TodoApiClient : BaseRequestBuilder + public partial class KiotaTodoApiClient : BaseRequestBuilder { /// The api property - public global::TodoApp.Client.Api.ApiRequestBuilder Api + public global::TodoApp.KiotaClient.Api.ApiRequestBuilder Api { - get => new global::TodoApp.Client.Api.ApiRequestBuilder(PathParameters, RequestAdapter); + get => new global::TodoApp.KiotaClient.Api.ApiRequestBuilder(PathParameters, RequestAdapter); } /// - /// Instantiates a new and sets the default values. + /// Instantiates a new and sets the default values. /// /// The request adapter to use to execute the requests. - public TodoApiClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary()) + public KiotaTodoApiClient(IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}", new Dictionary()) { ApiClientBuilder.RegisterDefaultSerializer(); ApiClientBuilder.RegisterDefaultSerializer(); diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreateTodoItemModel.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreateTodoItemModel.verified.cs index facd4f1345..57d52174c1 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreateTodoItemModel.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreateTodoItemModel.verified.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents the model for creating a new Todo item. @@ -24,12 +24,12 @@ public partial class CreateTodoItemModel : IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.CreateTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.CreateTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.CreateTodoItemModel(); + return new global::TodoApp.KiotaClient.Models.CreateTodoItemModel(); } /// /// The deserialization information for the current model diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreatedTodoItemModel.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreatedTodoItemModel.verified.cs index ab6ca282e9..67627f1ee8 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreatedTodoItemModel.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/CreatedTodoItemModel.verified.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents the model for a created Todo item. @@ -24,12 +24,12 @@ public partial class CreatedTodoItemModel : IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.CreatedTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.CreatedTodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.CreatedTodoItemModel(); + return new global::TodoApp.KiotaClient.Models.CreatedTodoItemModel(); } /// /// The deserialization information for the current model diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/ProblemDetails.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/ProblemDetails.verified.cs index 1773cc90ee..c86adef1dd 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/ProblemDetails.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/ProblemDetails.verified.cs @@ -6,7 +6,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] #pragma warning disable CS1591 @@ -52,12 +52,12 @@ public partial class ProblemDetails : ApiException, IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.ProblemDetails CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.ProblemDetails CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.ProblemDetails(); + return new global::TodoApp.KiotaClient.Models.ProblemDetails(); } /// /// The deserialization information for the current model diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoItemModel.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoItemModel.verified.cs index f9e6233aca..7e8fac8e44 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoItemModel.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoItemModel.verified.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents a Todo item. @@ -28,7 +28,7 @@ public partial class TodoItemModel : IParsable /// Gets or sets the date and time the Todo item was last updated. public DateTimeOffset? LastUpdated { get; set; } /// Gets or sets the optional priority of the Todo item. - public global::TodoApp.Client.Models.TodoPriority? Priority { get; set; } + public global::TodoApp.KiotaClient.Models.TodoPriority? Priority { get; set; } /// Gets or sets the text of the Todo item. #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable @@ -40,12 +40,12 @@ public partial class TodoItemModel : IParsable /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.TodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.TodoItemModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.TodoItemModel(); + return new global::TodoApp.KiotaClient.Models.TodoItemModel(); } /// /// The deserialization information for the current model @@ -59,7 +59,7 @@ public virtual IDictionary> GetFieldDeserializers() { "createdAt", n => { CreatedAt = n.GetDateTimeOffsetValue(); } }, { "id", n => { Id = n.GetStringValue(); } }, { "lastUpdated", n => { LastUpdated = n.GetDateTimeOffsetValue(); } }, - { "priority", n => { Priority = n.GetEnumValue(); } }, + { "priority", n => { Priority = n.GetEnumValue(); } }, { "text", n => { Text = n.GetStringValue(); } }, }; } @@ -74,7 +74,7 @@ public virtual void Serialize(ISerializationWriter writer) writer.WriteDateTimeOffsetValue("createdAt", CreatedAt); writer.WriteStringValue("id", Id); writer.WriteDateTimeOffsetValue("lastUpdated", LastUpdated); - writer.WriteEnumValue("priority", Priority); + writer.WriteEnumValue("priority", Priority); writer.WriteStringValue("text", Text); } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoListViewModel.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoListViewModel.verified.cs index eb520f51c2..8ee66a572f 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoListViewModel.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoListViewModel.verified.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents a collection of Todo items. @@ -16,20 +16,20 @@ public partial class TodoListViewModel : IParsable /// Gets or sets the Todo item(s). #if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER #nullable enable - public List? Items { get; set; } + public List? Items { get; set; } #nullable restore #else - public List Items { get; set; } + public List Items { get; set; } #endif /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.TodoListViewModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.TodoListViewModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.TodoListViewModel(); + return new global::TodoApp.KiotaClient.Models.TodoListViewModel(); } /// /// The deserialization information for the current model @@ -39,7 +39,7 @@ public virtual IDictionary> GetFieldDeserializers() { return new Dictionary> { - { "items", n => { Items = n.GetCollectionOfObjectValues(global::TodoApp.Client.Models.TodoItemModel.CreateFromDiscriminatorValue)?.AsList(); } }, + { "items", n => { Items = n.GetCollectionOfObjectValues(global::TodoApp.KiotaClient.Models.TodoItemModel.CreateFromDiscriminatorValue)?.AsList(); } }, }; } /// @@ -49,7 +49,7 @@ public virtual IDictionary> GetFieldDeserializers() public virtual void Serialize(ISerializationWriter writer) { if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); - writer.WriteCollectionOfObjectValues("items", Items); + writer.WriteCollectionOfObjectValues("items", Items); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoPriority.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoPriority.verified.cs index 3ff868a37c..628c1b0af4 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoPriority.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/TodoPriority.verified.cs @@ -1,7 +1,7 @@ // using System.Runtime.Serialization; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// The priority levels for a Todo item. [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/UpdateTodoItemPriorityModel.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/UpdateTodoItemPriorityModel.verified.cs index 7febaace2e..11ba1d679d 100644 --- a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/UpdateTodoItemPriorityModel.verified.cs +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyKiotaTodoAppClient/Models/UpdateTodoItemPriorityModel.verified.cs @@ -5,7 +5,7 @@ using System.Collections.Generic; using System.IO; using System; -namespace TodoApp.Client.Models +namespace TodoApp.KiotaClient.Models { /// /// Represents the model for updating the priority of a Todo item. @@ -14,16 +14,16 @@ namespace TodoApp.Client.Models public partial class UpdateTodoItemPriorityModel : IParsable { /// Gets or sets the new priority of the Todo item. - public global::TodoApp.Client.Models.TodoPriority? Priority { get; set; } + public global::TodoApp.KiotaClient.Models.TodoPriority? Priority { get; set; } /// /// Creates a new instance of the appropriate class based on discriminator value /// - /// A + /// A /// The parse node to use to read the discriminator value and create the object - public static global::TodoApp.Client.Models.UpdateTodoItemPriorityModel CreateFromDiscriminatorValue(IParseNode parseNode) + public static global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel CreateFromDiscriminatorValue(IParseNode parseNode) { if(ReferenceEquals(parseNode, null)) throw new ArgumentNullException(nameof(parseNode)); - return new global::TodoApp.Client.Models.UpdateTodoItemPriorityModel(); + return new global::TodoApp.KiotaClient.Models.UpdateTodoItemPriorityModel(); } /// /// The deserialization information for the current model @@ -33,7 +33,7 @@ public virtual IDictionary> GetFieldDeserializers() { return new Dictionary> { - { "priority", n => { Priority = n.GetEnumValue(); } }, + { "priority", n => { Priority = n.GetEnumValue(); } }, }; } /// @@ -43,7 +43,7 @@ public virtual IDictionary> GetFieldDeserializers() public virtual void Serialize(ISerializationWriter writer) { if(ReferenceEquals(writer, null)) throw new ArgumentNullException(nameof(writer)); - writer.WriteEnumValue("priority", Priority); + writer.WriteEnumValue("priority", Priority); } } } diff --git a/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyNSwagTodoAppClient/NSwagTodoClient.verified.cs b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyNSwagTodoAppClient/NSwagTodoClient.verified.cs new file mode 100644 index 0000000000..15a1134ecd --- /dev/null +++ b/test/Swashbuckle.AspNetCore.IntegrationTests/snapshots/CodeGenerationTests.VerifyNSwagTodoAppClient/NSwagTodoClient.verified.cs @@ -0,0 +1,1224 @@ +//---------------------- +// +// Generated using the NSwag toolchain v14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0)) (http://NSwag.org) +// +//---------------------- + +#pragma warning disable 108 // Disable "CS0108 '{derivedDto}.ToJson()' hides inherited member '{dtoBase}.ToJson()'. Use the new keyword if hiding was intended." +#pragma warning disable 114 // Disable "CS0114 '{derivedDto}.RaisePropertyChanged(String)' hides inherited member 'dtoBase.RaisePropertyChanged(String)'. To make the current member override that implementation, add the override keyword. Otherwise add the new keyword." +#pragma warning disable 472 // Disable "CS0472 The result of the expression is always 'false' since a value of type 'Int32' is never equal to 'null' of type 'Int32?' +#pragma warning disable 612 // Disable "CS0612 '...' is obsolete" +#pragma warning disable 649 // Disable "CS0649 Field is never assigned to, and will always have its default value null" +#pragma warning disable 1573 // Disable "CS1573 Parameter '...' has no matching param tag in the XML comment for ... +#pragma warning disable 1591 // Disable "CS1591 Missing XML comment for publicly visible type or member ..." +#pragma warning disable 8073 // Disable "CS8073 The result of the expression is always 'false' since a value of type 'T' is never equal to 'null' of type 'T?'" +#pragma warning disable 3016 // Disable "CS3016 Arrays as attribute arguments is not CLS-compliant" +#pragma warning disable 8600 // Disable "CS8600 Converting null literal or possible null value to non-nullable type" +#pragma warning disable 8602 // Disable "CS8602 Dereference of a possibly null reference" +#pragma warning disable 8603 // Disable "CS8603 Possible null reference return" +#pragma warning disable 8604 // Disable "CS8604 Possible null reference argument for parameter" +#pragma warning disable 8625 // Disable "CS8625 Cannot convert null literal to non-nullable reference type" +#pragma warning disable 8765 // Disable "CS8765 Nullability of type of parameter doesn't match overridden member (possibly because of nullability attributes)." + +namespace TodoApp.NSwagClient +{ + using System = global::System; + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class NSwagTodoApiClient + { + #pragma warning disable 8618 + private string _baseUrl; + #pragma warning restore 8618 + + private System.Net.Http.HttpClient _httpClient; + private static System.Lazy _settings = new System.Lazy(CreateSerializerSettings, true); + private Newtonsoft.Json.JsonSerializerSettings _instanceSettings; + + #pragma warning disable CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + public NSwagTodoApiClient(string baseUrl, System.Net.Http.HttpClient httpClient) + #pragma warning restore CS8618 // Non-nullable field must contain a non-null value when exiting constructor. Consider declaring as nullable. + { + BaseUrl = baseUrl; + _httpClient = httpClient; + Initialize(); + } + + private static Newtonsoft.Json.JsonSerializerSettings CreateSerializerSettings() + { + var settings = new Newtonsoft.Json.JsonSerializerSettings(); + UpdateJsonSerializerSettings(settings); + return settings; + } + + public string BaseUrl + { + get { return _baseUrl; } + set + { + _baseUrl = value; + if (!string.IsNullOrEmpty(_baseUrl) && !_baseUrl.EndsWith("/")) + _baseUrl += '/'; + } + } + + protected Newtonsoft.Json.JsonSerializerSettings JsonSerializerSettings { get { return _instanceSettings ?? _settings.Value; } } + + static partial void UpdateJsonSerializerSettings(Newtonsoft.Json.JsonSerializerSettings settings); + + partial void Initialize(); + + partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, string url); + partial void PrepareRequest(System.Net.Http.HttpClient client, System.Net.Http.HttpRequestMessage request, System.Text.StringBuilder urlBuilder); + partial void ProcessResponse(System.Net.Http.HttpClient client, System.Net.Http.HttpResponseMessage response); + + /// + /// Get all Todo items + /// + /// + /// Gets all of the current user's todo items. + /// + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task ListTodosAsync() + { + return ListTodosAsync(System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get all Todo items + /// + /// + /// Gets all of the current user's todo items. + /// + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task ListTodosAsync(System.Threading.CancellationToken cancellationToken) + { + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items" + urlBuilder_.Append("api/items"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Create a new Todo item + /// + /// + /// Creates a new todo item for the current user and returns its ID. + /// + /// Created + /// A server side error occurred. + public virtual System.Threading.Tasks.Task CreateTodoAsync(CreateTodoItemModel body) + { + return CreateTodoAsync(body, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Create a new Todo item + /// + /// + /// Creates a new todo item for the current user and returns its ID. + /// + /// Created + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task CreateTodoAsync(CreateTodoItemModel body, System.Threading.CancellationToken cancellationToken) + { + if (body == null) + throw new System.ArgumentNullException("body"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); + var content_ = new System.Net.Http.StringContent(json_); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; + request_.Method = new System.Net.Http.HttpMethod("POST"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items" + urlBuilder_.Append("api/items"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 201) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + if (status_ == 400) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Get a specific Todo item + /// + /// + /// Gets the todo item with the specified ID. + /// + /// The Todo item's ID. + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetTodoAsync(System.Guid id) + { + return GetTodoAsync(id, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Get a specific Todo item + /// + /// + /// Gets the todo item with the specified ID. + /// + /// The Todo item's ID. + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetTodoAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Delete a Todo item + /// + /// + /// Deletes the todo item with the specified ID. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual System.Threading.Tasks.Task DeleteTodoAsync(System.Guid id) + { + return DeleteTodoAsync(id, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Delete a Todo item + /// + /// + /// Deletes the todo item with the specified ID. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task DeleteTodoAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("DELETE"); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 204) + { + return; + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Mark a Todo item as completed + /// + /// + /// Marks the todo item with the specified ID as complete. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual System.Threading.Tasks.Task CompleteTodoAsync(System.Guid id) + { + return CompleteTodoAsync(id, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Mark a Todo item as completed + /// + /// + /// Marks the todo item with the specified ID as complete. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task CompleteTodoAsync(System.Guid id, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Content = new System.Net.Http.StringContent(string.Empty, System.Text.Encoding.UTF8, "application/json"); + request_.Method = new System.Net.Http.HttpMethod("POST"); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}/complete" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("/complete"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 204) + { + return; + } + else + if (status_ == 400) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// + /// Updates the priority of a Todo item + /// + /// + /// Updates the priority of the todo item with the specified ID to the specified priority. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual System.Threading.Tasks.Task UpdateTodoPriorityAsync(System.Guid id, UpdateTodoItemPriorityModel body) + { + return UpdateTodoPriorityAsync(id, body, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// + /// Updates the priority of a Todo item + /// + /// + /// Updates the priority of the todo item with the specified ID to the specified priority. + /// + /// The Todo item's ID. + /// No Content + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task UpdateTodoPriorityAsync(System.Guid id, UpdateTodoItemPriorityModel body, System.Threading.CancellationToken cancellationToken) + { + if (id == null) + throw new System.ArgumentNullException("id"); + + if (body == null) + throw new System.ArgumentNullException("body"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + var json_ = Newtonsoft.Json.JsonConvert.SerializeObject(body, JsonSerializerSettings); + var content_ = new System.Net.Http.StringContent(json_); + content_.Headers.ContentType = System.Net.Http.Headers.MediaTypeHeaderValue.Parse("application/json"); + request_.Content = content_; + request_.Method = new System.Net.Http.HttpMethod("PATCH"); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/{id}/priority" + urlBuilder_.Append("api/items/"); + urlBuilder_.Append(System.Uri.EscapeDataString(ConvertToString(id, System.Globalization.CultureInfo.InvariantCulture))); + urlBuilder_.Append("/priority"); + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 204) + { + return; + } + else + if (status_ == 400) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Bad Request", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + if (status_ == 404) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + throw new ApiException("Not Found", status_, objectResponse_.Text, headers_, objectResponse_.Object, null); + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// Gets or sets the text of the filter. + /// Gets or sets a value indicating whether to search completed Todo items. + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task FindTodoAsync(string text, bool isCompleted) + { + return FindTodoAsync(text, isCompleted, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// Gets or sets the text of the filter. + /// Gets or sets a value indicating whether to search completed Todo items. + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task FindTodoAsync(string text, bool isCompleted, System.Threading.CancellationToken cancellationToken) + { + if (text == null) + throw new System.ArgumentNullException("text"); + + if (isCompleted == null) + throw new System.ArgumentNullException("isCompleted"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/find" + urlBuilder_.Append("api/items/find"); + urlBuilder_.Append('?'); + urlBuilder_.Append(System.Uri.EscapeDataString("Text")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(text, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Append(System.Uri.EscapeDataString("IsCompleted")).Append('=').Append(System.Uri.EscapeDataString(ConvertToString(isCompleted, System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Length--; + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + /// OK + /// A server side error occurred. + public virtual System.Threading.Tasks.Task GetAfterDateAsync(System.DateTimeOffset value) + { + return GetAfterDateAsync(value, System.Threading.CancellationToken.None); + } + + /// A cancellation token that can be used by other objects or threads to receive notice of cancellation. + /// OK + /// A server side error occurred. + public virtual async System.Threading.Tasks.Task GetAfterDateAsync(System.DateTimeOffset value, System.Threading.CancellationToken cancellationToken) + { + if (value == null) + throw new System.ArgumentNullException("value"); + + var client_ = _httpClient; + var disposeClient_ = false; + try + { + using (var request_ = new System.Net.Http.HttpRequestMessage()) + { + request_.Method = new System.Net.Http.HttpMethod("GET"); + request_.Headers.Accept.Add(System.Net.Http.Headers.MediaTypeWithQualityHeaderValue.Parse("application/json")); + + var urlBuilder_ = new System.Text.StringBuilder(); + if (!string.IsNullOrEmpty(_baseUrl)) urlBuilder_.Append(_baseUrl); + // Operation Path: "api/items/getAfter" + urlBuilder_.Append("api/items/getAfter"); + urlBuilder_.Append('?'); + urlBuilder_.Append(System.Uri.EscapeDataString("value")).Append('=').Append(System.Uri.EscapeDataString(value.ToString("s", System.Globalization.CultureInfo.InvariantCulture))).Append('&'); + urlBuilder_.Length--; + + PrepareRequest(client_, request_, urlBuilder_); + + var url_ = urlBuilder_.ToString(); + request_.RequestUri = new System.Uri(url_, System.UriKind.RelativeOrAbsolute); + + PrepareRequest(client_, request_, url_); + + var response_ = await client_.SendAsync(request_, System.Net.Http.HttpCompletionOption.ResponseHeadersRead, cancellationToken).ConfigureAwait(false); + var disposeResponse_ = true; + try + { + var headers_ = new System.Collections.Generic.Dictionary>(); + foreach (var item_ in response_.Headers) + headers_[item_.Key] = item_.Value; + if (response_.Content != null && response_.Content.Headers != null) + { + foreach (var item_ in response_.Content.Headers) + headers_[item_.Key] = item_.Value; + } + + ProcessResponse(client_, response_); + + var status_ = (int)response_.StatusCode; + if (status_ == 200) + { + var objectResponse_ = await ReadObjectResponseAsync(response_, headers_, cancellationToken).ConfigureAwait(false); + if (objectResponse_.Object == null) + { + throw new ApiException("Response was null which was not expected.", status_, objectResponse_.Text, headers_, null); + } + return objectResponse_.Object; + } + else + { + var responseData_ = response_.Content == null ? null : await ReadAsStringAsync(response_.Content, cancellationToken).ConfigureAwait(false); + throw new ApiException("The HTTP status code of the response was not expected (" + status_ + ").", status_, responseData_, headers_, null); + } + } + finally + { + if (disposeResponse_) + response_.Dispose(); + } + } + } + finally + { + if (disposeClient_) + client_.Dispose(); + } + } + + protected struct ObjectResponseResult + { + public ObjectResponseResult(T responseObject, string responseText) + { + this.Object = responseObject; + this.Text = responseText; + } + + public T Object { get; } + + public string Text { get; } + } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + private static System.Threading.Tasks.Task ReadAsStringAsync(System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken) + { + #if NET5_0_OR_GREATER + return content.ReadAsStringAsync(cancellationToken); + #else + return content.ReadAsStringAsync(); + #endif + } + + [System.Runtime.CompilerServices.MethodImpl(System.Runtime.CompilerServices.MethodImplOptions.AggressiveInlining)] + private static System.Threading.Tasks.Task ReadAsStreamAsync(System.Net.Http.HttpContent content, System.Threading.CancellationToken cancellationToken) + { + #if NET5_0_OR_GREATER + return content.ReadAsStreamAsync(cancellationToken); + #else + return content.ReadAsStreamAsync(); + #endif + } + + public bool ReadResponseAsString { get; set; } + + protected virtual async System.Threading.Tasks.Task> ReadObjectResponseAsync(System.Net.Http.HttpResponseMessage response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Threading.CancellationToken cancellationToken) + { + if (response == null || response.Content == null) + { + return new ObjectResponseResult(default(T), string.Empty); + } + + if (ReadResponseAsString) + { + var responseText = await ReadAsStringAsync(response.Content, cancellationToken).ConfigureAwait(false); + try + { + var typedBody = Newtonsoft.Json.JsonConvert.DeserializeObject(responseText, JsonSerializerSettings); + return new ObjectResponseResult(typedBody, responseText); + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body string as " + typeof(T).FullName + "."; + throw new ApiException(message, (int)response.StatusCode, responseText, headers, exception); + } + } + else + { + try + { + using (var responseStream = await ReadAsStreamAsync(response.Content, cancellationToken).ConfigureAwait(false)) + using (var streamReader = new System.IO.StreamReader(responseStream)) + using (var jsonTextReader = new Newtonsoft.Json.JsonTextReader(streamReader)) + { + var serializer = Newtonsoft.Json.JsonSerializer.Create(JsonSerializerSettings); + var typedBody = serializer.Deserialize(jsonTextReader); + return new ObjectResponseResult(typedBody, string.Empty); + } + } + catch (Newtonsoft.Json.JsonException exception) + { + var message = "Could not deserialize the response body stream as " + typeof(T).FullName + "."; + throw new ApiException(message, (int)response.StatusCode, string.Empty, headers, exception); + } + } + } + + private string ConvertToString(object value, System.Globalization.CultureInfo cultureInfo) + { + if (value == null) + { + return ""; + } + + if (value is System.Enum) + { + var name = System.Enum.GetName(value.GetType(), value); + if (name != null) + { + var field_ = System.Reflection.IntrospectionExtensions.GetTypeInfo(value.GetType()).GetDeclaredField(name); + if (field_ != null) + { + var attribute = System.Reflection.CustomAttributeExtensions.GetCustomAttribute(field_, typeof(System.Runtime.Serialization.EnumMemberAttribute)) + as System.Runtime.Serialization.EnumMemberAttribute; + if (attribute != null) + { + return attribute.Value != null ? attribute.Value : name; + } + } + + var converted = System.Convert.ToString(System.Convert.ChangeType(value, System.Enum.GetUnderlyingType(value.GetType()), cultureInfo)); + return converted == null ? string.Empty : converted; + } + } + else if (value is bool) + { + return System.Convert.ToString((bool)value, cultureInfo).ToLowerInvariant(); + } + else if (value is byte[]) + { + return System.Convert.ToBase64String((byte[]) value); + } + else if (value is string[]) + { + return string.Join(",", (string[])value); + } + else if (value.GetType().IsArray) + { + var valueArray = (System.Array)value; + var valueTextArray = new string[valueArray.Length]; + for (var i = 0; i < valueArray.Length; i++) + { + valueTextArray[i] = ConvertToString(valueArray.GetValue(i), cultureInfo); + } + return string.Join(",", valueTextArray); + } + + var result = System.Convert.ToString(value, cultureInfo); + return result == null ? "" : result; + } + } + + /// + /// Represents the model for creating a new Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class CreateTodoItemModel + { + + /// + /// Gets or sets the text of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("text", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Text { get; set; } + + } + + /// + /// Represents the model for a created Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class CreatedTodoItemModel + { + + /// + /// Gets or sets the ID of the created Todo item. + /// + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Id { get; set; } + + } + + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ProblemDetails + { + + [Newtonsoft.Json.JsonProperty("type", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Type { get; set; } + + [Newtonsoft.Json.JsonProperty("title", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Title { get; set; } + + [Newtonsoft.Json.JsonProperty("status", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public int? Status { get; set; } + + [Newtonsoft.Json.JsonProperty("detail", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Detail { get; set; } + + [Newtonsoft.Json.JsonProperty("instance", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Instance { get; set; } + + private System.Collections.Generic.IDictionary _additionalProperties; + + [Newtonsoft.Json.JsonExtensionData] + public System.Collections.Generic.IDictionary AdditionalProperties + { + get { return _additionalProperties ?? (_additionalProperties = new System.Collections.Generic.Dictionary()); } + set { _additionalProperties = value; } + } + + } + + /// + /// Represents a Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class TodoItemModel + { + + /// + /// Gets or sets the ID of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("id", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Id { get; set; } + + /// + /// Gets or sets the text of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("text", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public string Text { get; set; } + + /// + /// Gets or sets the date and time the item was created. + /// + [Newtonsoft.Json.JsonProperty("createdAt", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset CreatedAt { get; set; } + + /// + /// Gets or sets the date and time the item was completed. + /// + [Newtonsoft.Json.JsonProperty("completedAt", Required = Newtonsoft.Json.Required.Default, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset? CompletedAt { get; set; } + + /// + /// Gets or sets the date and time the Todo item was last updated. + /// + [Newtonsoft.Json.JsonProperty("lastUpdated", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.DateTimeOffset LastUpdated { get; set; } + + /// + /// Gets or sets the optional priority of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("priority", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public TodoPriority Priority { get; set; } + + } + + /// + /// Represents a collection of Todo items. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class TodoListViewModel + { + + /// + /// Gets or sets the Todo item(s). + /// + [Newtonsoft.Json.JsonProperty("items", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + public System.Collections.Generic.ICollection Items { get; set; } + + } + + /// + /// The priority levels for a Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public enum TodoPriority + { + + [System.Runtime.Serialization.EnumMember(Value = @"Normal")] + Normal = 0, + + [System.Runtime.Serialization.EnumMember(Value = @"Low")] + Low = 1, + + [System.Runtime.Serialization.EnumMember(Value = @"High")] + High = 2, + + } + + /// + /// Represents the model for updating the priority of a Todo item. + /// + [System.CodeDom.Compiler.GeneratedCode("NJsonSchema", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class UpdateTodoItemPriorityModel + { + + /// + /// Gets or sets the new priority of the Todo item. + /// + [Newtonsoft.Json.JsonProperty("priority", Required = Newtonsoft.Json.Required.DisallowNull, NullValueHandling = Newtonsoft.Json.NullValueHandling.Ignore)] + [Newtonsoft.Json.JsonConverter(typeof(Newtonsoft.Json.Converters.StringEnumConverter))] + public TodoPriority Priority { get; set; } + + } + + + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ApiException : System.Exception + { + public int StatusCode { get; private set; } + + public string Response { get; private set; } + + public System.Collections.Generic.IReadOnlyDictionary> Headers { get; private set; } + + public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, System.Exception innerException) + : base(message + "\n\nStatus: " + statusCode + "\nResponse: \n" + ((response == null) ? "(null)" : response.Substring(0, response.Length >= 512 ? 512 : response.Length)), innerException) + { + StatusCode = statusCode; + Response = response; + Headers = headers; + } + + public override string ToString() + { + return string.Format("HTTP Response: \n\n{0}\n\n{1}", Response, base.ToString()); + } + } + + [System.CodeDom.Compiler.GeneratedCode("NSwag", "14.6.3.0 (NJsonSchema v11.5.2.0 (Newtonsoft.Json v13.0.0.0))")] + public partial class ApiException : ApiException + { + public TResult Result { get; private set; } + + public ApiException(string message, int statusCode, string response, System.Collections.Generic.IReadOnlyDictionary> headers, TResult result, System.Exception innerException) + : base(message, statusCode, response, headers, innerException) + { + Result = result; + } + } + +} + +#pragma warning restore 108 +#pragma warning restore 114 +#pragma warning restore 472 +#pragma warning restore 612 +#pragma warning restore 649 +#pragma warning restore 1573 +#pragma warning restore 1591 +#pragma warning restore 8073 +#pragma warning restore 3016 +#pragma warning restore 8600 +#pragma warning restore 8602 +#pragma warning restore 8603 +#pragma warning restore 8604 +#pragma warning restore 8625 +#pragma warning restore 8765 \ No newline at end of file