diff --git a/.config/dotnet-tools.json b/.config/dotnet-tools.json index 9658fff117..4ceebfab3b 100644 --- a/.config/dotnet-tools.json +++ b/.config/dotnet-tools.json @@ -25,6 +25,12 @@ "commands": [ "docfx" ] + }, + "microsoft.openapi.kiota": { + "version": "1.11.1", + "commands": [ + "kiota" + ] } } } \ No newline at end of file diff --git a/.gitattributes b/.gitattributes index 1f6c60ff78..2780241e04 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1,6 +1,5 @@ # When running OpenAPI tests, these committed files are downloaded and written to disk (so we'll know when something changes). # On Windows, these text files are auto-converted to crlf on git fetch, while the written downloaded files use lf line endings. # Therefore, running the tests on Windows creates local changes. Staging them auto-converts back to crlf, which undoes the changes. -# To avoid this annoyance, the next lines opt out of the auto-conversion and force to lf. -swagger.g.json text eol=lf +# To avoid this annoyance, the next line opts out of the auto-conversion and forces line endings to lf. **/GeneratedSwagger/*.json text eol=lf diff --git a/.github/workflows/codeql.yml b/.github/workflows/codeql.yml index f12a02041b..55d430a67c 100644 --- a/.github/workflows/codeql.yml +++ b/.github/workflows/codeql.yml @@ -35,6 +35,9 @@ jobs: uses: github/codeql-action/init@v3 with: languages: ${{ matrix.language }} + - name: Restore .NET tools + run: | + dotnet tool restore - name: Autobuild uses: github/codeql-action/autobuild@v3 - name: Perform CodeQL Analysis diff --git a/.gitignore b/.gitignore index 85bd0f1080..c1757fc159 100644 --- a/.gitignore +++ b/.gitignore @@ -423,3 +423,6 @@ FodyWeavers.xsd **/.idea/**/httpRequests/ **/.idea/**/dataSources/ !**/.idea/**/codeStyles/* + +# Workaround for https://github.com/microsoft/kiota/issues/4228 +kiota-lock.json diff --git a/JsonApiDotNetCore.sln b/JsonApiDotNetCore.sln index 15ae0a00e3..3e092342c6 100644 --- a/JsonApiDotNetCore.sln +++ b/JsonApiDotNetCore.sln @@ -66,13 +66,19 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.OpenApi", EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiTests", "test\OpenApiTests\OpenApiTests.csproj", "{B693DE14-BB28-496F-AB39-B4E674ABCA80}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.OpenApi.Client", "src\JsonApiDotNetCore.OpenApi.Client\JsonApiDotNetCore.OpenApi.Client.csproj", "{5ADAA902-5A75-4ECB-B4B4-03291D63CE9C}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.OpenApi.Client.NSwag", "src\JsonApiDotNetCore.OpenApi.Client.NSwag\JsonApiDotNetCore.OpenApi.Client.NSwag.csproj", "{5ADAA902-5A75-4ECB-B4B4-03291D63CE9C}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCoreExampleClient", "src\Examples\JsonApiDotNetCoreExampleClient\JsonApiDotNetCoreExampleClient.csproj", "{7FC5DFA3-6F66-4FD8-820D-81E93856F252}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiNSwagClientExample", "src\Examples\OpenApiNSwagClientExample\OpenApiNSwagClientExample.csproj", "{7FC5DFA3-6F66-4FD8-820D-81E93856F252}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiClientTests", "test\OpenApiClientTests\OpenApiClientTests.csproj", "{77F98215-3085-422E-B99D-4C404C2114CF}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiNSwagClientTests", "test\OpenApiNSwagClientTests\OpenApiNSwagClientTests.csproj", "{77F98215-3085-422E-B99D-4C404C2114CF}" EndProject -Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiEndToEndTests", "test\OpenApiEndToEndTests\OpenApiEndToEndTests.csproj", "{3BA4F9B9-3D90-44B5-B09C-28D98E0B4225}" +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiNSwagEndToEndTests", "test\OpenApiNSwagEndToEndTests\OpenApiNSwagEndToEndTests.csproj", "{3BA4F9B9-3D90-44B5-B09C-28D98E0B4225}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "JsonApiDotNetCore.OpenApi.Client.Kiota", "src\JsonApiDotNetCore.OpenApi.Client.Kiota\JsonApiDotNetCore.OpenApi.Client.Kiota.csproj", "{617FCA5D-A2DE-4083-B373-ADCA9901059F}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiKiotaClientExample", "src\Examples\OpenApiKiotaClientExample\OpenApiKiotaClientExample.csproj", "{39DEAFE8-AE29-48E5-A67D-73776D70FC82}" +EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OpenApiKiotaEndToEndTests", "test\OpenApiKiotaEndToEndTests\OpenApiKiotaEndToEndTests.csproj", "{FD86C676-3D80-4971-8D8C-B0729B2251F6}" EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution @@ -396,6 +402,42 @@ Global {3BA4F9B9-3D90-44B5-B09C-28D98E0B4225}.Release|x64.Build.0 = Release|Any CPU {3BA4F9B9-3D90-44B5-B09C-28D98E0B4225}.Release|x86.ActiveCfg = Release|Any CPU {3BA4F9B9-3D90-44B5-B09C-28D98E0B4225}.Release|x86.Build.0 = Release|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Debug|Any CPU.Build.0 = Debug|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Debug|x64.ActiveCfg = Debug|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Debug|x64.Build.0 = Debug|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Debug|x86.ActiveCfg = Debug|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Debug|x86.Build.0 = Debug|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Release|Any CPU.ActiveCfg = Release|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Release|Any CPU.Build.0 = Release|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Release|x64.ActiveCfg = Release|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Release|x64.Build.0 = Release|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Release|x86.ActiveCfg = Release|Any CPU + {617FCA5D-A2DE-4083-B373-ADCA9901059F}.Release|x86.Build.0 = Release|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Debug|Any CPU.Build.0 = Debug|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Debug|x64.ActiveCfg = Debug|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Debug|x64.Build.0 = Debug|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Debug|x86.ActiveCfg = Debug|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Debug|x86.Build.0 = Debug|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Release|Any CPU.ActiveCfg = Release|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Release|Any CPU.Build.0 = Release|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Release|x64.ActiveCfg = Release|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Release|x64.Build.0 = Release|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Release|x86.ActiveCfg = Release|Any CPU + {39DEAFE8-AE29-48E5-A67D-73776D70FC82}.Release|x86.Build.0 = Release|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Debug|Any CPU.Build.0 = Debug|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Debug|x64.ActiveCfg = Debug|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Debug|x64.Build.0 = Debug|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Debug|x86.ActiveCfg = Debug|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Debug|x86.Build.0 = Debug|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Release|Any CPU.ActiveCfg = Release|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Release|Any CPU.Build.0 = Release|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Release|x64.ActiveCfg = Release|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Release|x64.Build.0 = Release|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Release|x86.ActiveCfg = Release|Any CPU + {FD86C676-3D80-4971-8D8C-B0729B2251F6}.Release|x86.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE @@ -427,6 +469,9 @@ Global {7FC5DFA3-6F66-4FD8-820D-81E93856F252} = {026FBC6C-AF76-4568-9B87-EC73457899FD} {77F98215-3085-422E-B99D-4C404C2114CF} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} {3BA4F9B9-3D90-44B5-B09C-28D98E0B4225} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} + {617FCA5D-A2DE-4083-B373-ADCA9901059F} = {7A2B7ADD-ECB5-4D00-AA6A-D45BD11C97CF} + {39DEAFE8-AE29-48E5-A67D-73776D70FC82} = {026FBC6C-AF76-4568-9B87-EC73457899FD} + {FD86C676-3D80-4971-8D8C-B0729B2251F6} = {24B15015-62E5-42E1-9BA0-ECE6BE7AA15F} EndGlobalSection GlobalSection(ExtensibilityGlobals) = postSolution SolutionGuid = {A2421882-8F0A-4905-928F-B550B192F9A4} diff --git a/JsonApiDotNetCore.sln.DotSettings b/JsonApiDotNetCore.sln.DotSettings index 9b756680ec..8ab8b0cf0c 100644 --- a/JsonApiDotNetCore.sln.DotSettings +++ b/JsonApiDotNetCore.sln.DotSettings @@ -670,6 +670,7 @@ $left$ = $right$; True True True + True True True True diff --git a/docs/usage/openapi-client.md b/docs/usage/openapi-client.md index 2acd8f2fe6..0ba44d20d6 100644 --- a/docs/usage/openapi-client.md +++ b/docs/usage/openapi-client.md @@ -1,23 +1,46 @@ -# OpenAPI Client +# OpenAPI clients -You can generate a JSON:API client in various programming languages from the [OpenAPI specification](https://swagger.io/specification/) file that JsonApiDotNetCore APIs provide. +After [enabling OpenAPI](~/usage/openapi.md), you can generate a JSON:API client for your API in various programming languages. -For C# .NET clients generated using [NSwag](https://github.com/RicoSuter/NSwag), we provide an additional package -that provides workarounds for NSwag bugs and introduces support for partial PATCH/POST requests. -The concern here is that a property on a generated C# class being `null` could either mean: "set the value to `null` -in the request" or: "this is `null` because I never touched it". +The following generators are supported, though you may try others as well: +- [NSwag](https://github.com/RicoSuter/NSwag): Produces clients for C# and TypeScript +- [Kiota](https://learn.microsoft.com/en-us/openapi/kiota/overview): Produces clients for C#, Go, Java, PHP, Python, Ruby, Swift and TypeScript + +# [NSwag](#tab/nswag) + +For C# clients, we provide an additional package that provides workarounds for bugs in NSwag and enables using partial PATCH/POST requests. + +To add it to your project, run the following command: +``` +dotnet add package JsonApiDotNetCore.OpenApi.Client.NSwag +``` + +# [Kiota](#tab/kiota) + +For C# clients, we provide an additional package that provides workarounds for bugs in Kiota. + +To add it to your project, run the following command: +``` +dotnet add package JsonApiDotNetCore.OpenApi.Client.Kiota +``` + +--- ## Getting started +To generate your C# client, follow the steps below. + +# [NSwag](#tab/nswag) + ### Visual Studio The easiest way to get started is by using the built-in capabilities of Visual Studio. -The next steps describe how to generate a JSON:API client library and use our package. +The following steps describe how to generate and use a JSON:API client in C#, using our package. 1. In **Solution Explorer**, right-click your client project, select **Add** > **Service Reference** and choose **OpenAPI**. 2. On the next page, specify the OpenAPI URL to your JSON:API server, for example: `http://localhost:14140/swagger/v1/swagger.json`. - Specify `ExampleApiClient` as class name, optionally provide a namespace and click **Finish**. + Specify `ExampleApiClient` as the class name, optionally provide a namespace and click **Finish**. Visual Studio now downloads your swagger.json and updates your project file. This adds a pre-build step that generates the client code. @@ -25,7 +48,7 @@ The next steps describe how to generate a JSON:API client library and use our pa > To later re-download swagger.json and regenerate the client code, > right-click **Dependencies** > **Manage Connected Services** and click the **Refresh** icon. -3. Although not strictly required, we recommend to run package update now, which fixes some issues. +3. Although not strictly required, we recommend running package update now, which fixes some issues. > [!WARNING] > NSwag v14 is currently *incompatible* with JsonApiDotNetCore (tracked [here](https://github.com/RicoSuter/NSwag/issues/4662)). Stick with v13.x for the moment. @@ -33,13 +56,13 @@ The next steps describe how to generate a JSON:API client library and use our pa 4. Add our client package to your project: ``` - dotnet add package JsonApiDotNetCore.OpenApi.Client + dotnet add package JsonApiDotNetCore.OpenApi.Client.NSwag ``` -5. Add the next line inside the **OpenApiReference** section in your project file: +5. Add the following line inside the **OpenApiReference** section in your project file: ```xml - /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client + /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag ``` 6. Add the following glue code to connect our package with your generated code. @@ -50,7 +73,7 @@ The next steps describe how to generate a JSON:API client library and use our pa > For example, add `namespace GeneratedCode;` below the `using` lines. ```c# - using JsonApiDotNetCore.OpenApi.Client; + using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; partial class ExampleApiClient : JsonApiClient @@ -62,10 +85,6 @@ The next steps describe how to generate a JSON:API client library and use our pa } ``` - > [!TIP] - > The project at src/Examples/JsonApiDotNetCoreExampleClient contains an enhanced version that logs the HTTP requests and responses. - > Additionally, the example shows how to write the swagger.json file to disk when building the server, which is imported from the client project. This keeps the server and client automatically in sync, which is handy when both are in the same solution. - 7. Add code that calls one of your JSON:API endpoints. ```c# @@ -121,42 +140,64 @@ The next steps describe how to generate a JSON:API client library and use our pa } ``` +> [!TIP] +> The [example project](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/openapi/src/Examples/OpenApiNSwagClientExample) contains an enhanced version that uses `IHttpClientFactory` for [scalability](https://learn.microsoft.com/en-us/dotnet/core/extensions/httpclient-factory) and [resiliency](https://learn.microsoft.com/en-us/aspnet/core/fundamentals/http-requests#use-polly-based-handlers) and logs the HTTP requests and responses. +> Additionally, the example shows how to write the swagger.json file to disk when building the server, which is imported from the client project. This keeps the server and client automatically in sync, which is handy when both are in the same solution. + ### Other IDEs -When using the command-line, you can try the [Microsoft.dotnet-openapi Global Tool](https://docs.microsoft.com/en-us/aspnet/core/web-api/microsoft.dotnet-openapi?view=aspnetcore-5.0). +When using the command line, you can try the [Microsoft.dotnet-openapi Global Tool](https://docs.microsoft.com/en-us/aspnet/core/web-api/microsoft.dotnet-openapi?view=aspnetcore-5.0). -Alternatively, the next section shows what to add to your client project file directly: +Alternatively, the following section shows what to add to your client project file directly: ```xml - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - - - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + - + http://localhost:14140/swagger/v1/swagger.json + NSwagCSharp + ExampleApiClient + ExampleApiClient.cs ``` From here, continue from step 3 in the list of steps for Visual Studio. +# [Kiota](#tab/kiota) + +To generate your C# client, install the Kiota tool by following the steps at https://learn.microsoft.com/en-us/openapi/kiota/install#install-as-net-tool. + +Next, generate client code by running the [command line tool](https://learn.microsoft.com/en-us/openapi/kiota/using#client-generation). For example: + +``` +dotnet kiota generate --language CSharp --class-name ExampleApiClient --output ./GeneratedCode --backing-store --exclude-backward-compatible --clean-output --clear-cache --openapi ..\JsonApiDotNetCoreExample\GeneratedSwagger\JsonApiDotNetCoreExample.json +``` + +> [!CAUTION] +> The `--backing-store` switch is needed for JSON:API partial PATCH/POST requests to work correctly. + +Kiota is pretty young and therefore still rough around the edges. At the time of writing, there are various bugs, for which we have workarounds +in place. For a full example, see the [example project](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/openapi/src/Examples/OpenApiKiotaClientExample). + +--- + ## Configuration -### NSwag +Various switches enable you to tweak the client generation to your needs. See the section below for an overview. + +# [NSwag](#tab/nswag) The `OpenApiReference` element in the project file accepts an `Options` element to pass additional settings to the client generator, which are listed [here](https://github.com/RicoSuter/NSwag/blob/master/src/NSwag.Commands/Commands/CodeGeneration/OpenApiToCSharpClientCommand.cs). +A guide with common best practices is available [here](https://stevetalkscode.co.uk/openapireference-commands). -For example, the next section puts the generated code in a namespace and generates an interface (which is handy for dependency injection): +For example, the following section puts the generated code in a namespace and generates an interface (which is handy for dependency injection): ```xml @@ -167,20 +208,47 @@ For example, the next section puts the generated code in a namespace and generat ``` +Likewise, you can enable nullable reference types by adding `/GenerateNullableReferenceTypes:true`, optionally combined with `/GenerateOptionalParameters:true`. + +# [Kiota](#tab/kiota) + +The available command-line switches for Kiota are described [here](https://learn.microsoft.com/en-us/openapi/kiota/using#client-generation). + +At the time of writing, Kiota provides [no official integration](https://github.com/microsoft/kiota/issues/3005) with MSBuild. +Our [example project](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/openapi/src/Examples/OpenApiKiotaClientExample) takes a stab at it, although it has glitches. If you're an MSBuild expert, please help out! + +```xml + + + + + + + + + +``` + +--- + ## Headers and caching -To use [ETags for caching](~/usage/caching.md), NSwag needs extra settings to make response headers accessible. -Specify the following in the `` element of your project file: +The use of HTTP headers varies per client generator. To use [ETags for caching](~/usage/caching.md), see the notes below. + +# [NSwag](#tab/nswag) + +NSwag needs extra settings to make response headers accessible. Specify the following in the `` element of your project file: ``` -/GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client +/GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag ``` This enables the following code, which is explained below: ```c# var getResponse = await ApiResponse.TranslateAsync(() => apiClient.GetPersonCollectionAsync(null, null)); -string eTag = getResponse.Headers[HeaderNames.ETag].Single(); +string eTag = getResponse.Headers["ETag"].Single(); Console.WriteLine($"Retrieved {getResponse.Result.Data.Count} people."); // wait some time... @@ -197,3 +265,24 @@ The response of the first API call contains both data and an ETag header, which That ETag gets passed to the second API call. This enables the server to detect if something changed, which optimizes network usage: no data is sent back, unless is has changed. If you only want to ask whether data has changed without fetching it, use a HEAD request instead. + +# [Kiota](#tab/kiota) + +Use `HeadersInspectionHandlerOption` to gain access to response headers. For example: + +```c# +var headerInspector = new HeadersInspectionHandlerOption +{ + InspectResponseHeaders = true +}; + +var responseDocument = await apiClient.Api.People.GetAsync(configuration => configuration.Options.Add(headerInspector)); + +string eTag = headerInspector.ResponseHeaders["ETag"].Single(); +``` + +Due to a [bug in Kiota](https://github.com/microsoft/kiota/issues/4190), a try/catch block is needed additionally to make this work. + +For a full example, see the [example project](https://github.com/json-api-dotnet/JsonApiDotNetCore/tree/openapi/src/Examples/OpenApiKiotaClientExample). + +--- diff --git a/docs/usage/openapi.md b/docs/usage/openapi.md index 1419a6ba43..e26754d99b 100644 --- a/docs/usage/openapi.md +++ b/docs/usage/openapi.md @@ -16,13 +16,10 @@ The package provides an integration with [Swashbuckle](https://github.com/domain 2. Add the integration in your `Program.cs` file. ```c# - IMvcCoreBuilder mvcCoreBuilder = builder.Services.AddMvcCore(); - - // Include the mvcBuilder parameter. - builder.Services.AddJsonApi(mvcBuilder: mvcCoreBuilder); + builder.Services.AddJsonApi(); // Configure Swashbuckle for JSON:API. - builder.Services.AddOpenApi(mvcCoreBuilder); + builder.Services.AddOpenApi(); var app = builder.Build(); diff --git a/docs/usage/toc.md b/docs/usage/toc.md index 6f90725cba..925aa660a2 100644 --- a/docs/usage/toc.md +++ b/docs/usage/toc.md @@ -26,7 +26,7 @@ # [Common Pitfalls](common-pitfalls.md) # [OpenAPI](openapi.md) -## [Client](openapi-client.md) +## [Clients](openapi-client.md) # Extensibility ## [Layer Overview](extensibility/layer-overview.md) diff --git a/package-versions.props b/package-versions.props index 0129d2aee2..89a550247d 100644 --- a/package-versions.props +++ b/package-versions.props @@ -5,6 +5,7 @@ 0.4.1 2.14.1 6.5.0 + 13.0.3 8.0.* @@ -17,6 +18,7 @@ 6.12.* 2.3.* 2.0.* + 1.* 8.0.* 13.20.* 13.0.* diff --git a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj index 5335a96b42..654abe9a88 100644 --- a/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj +++ b/src/Examples/JsonApiDotNetCoreExample/JsonApiDotNetCoreExample.csproj @@ -16,8 +16,8 @@ - - + + diff --git a/src/Examples/JsonApiDotNetCoreExample/Program.cs b/src/Examples/JsonApiDotNetCoreExample/Program.cs index 332235d491..925c2f02e3 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Program.cs +++ b/src/Examples/JsonApiDotNetCoreExample/Program.cs @@ -66,8 +66,6 @@ static void ConfigureServices(WebApplicationBuilder builder) SetDbContextDebugOptions(options); }); - IMvcCoreBuilder mvcCoreBuilder = builder.Services.AddMvcCore(); - using (CodeTimingSessionManager.Current.Measure("AddJsonApi()")) { builder.Services.AddJsonApi(options => @@ -82,12 +80,12 @@ static void ConfigureServices(WebApplicationBuilder builder) options.IncludeRequestBodyInErrors = true; options.SerializerOptions.WriteIndented = true; #endif - }, discovery => discovery.AddCurrentAssembly(), mvcBuilder: mvcCoreBuilder); + }, discovery => discovery.AddCurrentAssembly()); } using (CodeTimingSessionManager.Current.Measure("AddOpenApi()")) { - builder.Services.AddOpenApi(mvcCoreBuilder, options => options.DocumentFilter()); + builder.Services.AddOpenApi(options => options.DocumentFilter()); } } diff --git a/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs b/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs deleted file mode 100644 index 7f3926f00c..0000000000 --- a/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs +++ /dev/null @@ -1,90 +0,0 @@ -using System.Net; -using JsonApiDotNetCore.OpenApi.Client; -using JsonApiDotNetCoreExampleClient; -using Microsoft.Net.Http.Headers; - -#if DEBUG -using var httpClient = new HttpClient(new ColoredConsoleLogDelegatingHandler -{ - InnerHandler = new HttpClientHandler() -}); -#else -using var httpClient = new HttpClient(); -#endif - -var apiClient = new ExampleApiClient(httpClient); - -ApiResponse getResponse1 = await GetPersonCollectionAsync(apiClient, null); -ApiResponse getResponse2 = await GetPersonCollectionAsync(apiClient, getResponse1.Headers[HeaderNames.ETag].First()); - -if (getResponse2 is { StatusCode: (int)HttpStatusCode.NotModified, Result: null }) -{ - Console.WriteLine("The HTTP response hasn't changed, so no response body was returned."); -} - -foreach (PersonDataInResponse person in getResponse1.Result!.Data) -{ - PrintPerson(person, getResponse1.Result.Included); -} - -var patchRequest = new PersonPatchRequestDocument -{ - Data = new PersonDataInPatchRequest - { - Id = "1", - Attributes = new PersonAttributesInPatchRequest - { - LastName = "Doe" - } - } -}; - -// This line results in sending "firstName: null" instead of omitting it. -using (apiClient.WithPartialAttributeSerialization(patchRequest, person => person.FirstName)) -{ - // Workaround for https://github.com/RicoSuter/NSwag/issues/2499. - await ApiResponse.TranslateAsync(() => apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest)); -} - -Console.WriteLine("Press any key to close."); -Console.ReadKey(); - -static Task> GetPersonCollectionAsync(ExampleApiClient apiClient, string? ifNoneMatch) -{ - return ApiResponse.TranslateAsync(() => apiClient.GetPersonCollectionAsync(new Dictionary - { - ["filter"] = "has(assignedTodoItems)", - ["sort"] = "-lastName", - ["page[size]"] = "5", - ["include"] = "assignedTodoItems.tags" - }, ifNoneMatch)); -} - -static void PrintPerson(PersonDataInResponse person, ICollection includes) -{ - ToManyTodoItemInResponse assignedTodoItems = person.Relationships.AssignedTodoItems; - - Console.WriteLine($"Found person {person.Id}: {person.Attributes.DisplayName} with {assignedTodoItems.Data.Count} assigned todo-items:"); - - PrintRelatedTodoItems(assignedTodoItems.Data, includes); -} - -static void PrintRelatedTodoItems(IEnumerable todoItemIdentifiers, ICollection includes) -{ - foreach (TodoItemIdentifier todoItemIdentifier in todoItemIdentifiers) - { - TodoItemDataInResponse includedTodoItem = includes.OfType().Single(include => include.Id == todoItemIdentifier.Id); - Console.WriteLine($" TodoItem {includedTodoItem.Id}: {includedTodoItem.Attributes.Description}"); - - PrintRelatedTags(includedTodoItem.Relationships.Tags.Data, includes); - } -} - -static void PrintRelatedTags(IEnumerable tagIdentifiers, ICollection includes) -{ - foreach (TagIdentifier tagIdentifier in tagIdentifiers) - { - TagDataInResponse includedTag = includes.OfType().Single(include => include.Id == tagIdentifier.Id); - Console.WriteLine($" Tag {includedTag.Id}: {includedTag.Attributes.Name}"); - } -} diff --git a/src/Examples/JsonApiDotNetCoreExampleClient/ColoredConsoleLogDelegatingHandler.cs b/src/Examples/OpenApiKiotaClientExample/ColoredConsoleLogHttpMessageHandler.cs similarity index 90% rename from src/Examples/JsonApiDotNetCoreExampleClient/ColoredConsoleLogDelegatingHandler.cs rename to src/Examples/OpenApiKiotaClientExample/ColoredConsoleLogHttpMessageHandler.cs index 88679e112f..e13aff5a4d 100644 --- a/src/Examples/JsonApiDotNetCoreExampleClient/ColoredConsoleLogDelegatingHandler.cs +++ b/src/Examples/OpenApiKiotaClientExample/ColoredConsoleLogHttpMessageHandler.cs @@ -1,24 +1,28 @@ using JetBrains.Annotations; -namespace JsonApiDotNetCoreExampleClient; +namespace OpenApiKiotaClientExample; /// /// Writes incoming and outgoing HTTP messages to the console. /// -[UsedImplicitly] -internal sealed class ColoredConsoleLogDelegatingHandler : DelegatingHandler +internal sealed class ColoredConsoleLogHttpMessageHandler : DelegatingHandler { protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) { +#if DEBUG await LogRequestAsync(request, cancellationToken); +#endif HttpResponseMessage response = await base.SendAsync(request, cancellationToken); +#if DEBUG await LogResponseAsync(response, cancellationToken); +#endif return response; } + [UsedImplicitly] private static async Task LogRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken) { using var _ = new ConsoleColorScope(ConsoleColor.Green); @@ -33,6 +37,7 @@ private static async Task LogRequestAsync(HttpRequestMessage request, Cancellati } } + [UsedImplicitly] private static async Task LogResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken) { using var _ = new ConsoleColorScope(ConsoleColor.Cyan); diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/ApiRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/ApiRequestBuilder.cs new file mode 100644 index 0000000000..f67774090a --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/ApiRequestBuilder.cs @@ -0,0 +1,43 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.People; +using OpenApiKiotaClientExample.GeneratedCode.Api.Tags; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api { + /// + /// Builds and executes requests for operations under \api + /// + public class ApiRequestBuilder : BaseRequestBuilder { + /// The people property + public PeopleRequestBuilder People { get => + new PeopleRequestBuilder(PathParameters, RequestAdapter); + } + /// The tags property + public TagsRequestBuilder Tags { get => + new TagsRequestBuilder(PathParameters, RequestAdapter); + } + /// The todoItems property + public TodoItemsRequestBuilder TodoItems { get => + new TodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new ApiRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ApiRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api", pathParameters) { + } + /// + /// Instantiates a new ApiRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ApiRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api", rawUrl) { + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/AssignedTodoItems/AssignedTodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/AssignedTodoItems/AssignedTodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..5773981c9f --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/AssignedTodoItems/AssignedTodoItemsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.AssignedTodoItems { + /// + /// Builds and executes requests for operations under \api\people\{id}\assignedTodoItems + /// + public class AssignedTodoItemsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AssignedTodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AssignedTodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/assignedTodoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new AssignedTodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AssignedTodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/assignedTodoItems{?query*}", rawUrl) { + } + /// + /// Retrieves the related todoItems of an individual person's assignedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related todoItems of an individual person's assignedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AssignedTodoItemsRequestBuilder WithUrl(string rawUrl) { + return new AssignedTodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related todoItems of an individual person's assignedTodoItems relationship. + /// + public class AssignedTodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AssignedTodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/OwnedTodoItems/OwnedTodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/OwnedTodoItems/OwnedTodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..d13bb455d0 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/OwnedTodoItems/OwnedTodoItemsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.OwnedTodoItems { + /// + /// Builds and executes requests for operations under \api\people\{id}\ownedTodoItems + /// + public class OwnedTodoItemsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new OwnedTodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OwnedTodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/ownedTodoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new OwnedTodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OwnedTodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/ownedTodoItems{?query*}", rawUrl) { + } + /// + /// Retrieves the related todoItems of an individual person's ownedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related todoItems of an individual person's ownedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public OwnedTodoItemsRequestBuilder WithUrl(string rawUrl) { + return new OwnedTodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related todoItems of an individual person's ownedTodoItems relationship. + /// + public class OwnedTodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class OwnedTodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/PeopleItemRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/PeopleItemRequestBuilder.cs new file mode 100644 index 0000000000..27ab0fb180 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/PeopleItemRequestBuilder.cs @@ -0,0 +1,239 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.AssignedTodoItems; +using OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.OwnedTodoItems; +using OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.Relationships; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People.Item { + /// + /// Builds and executes requests for operations under \api\people\{id} + /// + public class PeopleItemRequestBuilder : BaseRequestBuilder { + /// The assignedTodoItems property + public AssignedTodoItemsRequestBuilder AssignedTodoItems { get => + new AssignedTodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ownedTodoItems property + public OwnedTodoItemsRequestBuilder OwnedTodoItems { get => + new OwnedTodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new PeopleItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public PeopleItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new PeopleItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public PeopleItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing person by its identifier. + /// + /// 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 DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual person by its identifier. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PersonPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing person. + /// + /// The request body + /// 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 PatchAsync(PersonPatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(PersonPatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PersonPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing person by its identifier. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Retrieves an individual person by its identifier. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Updates an existing person. + /// + /// The request body + /// 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(PersonPatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(PersonPatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public PeopleItemRequestBuilder WithUrl(string rawUrl) { + return new PeopleItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual person by its identifier. + /// + public class PeopleItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class PeopleItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Updates an existing person. + /// + public class PeopleItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/AssignedTodoItems/AssignedTodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/AssignedTodoItems/AssignedTodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..bcf5b07d9c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/AssignedTodoItems/AssignedTodoItemsRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.Relationships.AssignedTodoItems { + /// + /// Builds and executes requests for operations under \api\people\{id}\relationships\assignedTodoItems + /// + public class AssignedTodoItemsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AssignedTodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AssignedTodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/relationships/assignedTodoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new AssignedTodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AssignedTodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/relationships/assignedTodoItems{?query*}", rawUrl) { + } + /// + /// Removes existing todoItems from the assignedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 DeleteAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related todoItem identities of an individual person's assignedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing todoItems to the assignedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 PatchAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing todoItems to the assignedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 PostAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing todoItems from the assignedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related todoItem identities of an individual person's assignedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing todoItems to the assignedTodoItems relationship of an individual person. + /// + /// The request body + /// 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(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing todoItems to the assignedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AssignedTodoItemsRequestBuilder WithUrl(string rawUrl) { + return new AssignedTodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related todoItem identities of an individual person's assignedTodoItems relationship. + /// + public class AssignedTodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AssignedTodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/OwnedTodoItems/OwnedTodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/OwnedTodoItems/OwnedTodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..80c5a9bc9b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/OwnedTodoItems/OwnedTodoItemsRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.Relationships.OwnedTodoItems { + /// + /// Builds and executes requests for operations under \api\people\{id}\relationships\ownedTodoItems + /// + public class OwnedTodoItemsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new OwnedTodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OwnedTodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/relationships/ownedTodoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new OwnedTodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OwnedTodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/relationships/ownedTodoItems{?query*}", rawUrl) { + } + /// + /// Removes existing todoItems from the ownedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 DeleteAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related todoItem identities of an individual person's ownedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing todoItems to the ownedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 PatchAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing todoItems to the ownedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 PostAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing todoItems from the ownedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related todoItem identities of an individual person's ownedTodoItems relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing todoItems to the ownedTodoItems relationship of an individual person. + /// + /// The request body + /// 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(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing todoItems to the ownedTodoItems relationship of an individual person. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public OwnedTodoItemsRequestBuilder WithUrl(string rawUrl) { + return new OwnedTodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related todoItem identities of an individual person's ownedTodoItems relationship. + /// + public class OwnedTodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class OwnedTodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/RelationshipsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..f1adfee806 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,38 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.Relationships.AssignedTodoItems; +using OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.Relationships.OwnedTodoItems; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People.Item.Relationships { + /// + /// Builds and executes requests for operations under \api\people\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The assignedTodoItems property + public AssignedTodoItemsRequestBuilder AssignedTodoItems { get => + new AssignedTodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// The ownedTodoItems property + public OwnedTodoItemsRequestBuilder OwnedTodoItems { get => + new OwnedTodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people/{id}/relationships", rawUrl) { + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs new file mode 100644 index 0000000000..7ba6f0a5c0 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/People/PeopleRequestBuilder.cs @@ -0,0 +1,197 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.People.Item; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.People { + /// + /// Builds and executes requests for operations under \api\people + /// + public class PeopleRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaClientExample.GeneratedCode.api.people.item collection + /// The identifier of the person to retrieve. + public PeopleItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new PeopleItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new PeopleRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public PeopleRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people{?query*}", pathParameters) { + } + /// + /// Instantiates a new PeopleRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public PeopleRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/people{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of people. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PersonCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new person. + /// + /// The request body + /// 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 PostAsync(PersonPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(PersonPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PersonPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of people. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Creates a new person. + /// + /// The request body + /// 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 ToPostRequestInformation(PersonPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(PersonPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public PeopleRequestBuilder WithUrl(string rawUrl) { + return new PeopleRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of people. + /// + public class PeopleRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class PeopleRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Creates a new person. + /// + public class PeopleRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/Relationships/RelationshipsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..d7a94e21fc --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,33 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item.Relationships.TodoItems; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item.Relationships { + /// + /// Builds and executes requests for operations under \api\tags\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The todoItems property + public TodoItemsRequestBuilder TodoItems { get => + new TodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}/relationships", rawUrl) { + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/Relationships/TodoItems/TodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/Relationships/TodoItems/TodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..aa828bb1ac --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/Relationships/TodoItems/TodoItemsRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item.Relationships.TodoItems { + /// + /// Builds and executes requests for operations under \api\tags\{id}\relationships\todoItems + /// + public class TodoItemsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new TodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}/relationships/todoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new TodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}/relationships/todoItems{?query*}", rawUrl) { + } + /// + /// Removes existing todoItems from the todoItems relationship of an individual tag. + /// + /// The request body + /// 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 DeleteAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related todoItem identities of an individual tag's todoItems relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing todoItems to the todoItems relationship of an individual tag. + /// + /// The request body + /// 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 PatchAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing todoItems to the todoItems relationship of an individual tag. + /// + /// The request body + /// 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 PostAsync(ToManyTodoItemInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyTodoItemInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing todoItems from the todoItems relationship of an individual tag. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related todoItem identities of an individual tag's todoItems relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing todoItems to the todoItems relationship of an individual tag. + /// + /// The request body + /// 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(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing todoItems to the todoItems relationship of an individual tag. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyTodoItemInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyTodoItemInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TodoItemsRequestBuilder WithUrl(string rawUrl) { + return new TodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related todoItem identities of an individual tag's todoItems relationship. + /// + public class TodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/TagsItemRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/TagsItemRequestBuilder.cs new file mode 100644 index 0000000000..dcd0c130d5 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/TagsItemRequestBuilder.cs @@ -0,0 +1,234 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item.Relationships; +using OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item.TodoItems; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item { + /// + /// Builds and executes requests for operations under \api\tags\{id} + /// + public class TagsItemRequestBuilder : BaseRequestBuilder { + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// The todoItems property + public TodoItemsRequestBuilder TodoItems { get => + new TodoItemsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new TagsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TagsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new TagsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TagsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing tag by its identifier. + /// + /// 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 DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual tag by its identifier. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TagPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing tag. + /// + /// The request body + /// 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 PatchAsync(TagPatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(TagPatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TagPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing tag by its identifier. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Retrieves an individual tag by its identifier. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Updates an existing tag. + /// + /// The request body + /// 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(TagPatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(TagPatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TagsItemRequestBuilder WithUrl(string rawUrl) { + return new TagsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual tag by its identifier. + /// + public class TagsItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TagsItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Updates an existing tag. + /// + public class TagsItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/TodoItems/TodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/TodoItems/TodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..918bf06a3c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/Item/TodoItems/TodoItemsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item.TodoItems { + /// + /// Builds and executes requests for operations under \api\tags\{id}\todoItems + /// + public class TodoItemsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new TodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}/todoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new TodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags/{id}/todoItems{?query*}", rawUrl) { + } + /// + /// Retrieves the related todoItems of an individual tag's todoItems relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related todoItems of an individual tag's todoItems relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TodoItemsRequestBuilder WithUrl(string rawUrl) { + return new TodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related todoItems of an individual tag's todoItems relationship. + /// + public class TodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs new file mode 100644 index 0000000000..9c9d71cde2 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/Tags/TagsRequestBuilder.cs @@ -0,0 +1,197 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.Tags.Item; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.Tags { + /// + /// Builds and executes requests for operations under \api\tags + /// + public class TagsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaClientExample.GeneratedCode.api.tags.item collection + /// The identifier of the tag to retrieve. + public TagsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new TagsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new TagsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TagsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags{?query*}", pathParameters) { + } + /// + /// Instantiates a new TagsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TagsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/tags{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of tags. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TagCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new tag. + /// + /// The request body + /// 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 PostAsync(TagPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(TagPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TagPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of tags. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Creates a new tag. + /// + /// The request body + /// 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 ToPostRequestInformation(TagPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(TagPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TagsRequestBuilder WithUrl(string rawUrl) { + return new TagsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of tags. + /// + public class TagsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TagsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Creates a new tag. + /// + public class TagsRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Assignee/AssigneeRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Assignee/AssigneeRequestBuilder.cs new file mode 100644 index 0000000000..9bc9f12708 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Assignee/AssigneeRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Assignee { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\assignee + /// + public class AssigneeRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AssigneeRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AssigneeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/assignee{?query*}", pathParameters) { + } + /// + /// Instantiates a new AssigneeRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AssigneeRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/assignee{?query*}", rawUrl) { + } + /// + /// Retrieves the related person of an individual todoItem's assignee relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullablePersonSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related person of an individual todoItem's assignee relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AssigneeRequestBuilder WithUrl(string rawUrl) { + return new AssigneeRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related person of an individual todoItem's assignee relationship. + /// + public class AssigneeRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AssigneeRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Owner/OwnerRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Owner/OwnerRequestBuilder.cs new file mode 100644 index 0000000000..8243f0cc95 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Owner/OwnerRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Owner { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\owner + /// + public class OwnerRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/owner{?query*}", pathParameters) { + } + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/owner{?query*}", rawUrl) { + } + /// + /// Retrieves the related person of an individual todoItem's owner relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PersonSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related person of an individual todoItem's owner relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public OwnerRequestBuilder WithUrl(string rawUrl) { + return new OwnerRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related person of an individual todoItem's owner relationship. + /// + public class OwnerRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class OwnerRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Assignee/AssigneeRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Assignee/AssigneeRequestBuilder.cs new file mode 100644 index 0000000000..ee8104d004 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Assignee/AssigneeRequestBuilder.cs @@ -0,0 +1,174 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships.Assignee { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\relationships\assignee + /// + public class AssigneeRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new AssigneeRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AssigneeRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships/assignee{?query*}", pathParameters) { + } + /// + /// Instantiates a new AssigneeRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AssigneeRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships/assignee{?query*}", rawUrl) { + } + /// + /// Retrieves the related person identity of an individual todoItem's assignee relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullablePersonIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Clears or assigns an existing person to the assignee relationship of an individual todoItem. + /// + /// The request body + /// 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 PatchAsync(NullableToOnePersonInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(NullableToOnePersonInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related person identity of an individual todoItem's assignee relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Clears or assigns an existing person to the assignee relationship of an individual todoItem. + /// + /// The request body + /// 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(NullableToOnePersonInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(NullableToOnePersonInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public AssigneeRequestBuilder WithUrl(string rawUrl) { + return new AssigneeRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related person identity of an individual todoItem's assignee relationship. + /// + public class AssigneeRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class AssigneeRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Owner/OwnerRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Owner/OwnerRequestBuilder.cs new file mode 100644 index 0000000000..a65843384e --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Owner/OwnerRequestBuilder.cs @@ -0,0 +1,174 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships.Owner { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\relationships\owner + /// + public class OwnerRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships/owner{?query*}", pathParameters) { + } + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships/owner{?query*}", rawUrl) { + } + /// + /// Retrieves the related person identity of an individual todoItem's owner relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, PersonIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns an existing person to the owner relationship of an individual todoItem. + /// + /// The request body + /// 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 PatchAsync(ToOnePersonInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToOnePersonInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related person identity of an individual todoItem's owner relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns an existing person to the owner relationship of an individual todoItem. + /// + /// The request body + /// 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(ToOnePersonInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToOnePersonInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public OwnerRequestBuilder WithUrl(string rawUrl) { + return new OwnerRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related person identity of an individual todoItem's owner relationship. + /// + public class OwnerRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class OwnerRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/RelationshipsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..c325834f07 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,43 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships.Assignee; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships.Owner; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships.Tags; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The assignee property + public AssigneeRequestBuilder Assignee { get => + new AssigneeRequestBuilder(PathParameters, RequestAdapter); + } + /// The owner property + public OwnerRequestBuilder Owner { get => + new OwnerRequestBuilder(PathParameters, RequestAdapter); + } + /// The tags property + public TagsRequestBuilder Tags { get => + new TagsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships", rawUrl) { + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Tags/TagsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Tags/TagsRequestBuilder.cs new file mode 100644 index 0000000000..3add4f4aca --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Relationships/Tags/TagsRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships.Tags { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\relationships\tags + /// + public class TagsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new TagsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TagsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships/tags{?query*}", pathParameters) { + } + /// + /// Instantiates a new TagsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TagsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/relationships/tags{?query*}", rawUrl) { + } + /// + /// Removes existing tags from the tags relationship of an individual todoItem. + /// + /// The request body + /// 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 DeleteAsync(ToManyTagInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyTagInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related tag identities of an individual todoItem's tags relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TagIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing tags to the tags relationship of an individual todoItem. + /// + /// The request body + /// 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 PatchAsync(ToManyTagInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyTagInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing tags to the tags relationship of an individual todoItem. + /// + /// The request body + /// 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 PostAsync(ToManyTagInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyTagInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing tags from the tags relationship of an individual todoItem. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyTagInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyTagInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related tag identities of an individual todoItem's tags relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing tags to the tags relationship of an individual todoItem. + /// + /// The request body + /// 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(ToManyTagInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyTagInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing tags to the tags relationship of an individual todoItem. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyTagInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyTagInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TagsRequestBuilder WithUrl(string rawUrl) { + return new TagsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related tag identities of an individual todoItem's tags relationship. + /// + public class TagsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TagsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Tags/TagsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Tags/TagsRequestBuilder.cs new file mode 100644 index 0000000000..07c127fef9 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/Tags/TagsRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Tags { + /// + /// Builds and executes requests for operations under \api\todoItems\{id}\tags + /// + public class TagsRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new TagsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TagsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/tags{?query*}", pathParameters) { + } + /// + /// Instantiates a new TagsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TagsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}/tags{?query*}", rawUrl) { + } + /// + /// Retrieves the related tags of an individual todoItem's tags relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TagCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related tags of an individual todoItem's tags relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TagsRequestBuilder WithUrl(string rawUrl) { + return new TagsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related tags of an individual todoItem's tags relationship. + /// + public class TagsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TagsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/TodoItemsItemRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/TodoItemsItemRequestBuilder.cs new file mode 100644 index 0000000000..b665f9a46c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/Item/TodoItemsItemRequestBuilder.cs @@ -0,0 +1,244 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Assignee; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Owner; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Relationships; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item.Tags; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item { + /// + /// Builds and executes requests for operations under \api\todoItems\{id} + /// + public class TodoItemsItemRequestBuilder : BaseRequestBuilder { + /// The assignee property + public AssigneeRequestBuilder Assignee { get => + new AssigneeRequestBuilder(PathParameters, RequestAdapter); + } + /// The owner property + public OwnerRequestBuilder Owner { get => + new OwnerRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// The tags property + public TagsRequestBuilder Tags { get => + new TagsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new TodoItemsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TodoItemsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new TodoItemsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TodoItemsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing todoItem by its identifier. + /// + /// 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 DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual todoItem by its identifier. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing todoItem. + /// + /// The request body + /// 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 PatchAsync(TodoItemPatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(TodoItemPatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing todoItem by its identifier. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Retrieves an individual todoItem by its identifier. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Updates an existing todoItem. + /// + /// The request body + /// 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(TodoItemPatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(TodoItemPatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TodoItemsItemRequestBuilder WithUrl(string rawUrl) { + return new TodoItemsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual todoItem by its identifier. + /// + public class TodoItemsItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TodoItemsItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Updates an existing todoItem. + /// + public class TodoItemsItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs new file mode 100644 index 0000000000..08e26f678b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Api/TodoItems/TodoItemsRequestBuilder.cs @@ -0,0 +1,197 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems.Item; +using OpenApiKiotaClientExample.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Api.TodoItems { + /// + /// Builds and executes requests for operations under \api\todoItems + /// + public class TodoItemsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaClientExample.GeneratedCode.api.todoItems.item collection + /// The identifier of the todoItem to retrieve. + public TodoItemsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new TodoItemsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new TodoItemsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public TodoItemsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems{?query*}", pathParameters) { + } + /// + /// Instantiates a new TodoItemsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public TodoItemsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/api/todoItems{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of todoItems. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new todoItem. + /// + /// The request body + /// 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 PostAsync(TodoItemPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(TodoItemPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, TodoItemPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of todoItems. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Creates a new todoItem. + /// + /// The request body + /// 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 ToPostRequestInformation(TodoItemPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(TodoItemPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public TodoItemsRequestBuilder WithUrl(string rawUrl) { + return new TodoItemsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of todoItems. + /// + public class TodoItemsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class TodoItemsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Creates a new todoItem. + /// + public class TodoItemsRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/ExampleApiClient.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/ExampleApiClient.cs new file mode 100644 index 0000000000..fd0b3316ee --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/ExampleApiClient.cs @@ -0,0 +1,44 @@ +// +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Serialization.Form; +using Microsoft.Kiota.Serialization.Json; +using Microsoft.Kiota.Serialization.Multipart; +using Microsoft.Kiota.Serialization.Text; +using OpenApiKiotaClientExample.GeneratedCode.Api; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode { + /// + /// The main entry point of the SDK, exposes the configuration and the fluent API. + /// + public class ExampleApiClient : BaseRequestBuilder { + /// The api property + public ApiRequestBuilder Api { get => + new ApiRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new ExampleApiClient and sets the default values. + /// + /// The backing store to use for the models. + /// The request adapter to use to execute the requests. + public ExampleApiClient(IRequestAdapter requestAdapter, IBackingStoreFactory backingStore = default) : base(requestAdapter, "{+baseurl}", new Dictionary()) { + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) { + RequestAdapter.BaseUrl = "https://localhost:44340"; + } + PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl); + RequestAdapter.EnableBackingStore(backingStore); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Assignee.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Assignee.cs new file mode 100644 index 0000000000..0a34482d66 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Assignee.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class Assignee : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PersonAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Assignee_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Assignee_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PersonRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Assignee CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Assignee(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PersonAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Assignee_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PersonRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Assignee_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Assignee_meta.cs new file mode 100644 index 0000000000..5bc3af81c1 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Assignee_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class Assignee_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new assignee_meta and sets the default values. + /// + public Assignee_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Assignee_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Assignee_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/DataInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/DataInResponse.cs new file mode 100644 index 0000000000..bb5ad7b6b9 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/DataInResponse.cs @@ -0,0 +1,79 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class DataInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new dataInResponse and sets the default values. + /// + public DataInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch { + "people" => new PersonDataInResponse(), + "tags" => new TagDataInResponse(), + "todoItems" => new TodoItemDataInResponse(), + _ => new DataInResponse(), + }; + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorLinks.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorLinks.cs new file mode 100644 index 0000000000..2fb38d5ac9 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorLinks.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ErrorLinks : IBackedModel, IParsable { + /// The about property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#nullable restore +#else + public string About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new errorLinks and sets the default values. + /// + public ErrorLinks() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorLinks CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorLinks(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"about", n => { About = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("about", About); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorObject.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorObject.cs new file mode 100644 index 0000000000..1b58b4ea81 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorObject.cs @@ -0,0 +1,169 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ErrorObject : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The code property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#nullable restore +#else + public string Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#endif + /// The detail property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#nullable restore +#else + public string Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorLinks? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public ErrorLinks Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorObject_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorObject_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The source property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorSource? Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#nullable restore +#else + public ErrorSource Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#endif + /// The status property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#nullable restore +#else + public string Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#endif + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new errorObject and sets the default values. + /// + public ErrorObject() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"code", n => { Code = n.GetStringValue(); } }, + {"detail", n => { Detail = n.GetStringValue(); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"links", n => { Links = n.GetObjectValue(ErrorLinks.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorObject_meta.CreateFromDiscriminatorValue); } }, + {"source", n => { Source = n.GetObjectValue(ErrorSource.CreateFromDiscriminatorValue); } }, + {"status", n => { Status = n.GetStringValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("code", Code); + writer.WriteStringValue("detail", Detail); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("source", Source); + writer.WriteStringValue("status", Status); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorObject_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorObject_meta.cs new file mode 100644 index 0000000000..dc024af2d7 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorObject_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ErrorObject_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorObject_meta and sets the default values. + /// + public ErrorObject_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorResponseDocument.cs new file mode 100644 index 0000000000..32e5a9ff73 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorResponseDocument.cs @@ -0,0 +1,60 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ErrorResponseDocument : ApiException, IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The errors property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Errors { + get { return BackingStore?.Get?>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#nullable restore +#else + public List Errors { + get { return BackingStore?.Get>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#endif + /// The primary error message. + public override string Message { get => base.Message; } + /// + /// Instantiates a new errorResponseDocument and sets the default values. + /// + public ErrorResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"errors", n => { Errors = n.GetCollectionOfObjectValues(ErrorObject.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("errors", Errors); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorSource.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorSource.cs new file mode 100644 index 0000000000..6f91676932 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ErrorSource.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ErrorSource : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The header property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#nullable restore +#else + public string Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#endif + /// The parameter property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#nullable restore +#else + public string Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#endif + /// The pointer property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#nullable restore +#else + public string Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#endif + /// + /// Instantiates a new errorSource and sets the default values. + /// + public ErrorSource() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorSource CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorSource(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"header", n => { Header = n.GetStringValue(); } }, + {"parameter", n => { Parameter = n.GetStringValue(); } }, + {"pointer", n => { Pointer = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("header", Header); + writer.WriteStringValue("parameter", Parameter); + writer.WriteStringValue("pointer", Pointer); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInRelationship.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInRelationship.cs new file mode 100644 index 0000000000..c83d07bfdb --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInRelationship.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class LinksInRelationship : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInRelationship and sets the default values. + /// + public LinksInRelationship() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInRelationship CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInRelationship(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceCollectionDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceCollectionDocument.cs new file mode 100644 index 0000000000..48ac519c04 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceCollectionDocument.cs @@ -0,0 +1,137 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class LinksInResourceCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceCollectionDocument and sets the default values. + /// + public LinksInResourceCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceData.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceData.cs new file mode 100644 index 0000000000..89756e3093 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceData.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class LinksInResourceData : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceData and sets the default values. + /// + public LinksInResourceData() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceData CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceData(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceDocument.cs new file mode 100644 index 0000000000..1d41ffcd7b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class LinksInResourceDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceDocument and sets the default values. + /// + public LinksInResourceDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs new file mode 100644 index 0000000000..30176adee0 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs @@ -0,0 +1,153 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class LinksInResourceIdentifierCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierCollectionDocument and sets the default values. + /// + public LinksInResourceIdentifierCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs new file mode 100644 index 0000000000..0a67c50c39 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class LinksInResourceIdentifierDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierDocument and sets the default values. + /// + public LinksInResourceIdentifierDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonIdentifierResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonIdentifierResponseDocument.cs new file mode 100644 index 0000000000..df7f795d64 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonIdentifierResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullablePersonIdentifierResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullablePersonIdentifierResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullablePersonIdentifierResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullablePersonIdentifierResponseDocument and sets the default values. + /// + public NullablePersonIdentifierResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullablePersonIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullablePersonIdentifierResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullablePersonIdentifierResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonIdentifierResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonIdentifierResponseDocument_meta.cs new file mode 100644 index 0000000000..8e9c41594c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonIdentifierResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullablePersonIdentifierResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullablePersonIdentifierResponseDocument_meta and sets the default values. + /// + public NullablePersonIdentifierResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullablePersonIdentifierResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullablePersonIdentifierResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonSecondaryResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonSecondaryResponseDocument.cs new file mode 100644 index 0000000000..8ca8cbccb6 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonSecondaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullablePersonSecondaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Assignee? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Assignee Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullablePersonSecondaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullablePersonSecondaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullablePersonSecondaryResponseDocument and sets the default values. + /// + public NullablePersonSecondaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullablePersonSecondaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullablePersonSecondaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Assignee.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullablePersonSecondaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonSecondaryResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonSecondaryResponseDocument_meta.cs new file mode 100644 index 0000000000..c808b2d339 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullablePersonSecondaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullablePersonSecondaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullablePersonSecondaryResponseDocument_meta and sets the default values. + /// + public NullablePersonSecondaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullablePersonSecondaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullablePersonSecondaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInRequest.cs new file mode 100644 index 0000000000..40f20e00cf --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullableToOnePersonInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nullableToOnePersonInRequest and sets the default values. + /// + public NullableToOnePersonInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOnePersonInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOnePersonInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonIdentifier.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInResponse.cs new file mode 100644 index 0000000000..23fde34fc1 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullableToOnePersonInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOnePersonInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableToOnePersonInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableToOnePersonInResponse and sets the default values. + /// + public NullableToOnePersonInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOnePersonInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOnePersonInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableToOnePersonInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInResponse_meta.cs new file mode 100644 index 0000000000..b6c1eb7bd0 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/NullableToOnePersonInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class NullableToOnePersonInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableToOnePersonInResponse_meta and sets the default values. + /// + public NullableToOnePersonInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOnePersonInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOnePersonInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Owner.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Owner.cs new file mode 100644 index 0000000000..e9c38c5108 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Owner.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class Owner : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PersonAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Owner_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Owner_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PersonRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Owner CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Owner(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PersonAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Owner_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PersonRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Owner_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Owner_meta.cs new file mode 100644 index 0000000000..713ff1262c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Owner_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class Owner_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new owner_meta and sets the default values. + /// + public Owner_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Owner_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Owner_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/People.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/People.cs new file mode 100644 index 0000000000..c11a6184b2 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/People.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class People : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PersonAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public People_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public People_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PersonRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new People CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new People(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PersonAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(People_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PersonRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/People_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/People_meta.cs new file mode 100644 index 0000000000..52b4b85303 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/People_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class People_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new people_meta and sets the default values. + /// + public People_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static People_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new People_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInPatchRequest.cs new file mode 100644 index 0000000000..cdbbfc12e6 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInPatchRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The firstName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? FirstName { + get { return BackingStore?.Get("firstName"); } + set { BackingStore?.Set("firstName", value); } + } +#nullable restore +#else + public string FirstName { + get { return BackingStore?.Get("firstName"); } + set { BackingStore?.Set("firstName", value); } + } +#endif + /// The lastName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? LastName { + get { return BackingStore?.Get("lastName"); } + set { BackingStore?.Set("lastName", value); } + } +#nullable restore +#else + public string LastName { + get { return BackingStore?.Get("lastName"); } + set { BackingStore?.Set("lastName", value); } + } +#endif + /// + /// Instantiates a new personAttributesInPatchRequest and sets the default values. + /// + public PersonAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"firstName", n => { FirstName = n.GetStringValue(); } }, + {"lastName", n => { LastName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("firstName", FirstName); + writer.WriteStringValue("lastName", LastName); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInPostRequest.cs new file mode 100644 index 0000000000..d31d2f9e41 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInPostRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The firstName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? FirstName { + get { return BackingStore?.Get("firstName"); } + set { BackingStore?.Set("firstName", value); } + } +#nullable restore +#else + public string FirstName { + get { return BackingStore?.Get("firstName"); } + set { BackingStore?.Set("firstName", value); } + } +#endif + /// The lastName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? LastName { + get { return BackingStore?.Get("lastName"); } + set { BackingStore?.Set("lastName", value); } + } +#nullable restore +#else + public string LastName { + get { return BackingStore?.Get("lastName"); } + set { BackingStore?.Set("lastName", value); } + } +#endif + /// + /// Instantiates a new personAttributesInPostRequest and sets the default values. + /// + public PersonAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"firstName", n => { FirstName = n.GetStringValue(); } }, + {"lastName", n => { LastName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("firstName", FirstName); + writer.WriteStringValue("lastName", LastName); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInResponse.cs new file mode 100644 index 0000000000..f81b90c6a7 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonAttributesInResponse.cs @@ -0,0 +1,88 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The displayName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? DisplayName { + get { return BackingStore?.Get("displayName"); } + set { BackingStore?.Set("displayName", value); } + } +#nullable restore +#else + public string DisplayName { + get { return BackingStore?.Get("displayName"); } + set { BackingStore?.Set("displayName", value); } + } +#endif + /// The firstName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? FirstName { + get { return BackingStore?.Get("firstName"); } + set { BackingStore?.Set("firstName", value); } + } +#nullable restore +#else + public string FirstName { + get { return BackingStore?.Get("firstName"); } + set { BackingStore?.Set("firstName", value); } + } +#endif + /// The lastName property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? LastName { + get { return BackingStore?.Get("lastName"); } + set { BackingStore?.Set("lastName", value); } + } +#nullable restore +#else + public string LastName { + get { return BackingStore?.Get("lastName"); } + set { BackingStore?.Set("lastName", value); } + } +#endif + /// + /// Instantiates a new personAttributesInResponse and sets the default values. + /// + public PersonAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"displayName", n => { DisplayName = n.GetStringValue(); } }, + {"firstName", n => { FirstName = n.GetStringValue(); } }, + {"lastName", n => { LastName = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("firstName", FirstName); + writer.WriteStringValue("lastName", LastName); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonCollectionResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonCollectionResponseDocument.cs new file mode 100644 index 0000000000..5821b24249 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PersonCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new personCollectionResponseDocument and sets the default values. + /// + public PersonCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(PersonDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PersonCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonCollectionResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..a6e72b953e --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new personCollectionResponseDocument_meta and sets the default values. + /// + public PersonCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInPatchRequest.cs new file mode 100644 index 0000000000..3f7182b787 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PersonAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PersonRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public PersonResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new personDataInPatchRequest and sets the default values. + /// + public PersonDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(PersonAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PersonRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInPostRequest.cs new file mode 100644 index 0000000000..b90f42e2d7 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PersonAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PersonRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public PersonResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new personDataInPostRequest and sets the default values. + /// + public PersonDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(PersonAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PersonRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInResponse.cs new file mode 100644 index 0000000000..b91357f51c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public PersonAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PersonDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public PersonRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new PersonDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(PersonAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PersonDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(PersonRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInResponse_meta.cs new file mode 100644 index 0000000000..46f27f4085 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new personDataInResponse_meta and sets the default values. + /// + public PersonDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifier.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifier.cs new file mode 100644 index 0000000000..e1f922395b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public PersonResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new personIdentifier and sets the default values. + /// + public PersonIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifierResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifierResponseDocument.cs new file mode 100644 index 0000000000..7446c07686 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifierResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonIdentifierResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifierResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PersonIdentifierResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new personIdentifierResponseDocument and sets the default values. + /// + public PersonIdentifierResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonIdentifierResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PersonIdentifierResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifierResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifierResponseDocument_meta.cs new file mode 100644 index 0000000000..a9d57224e8 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonIdentifierResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonIdentifierResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new personIdentifierResponseDocument_meta and sets the default values. + /// + public PersonIdentifierResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonIdentifierResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonIdentifierResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPatchRequestDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPatchRequestDocument.cs new file mode 100644 index 0000000000..ef4fa007fd --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonPatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new personPatchRequestDocument and sets the default values. + /// + public PersonPatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonPatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonPatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPostRequestDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPostRequestDocument.cs new file mode 100644 index 0000000000..a2665facbe --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new personPostRequestDocument and sets the default values. + /// + public PersonPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPrimaryResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPrimaryResponseDocument.cs new file mode 100644 index 0000000000..bceff988c4 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public People? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public People Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PersonPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new personPrimaryResponseDocument and sets the default values. + /// + public PersonPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(People.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PersonPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPrimaryResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..60505524e1 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new personPrimaryResponseDocument_meta and sets the default values. + /// + public PersonPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..dc2bacc7af --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInPatchRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonRelationshipsInPatchRequest : IBackedModel, IParsable { + /// The assignedTodoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInRequest? AssignedTodoItems { + get { return BackingStore?.Get("assignedTodoItems"); } + set { BackingStore?.Set("assignedTodoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInRequest AssignedTodoItems { + get { return BackingStore?.Get("assignedTodoItems"); } + set { BackingStore?.Set("assignedTodoItems", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ownedTodoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInRequest? OwnedTodoItems { + get { return BackingStore?.Get("ownedTodoItems"); } + set { BackingStore?.Set("ownedTodoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInRequest OwnedTodoItems { + get { return BackingStore?.Get("ownedTodoItems"); } + set { BackingStore?.Set("ownedTodoItems", value); } + } +#endif + /// + /// Instantiates a new personRelationshipsInPatchRequest and sets the default values. + /// + public PersonRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"assignedTodoItems", n => { AssignedTodoItems = n.GetObjectValue(ToManyTodoItemInRequest.CreateFromDiscriminatorValue); } }, + {"ownedTodoItems", n => { OwnedTodoItems = n.GetObjectValue(ToManyTodoItemInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("assignedTodoItems", AssignedTodoItems); + writer.WriteObjectValue("ownedTodoItems", OwnedTodoItems); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..7871129b09 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInPostRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonRelationshipsInPostRequest : IBackedModel, IParsable { + /// The assignedTodoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInRequest? AssignedTodoItems { + get { return BackingStore?.Get("assignedTodoItems"); } + set { BackingStore?.Set("assignedTodoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInRequest AssignedTodoItems { + get { return BackingStore?.Get("assignedTodoItems"); } + set { BackingStore?.Set("assignedTodoItems", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ownedTodoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInRequest? OwnedTodoItems { + get { return BackingStore?.Get("ownedTodoItems"); } + set { BackingStore?.Set("ownedTodoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInRequest OwnedTodoItems { + get { return BackingStore?.Get("ownedTodoItems"); } + set { BackingStore?.Set("ownedTodoItems", value); } + } +#endif + /// + /// Instantiates a new personRelationshipsInPostRequest and sets the default values. + /// + public PersonRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"assignedTodoItems", n => { AssignedTodoItems = n.GetObjectValue(ToManyTodoItemInRequest.CreateFromDiscriminatorValue); } }, + {"ownedTodoItems", n => { OwnedTodoItems = n.GetObjectValue(ToManyTodoItemInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("assignedTodoItems", AssignedTodoItems); + writer.WriteObjectValue("ownedTodoItems", OwnedTodoItems); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInResponse.cs new file mode 100644 index 0000000000..bf369c9f21 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonRelationshipsInResponse.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonRelationshipsInResponse : IBackedModel, IParsable { + /// The assignedTodoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInResponse? AssignedTodoItems { + get { return BackingStore?.Get("assignedTodoItems"); } + set { BackingStore?.Set("assignedTodoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInResponse AssignedTodoItems { + get { return BackingStore?.Get("assignedTodoItems"); } + set { BackingStore?.Set("assignedTodoItems", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The ownedTodoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInResponse? OwnedTodoItems { + get { return BackingStore?.Get("ownedTodoItems"); } + set { BackingStore?.Set("ownedTodoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInResponse OwnedTodoItems { + get { return BackingStore?.Get("ownedTodoItems"); } + set { BackingStore?.Set("ownedTodoItems", value); } + } +#endif + /// + /// Instantiates a new personRelationshipsInResponse and sets the default values. + /// + public PersonRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"assignedTodoItems", n => { AssignedTodoItems = n.GetObjectValue(ToManyTodoItemInResponse.CreateFromDiscriminatorValue); } }, + {"ownedTodoItems", n => { OwnedTodoItems = n.GetObjectValue(ToManyTodoItemInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("assignedTodoItems", AssignedTodoItems); + writer.WriteObjectValue("ownedTodoItems", OwnedTodoItems); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonResourceType.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonResourceType.cs new file mode 100644 index 0000000000..a1ae340a9d --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public enum PersonResourceType { + [EnumMember(Value = "people")] + People, + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonSecondaryResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonSecondaryResponseDocument.cs new file mode 100644 index 0000000000..0cbb879924 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonSecondaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonSecondaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Owner? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Owner Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonSecondaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public PersonSecondaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new personSecondaryResponseDocument and sets the default values. + /// + public PersonSecondaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonSecondaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonSecondaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Owner.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(PersonSecondaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonSecondaryResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonSecondaryResponseDocument_meta.cs new file mode 100644 index 0000000000..a3e70a464d --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/PersonSecondaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class PersonSecondaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new personSecondaryResponseDocument_meta and sets the default values. + /// + public PersonSecondaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static PersonSecondaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new PersonSecondaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInPatchRequest.cs new file mode 100644 index 0000000000..6cce0f203b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInPatchRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new tagAttributesInPatchRequest and sets the default values. + /// + public TagAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInPostRequest.cs new file mode 100644 index 0000000000..05ca4b686c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new tagAttributesInPostRequest and sets the default values. + /// + public TagAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInResponse.cs new file mode 100644 index 0000000000..86dd11bd3c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagAttributesInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new tagAttributesInResponse and sets the default values. + /// + public TagAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagCollectionResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagCollectionResponseDocument.cs new file mode 100644 index 0000000000..645211b54c --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TagCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new tagCollectionResponseDocument and sets the default values. + /// + public TagCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TagDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TagCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagCollectionResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..6aa6954649 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new tagCollectionResponseDocument_meta and sets the default values. + /// + public TagCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInPatchRequest.cs new file mode 100644 index 0000000000..5c2693a63d --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TagAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TagRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public TagResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new tagDataInPatchRequest and sets the default values. + /// + public TagDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(TagAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TagRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInPostRequest.cs new file mode 100644 index 0000000000..252dcc46c1 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TagAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TagRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public TagResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new tagDataInPostRequest and sets the default values. + /// + public TagDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(TagAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TagRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInResponse.cs new file mode 100644 index 0000000000..42d529b36f --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TagAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TagDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TagRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new TagDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(TagAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TagDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TagRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInResponse_meta.cs new file mode 100644 index 0000000000..4f4c727375 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new tagDataInResponse_meta and sets the default values. + /// + public TagDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifier.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifier.cs new file mode 100644 index 0000000000..52bbf8d902 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public TagResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new tagIdentifier and sets the default values. + /// + public TagIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifierCollectionResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..33c43abc2d --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifierCollectionResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagIdentifierCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagIdentifierCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TagIdentifierCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new tagIdentifierCollectionResponseDocument and sets the default values. + /// + public TagIdentifierCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagIdentifierCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TagIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TagIdentifierCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifierCollectionResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifierCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..3e3158fd20 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagIdentifierCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagIdentifierCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new tagIdentifierCollectionResponseDocument_meta and sets the default values. + /// + public TagIdentifierCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagIdentifierCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagIdentifierCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPatchRequestDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPatchRequestDocument.cs new file mode 100644 index 0000000000..568d9f94fd --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagPatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public TagDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new tagPatchRequestDocument and sets the default values. + /// + public TagPatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagPatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagPatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(TagDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPostRequestDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPostRequestDocument.cs new file mode 100644 index 0000000000..c0e15652a7 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public TagDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new tagPostRequestDocument and sets the default values. + /// + public TagPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(TagDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPrimaryResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPrimaryResponseDocument.cs new file mode 100644 index 0000000000..63d111046d --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Tags? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Tags Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TagPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new tagPrimaryResponseDocument and sets the default values. + /// + public TagPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Tags.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TagPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPrimaryResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..428f81aa4b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new tagPrimaryResponseDocument_meta and sets the default values. + /// + public TagPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..a3282535e6 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInPatchRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagRelationshipsInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The todoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInRequest? TodoItems { + get { return BackingStore?.Get("todoItems"); } + set { BackingStore?.Set("todoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInRequest TodoItems { + get { return BackingStore?.Get("todoItems"); } + set { BackingStore?.Set("todoItems", value); } + } +#endif + /// + /// Instantiates a new tagRelationshipsInPatchRequest and sets the default values. + /// + public TagRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"todoItems", n => { TodoItems = n.GetObjectValue(ToManyTodoItemInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("todoItems", TodoItems); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..dd5a03aefd --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagRelationshipsInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The todoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInRequest? TodoItems { + get { return BackingStore?.Get("todoItems"); } + set { BackingStore?.Set("todoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInRequest TodoItems { + get { return BackingStore?.Get("todoItems"); } + set { BackingStore?.Set("todoItems", value); } + } +#endif + /// + /// Instantiates a new tagRelationshipsInPostRequest and sets the default values. + /// + public TagRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"todoItems", n => { TodoItems = n.GetObjectValue(ToManyTodoItemInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("todoItems", TodoItems); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInResponse.cs new file mode 100644 index 0000000000..11e7934ad6 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagRelationshipsInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TagRelationshipsInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The todoItems property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInResponse? TodoItems { + get { return BackingStore?.Get("todoItems"); } + set { BackingStore?.Set("todoItems", value); } + } +#nullable restore +#else + public ToManyTodoItemInResponse TodoItems { + get { return BackingStore?.Get("todoItems"); } + set { BackingStore?.Set("todoItems", value); } + } +#endif + /// + /// Instantiates a new tagRelationshipsInResponse and sets the default values. + /// + public TagRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TagRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TagRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"todoItems", n => { TodoItems = n.GetObjectValue(ToManyTodoItemInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("todoItems", TodoItems); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagResourceType.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagResourceType.cs new file mode 100644 index 0000000000..1489c0f039 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TagResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public enum TagResourceType { + [EnumMember(Value = "tags")] + Tags, + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Tags.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Tags.cs new file mode 100644 index 0000000000..e4454f9087 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Tags.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class Tags : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TagAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Tags_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Tags_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TagRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TagRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Tags CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Tags(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(TagAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Tags_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TagRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Tags_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Tags_meta.cs new file mode 100644 index 0000000000..f3b74162a6 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/Tags_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class Tags_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new tags_meta and sets the default values. + /// + public Tags_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Tags_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Tags_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInRequest.cs new file mode 100644 index 0000000000..1e788e6ec1 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToManyTagInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyTagInRequest and sets the default values. + /// + public ToManyTagInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyTagInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyTagInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TagIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInResponse.cs new file mode 100644 index 0000000000..68d7a927ca --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToManyTagInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTagInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyTagInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyTagInResponse and sets the default values. + /// + public ToManyTagInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyTagInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyTagInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TagIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyTagInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInResponse_meta.cs new file mode 100644 index 0000000000..f1654dca85 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTagInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToManyTagInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyTagInResponse_meta and sets the default values. + /// + public ToManyTagInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyTagInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyTagInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInRequest.cs new file mode 100644 index 0000000000..c4b93e065f --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToManyTodoItemInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyTodoItemInRequest and sets the default values. + /// + public ToManyTodoItemInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyTodoItemInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyTodoItemInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TodoItemIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInResponse.cs new file mode 100644 index 0000000000..a53c7a0c5a --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToManyTodoItemInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTodoItemInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyTodoItemInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyTodoItemInResponse and sets the default values. + /// + public ToManyTodoItemInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyTodoItemInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyTodoItemInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TodoItemIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyTodoItemInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInResponse_meta.cs new file mode 100644 index 0000000000..95feb33b8b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToManyTodoItemInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToManyTodoItemInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyTodoItemInResponse_meta and sets the default values. + /// + public ToManyTodoItemInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyTodoItemInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyTodoItemInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInRequest.cs new file mode 100644 index 0000000000..cc12e18212 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToOnePersonInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toOnePersonInRequest and sets the default values. + /// + public ToOnePersonInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOnePersonInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOnePersonInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonIdentifier.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInResponse.cs new file mode 100644 index 0000000000..14e4db99bb --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToOnePersonInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public PersonIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public PersonIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOnePersonInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToOnePersonInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toOnePersonInResponse and sets the default values. + /// + public ToOnePersonInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOnePersonInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOnePersonInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(PersonIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToOnePersonInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInResponse_meta.cs new file mode 100644 index 0000000000..3c2c541d83 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/ToOnePersonInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class ToOnePersonInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toOnePersonInResponse_meta and sets the default values. + /// + public ToOnePersonInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOnePersonInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOnePersonInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInPatchRequest.cs new file mode 100644 index 0000000000..31a441e693 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInPatchRequest.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The description property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Description { + get { return BackingStore?.Get("description"); } + set { BackingStore?.Set("description", value); } + } +#nullable restore +#else + public string Description { + get { return BackingStore?.Get("description"); } + set { BackingStore?.Set("description", value); } + } +#endif + /// The durationInHours property + public long? DurationInHours { + get { return BackingStore?.Get("durationInHours"); } + set { BackingStore?.Set("durationInHours", value); } + } + /// The priority property + public TodoItemPriority? Priority { + get { return BackingStore?.Get("priority"); } + set { BackingStore?.Set("priority", value); } + } + /// + /// Instantiates a new todoItemAttributesInPatchRequest and sets the default values. + /// + public TodoItemAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"description", n => { Description = n.GetStringValue(); } }, + {"durationInHours", n => { DurationInHours = n.GetLongValue(); } }, + {"priority", n => { Priority = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("description", Description); + writer.WriteLongValue("durationInHours", DurationInHours); + writer.WriteEnumValue("priority", Priority); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInPostRequest.cs new file mode 100644 index 0000000000..fa4593280b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInPostRequest.cs @@ -0,0 +1,71 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The description property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Description { + get { return BackingStore?.Get("description"); } + set { BackingStore?.Set("description", value); } + } +#nullable restore +#else + public string Description { + get { return BackingStore?.Get("description"); } + set { BackingStore?.Set("description", value); } + } +#endif + /// The durationInHours property + public long? DurationInHours { + get { return BackingStore?.Get("durationInHours"); } + set { BackingStore?.Set("durationInHours", value); } + } + /// The priority property + public TodoItemPriority? Priority { + get { return BackingStore?.Get("priority"); } + set { BackingStore?.Set("priority", value); } + } + /// + /// Instantiates a new todoItemAttributesInPostRequest and sets the default values. + /// + public TodoItemAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"description", n => { Description = n.GetStringValue(); } }, + {"durationInHours", n => { DurationInHours = n.GetLongValue(); } }, + {"priority", n => { Priority = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("description", Description); + writer.WriteLongValue("durationInHours", DurationInHours); + writer.WriteEnumValue("priority", Priority); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInResponse.cs new file mode 100644 index 0000000000..4011559de5 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemAttributesInResponse.cs @@ -0,0 +1,85 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The createdAt property + public DateTimeOffset? CreatedAt { + get { return BackingStore?.Get("createdAt"); } + set { BackingStore?.Set("createdAt", value); } + } + /// The description property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Description { + get { return BackingStore?.Get("description"); } + set { BackingStore?.Set("description", value); } + } +#nullable restore +#else + public string Description { + get { return BackingStore?.Get("description"); } + set { BackingStore?.Set("description", value); } + } +#endif + /// The durationInHours property + public long? DurationInHours { + get { return BackingStore?.Get("durationInHours"); } + set { BackingStore?.Set("durationInHours", value); } + } + /// The modifiedAt property + public DateTimeOffset? ModifiedAt { + get { return BackingStore?.Get("modifiedAt"); } + set { BackingStore?.Set("modifiedAt", value); } + } + /// The priority property + public TodoItemPriority? Priority { + get { return BackingStore?.Get("priority"); } + set { BackingStore?.Set("priority", value); } + } + /// + /// Instantiates a new todoItemAttributesInResponse and sets the default values. + /// + public TodoItemAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"createdAt", n => { CreatedAt = n.GetDateTimeOffsetValue(); } }, + {"description", n => { Description = n.GetStringValue(); } }, + {"durationInHours", n => { DurationInHours = n.GetLongValue(); } }, + {"modifiedAt", n => { ModifiedAt = n.GetDateTimeOffsetValue(); } }, + {"priority", n => { Priority = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteDateTimeOffsetValue("createdAt", CreatedAt); + writer.WriteStringValue("description", Description); + writer.WriteLongValue("durationInHours", DurationInHours); + writer.WriteDateTimeOffsetValue("modifiedAt", ModifiedAt); + writer.WriteEnumValue("priority", Priority); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemCollectionResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemCollectionResponseDocument.cs new file mode 100644 index 0000000000..eeb262fb88 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TodoItemCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new todoItemCollectionResponseDocument and sets the default values. + /// + public TodoItemCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TodoItemDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TodoItemCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemCollectionResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..f94d9991f4 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new todoItemCollectionResponseDocument_meta and sets the default values. + /// + public TodoItemCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInPatchRequest.cs new file mode 100644 index 0000000000..247d830fd9 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TodoItemAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TodoItemRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public TodoItemResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new todoItemDataInPatchRequest and sets the default values. + /// + public TodoItemDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(TodoItemAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TodoItemRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInPostRequest.cs new file mode 100644 index 0000000000..20e30a15eb --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TodoItemAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TodoItemRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public TodoItemResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new todoItemDataInPostRequest and sets the default values. + /// + public TodoItemDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(TodoItemAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TodoItemRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInResponse.cs new file mode 100644 index 0000000000..86ae33ca73 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TodoItemAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TodoItemDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TodoItemRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new TodoItemDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(TodoItemAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TodoItemDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TodoItemRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInResponse_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInResponse_meta.cs new file mode 100644 index 0000000000..d31743d051 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new todoItemDataInResponse_meta and sets the default values. + /// + public TodoItemDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifier.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifier.cs new file mode 100644 index 0000000000..369e2c49d6 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public TodoItemResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new todoItemIdentifier and sets the default values. + /// + public TodoItemIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifierCollectionResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..4fb118bbc9 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifierCollectionResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemIdentifierCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemIdentifierCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TodoItemIdentifierCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new todoItemIdentifierCollectionResponseDocument and sets the default values. + /// + public TodoItemIdentifierCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemIdentifierCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(TodoItemIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TodoItemIdentifierCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifierCollectionResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifierCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..0fec21a2cc --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemIdentifierCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemIdentifierCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new todoItemIdentifierCollectionResponseDocument_meta and sets the default values. + /// + public TodoItemIdentifierCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemIdentifierCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemIdentifierCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPatchRequestDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPatchRequestDocument.cs new file mode 100644 index 0000000000..1d2680602b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemPatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public TodoItemDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new todoItemPatchRequestDocument and sets the default values. + /// + public TodoItemPatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemPatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemPatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(TodoItemDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPostRequestDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPostRequestDocument.cs new file mode 100644 index 0000000000..c0ae64bcdd --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public TodoItemDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new todoItemPostRequestDocument and sets the default values. + /// + public TodoItemPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(TodoItemDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPrimaryResponseDocument.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPrimaryResponseDocument.cs new file mode 100644 index 0000000000..035d354623 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItems? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public TodoItems Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TodoItemPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new todoItemPrimaryResponseDocument and sets the default values. + /// + public TodoItemPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(TodoItems.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TodoItemPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPrimaryResponseDocument_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..74d5113c20 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new todoItemPrimaryResponseDocument_meta and sets the default values. + /// + public TodoItemPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPriority.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPriority.cs new file mode 100644 index 0000000000..19e9f4850a --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemPriority.cs @@ -0,0 +1,13 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public enum TodoItemPriority { + [EnumMember(Value = "High")] + High, + [EnumMember(Value = "Medium")] + Medium, + [EnumMember(Value = "Low")] + Low, + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInPatchRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..9078b07a50 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInPatchRequest.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemRelationshipsInPatchRequest : IBackedModel, IParsable { + /// The assignee property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOnePersonInRequest? Assignee { + get { return BackingStore?.Get("assignee"); } + set { BackingStore?.Set("assignee", value); } + } +#nullable restore +#else + public NullableToOnePersonInRequest Assignee { + get { return BackingStore?.Get("assignee"); } + set { BackingStore?.Set("assignee", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The owner property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOnePersonInRequest? Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#nullable restore +#else + public ToOnePersonInRequest Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#endif + /// The tags property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTagInRequest? Tags { + get { return BackingStore?.Get("tags"); } + set { BackingStore?.Set("tags", value); } + } +#nullable restore +#else + public ToManyTagInRequest Tags { + get { return BackingStore?.Get("tags"); } + set { BackingStore?.Set("tags", value); } + } +#endif + /// + /// Instantiates a new todoItemRelationshipsInPatchRequest and sets the default values. + /// + public TodoItemRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"assignee", n => { Assignee = n.GetObjectValue(NullableToOnePersonInRequest.CreateFromDiscriminatorValue); } }, + {"owner", n => { Owner = n.GetObjectValue(ToOnePersonInRequest.CreateFromDiscriminatorValue); } }, + {"tags", n => { Tags = n.GetObjectValue(ToManyTagInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("assignee", Assignee); + writer.WriteObjectValue("owner", Owner); + writer.WriteObjectValue("tags", Tags); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInPostRequest.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..2ca677b2c0 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInPostRequest.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemRelationshipsInPostRequest : IBackedModel, IParsable { + /// The assignee property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOnePersonInRequest? Assignee { + get { return BackingStore?.Get("assignee"); } + set { BackingStore?.Set("assignee", value); } + } +#nullable restore +#else + public NullableToOnePersonInRequest Assignee { + get { return BackingStore?.Get("assignee"); } + set { BackingStore?.Set("assignee", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The owner property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOnePersonInRequest? Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#nullable restore +#else + public ToOnePersonInRequest Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#endif + /// The tags property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTagInRequest? Tags { + get { return BackingStore?.Get("tags"); } + set { BackingStore?.Set("tags", value); } + } +#nullable restore +#else + public ToManyTagInRequest Tags { + get { return BackingStore?.Get("tags"); } + set { BackingStore?.Set("tags", value); } + } +#endif + /// + /// Instantiates a new todoItemRelationshipsInPostRequest and sets the default values. + /// + public TodoItemRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"assignee", n => { Assignee = n.GetObjectValue(NullableToOnePersonInRequest.CreateFromDiscriminatorValue); } }, + {"owner", n => { Owner = n.GetObjectValue(ToOnePersonInRequest.CreateFromDiscriminatorValue); } }, + {"tags", n => { Tags = n.GetObjectValue(ToManyTagInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("assignee", Assignee); + writer.WriteObjectValue("owner", Owner); + writer.WriteObjectValue("tags", Tags); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInResponse.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInResponse.cs new file mode 100644 index 0000000000..b7f5b014bc --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemRelationshipsInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItemRelationshipsInResponse : IBackedModel, IParsable { + /// The assignee property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOnePersonInResponse? Assignee { + get { return BackingStore?.Get("assignee"); } + set { BackingStore?.Set("assignee", value); } + } +#nullable restore +#else + public NullableToOnePersonInResponse Assignee { + get { return BackingStore?.Get("assignee"); } + set { BackingStore?.Set("assignee", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The owner property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOnePersonInResponse? Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#nullable restore +#else + public ToOnePersonInResponse Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#endif + /// The tags property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyTagInResponse? Tags { + get { return BackingStore?.Get("tags"); } + set { BackingStore?.Set("tags", value); } + } +#nullable restore +#else + public ToManyTagInResponse Tags { + get { return BackingStore?.Get("tags"); } + set { BackingStore?.Set("tags", value); } + } +#endif + /// + /// Instantiates a new todoItemRelationshipsInResponse and sets the default values. + /// + public TodoItemRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItemRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItemRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"assignee", n => { Assignee = n.GetObjectValue(NullableToOnePersonInResponse.CreateFromDiscriminatorValue); } }, + {"owner", n => { Owner = n.GetObjectValue(ToOnePersonInResponse.CreateFromDiscriminatorValue); } }, + {"tags", n => { Tags = n.GetObjectValue(ToManyTagInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("assignee", Assignee); + writer.WriteObjectValue("owner", Owner); + writer.WriteObjectValue("tags", Tags); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemResourceType.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemResourceType.cs new file mode 100644 index 0000000000..9820e2b336 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItemResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public enum TodoItemResourceType { + [EnumMember(Value = "todoItems")] + TodoItems, + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItems.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItems.cs new file mode 100644 index 0000000000..2f2163761b --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItems.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItems : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public TodoItemAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItems_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public TodoItems_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public TodoItemRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public TodoItemRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new TodoItems CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItems(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(TodoItemAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(TodoItems_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(TodoItemRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItems_meta.cs b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItems_meta.cs new file mode 100644 index 0000000000..f0e8773ff8 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/GeneratedCode/Models/TodoItems_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaClientExample.GeneratedCode.Models { + public class TodoItems_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new todoItems_meta and sets the default values. + /// + public TodoItems_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static TodoItems_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new TodoItems_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/OpenApiKiotaClientExample.csproj b/src/Examples/OpenApiKiotaClientExample/OpenApiKiotaClientExample.csproj new file mode 100644 index 0000000000..220acaedf5 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/OpenApiKiotaClientExample.csproj @@ -0,0 +1,40 @@ + + + net8.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/src/Examples/OpenApiKiotaClientExample/PeopleMessageFormatter.cs b/src/Examples/OpenApiKiotaClientExample/PeopleMessageFormatter.cs new file mode 100644 index 0000000000..be69942aec --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/PeopleMessageFormatter.cs @@ -0,0 +1,65 @@ +using System.Text; +using JetBrains.Annotations; +using OpenApiKiotaClientExample.GeneratedCode.Models; + +namespace OpenApiKiotaClientExample; + +/// +/// Prints the specified people, their assigned todo-items, and its tags. +/// +[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] +internal sealed class PeopleMessageFormatter +{ + public static void PrintPeople(PersonCollectionResponseDocument? peopleResponse) + { + string message = WritePeople(peopleResponse); + Console.WriteLine(message); + } + + private static string WritePeople(PersonCollectionResponseDocument? peopleResponse) + { + if (peopleResponse == null) + { + return "The HTTP response hasn't changed, so no response body was returned."; + } + + var builder = new StringBuilder(); + builder.AppendLine($"Found {peopleResponse.Data!.Count} people:"); + + foreach (PersonDataInResponse person in peopleResponse.Data) + { + WritePerson(person, peopleResponse.Included!, builder); + } + + return builder.ToString(); + } + + private static void WritePerson(PersonDataInResponse person, ICollection includes, StringBuilder builder) + { + ToManyTodoItemInResponse assignedTodoItems = person.Relationships!.AssignedTodoItems!; + + builder.AppendLine($" Person {person.Id}: {person.Attributes!.DisplayName} with {assignedTodoItems.Data!.Count} assigned todo-items:"); + WriteRelatedTodoItems(assignedTodoItems.Data, includes, builder); + } + + private static void WriteRelatedTodoItems(IEnumerable todoItemIdentifiers, ICollection includes, StringBuilder builder) + { + foreach (TodoItemIdentifier todoItemIdentifier in todoItemIdentifiers) + { + TodoItemDataInResponse includedTodoItem = includes.OfType().Single(include => include.Id == todoItemIdentifier.Id); + ToManyTagInResponse tags = includedTodoItem.Relationships!.Tags!; + + builder.AppendLine($" TodoItem {includedTodoItem.Id}: {includedTodoItem.Attributes!.Description} with {tags.Data!.Count} tags:"); + WriteRelatedTags(tags.Data, includes, builder); + } + } + + private static void WriteRelatedTags(IEnumerable tagIdentifiers, ICollection includes, StringBuilder builder) + { + foreach (TagIdentifier tagIdentifier in tagIdentifiers) + { + TagDataInResponse includedTag = includes.OfType().Single(include => include.Id == tagIdentifier.Id); + builder.AppendLine($" Tag {includedTag.Id}: {includedTag.Attributes!.Name}"); + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/Program.cs b/src/Examples/OpenApiKiotaClientExample/Program.cs new file mode 100644 index 0000000000..2716335282 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/Program.cs @@ -0,0 +1,37 @@ +using JsonApiDotNetCore.OpenApi.Client.Kiota; +using Microsoft.Kiota.Abstractions.Authentication; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaClientExample; +using OpenApiKiotaClientExample.GeneratedCode; + +HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); +builder.Services.AddLogging(options => options.ClearProviders()); +builder.Services.AddHostedService(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); +builder.Services.AddSingleton(); + +// @formatter:wrap_chained_method_calls chop_always +builder.Services.AddHttpClient() + .ConfigurePrimaryHttpMessageHandler(_ => + { + IList defaultHandlers = KiotaClientFactory.CreateDefaultHandlers(); + HttpMessageHandler defaultHttpMessageHandler = KiotaClientFactory.GetDefaultHttpMessageHandler(); + + // Or, if your generated client is long-lived, respond to DNS updates using: + // HttpMessageHandler defaultHttpMessageHandler = new SocketsHttpHandler(); + + return KiotaClientFactory.ChainHandlersCollectionAndGetFirstLink(defaultHttpMessageHandler, defaultHandlers.ToArray())!; + }) + .AddHttpMessageHandler() + .AddHttpMessageHandler() + .AddTypedClient((httpClient, serviceProvider) => + { + var authenticationProvider = serviceProvider.GetRequiredService(); + var requestAdapter = new HttpClientRequestAdapter(authenticationProvider, httpClient: httpClient); + return new ExampleApiClient(requestAdapter); + }); +// @formatter:wrap_chained_method_calls restore + +IHost host = builder.Build(); +await host.RunAsync(); diff --git a/src/Examples/OpenApiKiotaClientExample/Properties/launchSettings.json b/src/Examples/OpenApiKiotaClientExample/Properties/launchSettings.json new file mode 100644 index 0000000000..afb5e5dac4 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "Kestrel": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/Worker.cs b/src/Examples/OpenApiKiotaClientExample/Worker.cs new file mode 100644 index 0000000000..05b6f597f4 --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/Worker.cs @@ -0,0 +1,101 @@ +using System.Net; +using JsonApiDotNetCore.OpenApi.Client.Kiota; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Http.HttpClientLibrary.Middleware.Options; +using OpenApiKiotaClientExample.GeneratedCode; +using OpenApiKiotaClientExample.GeneratedCode.Models; + +namespace OpenApiKiotaClientExample; + +public sealed class Worker(ExampleApiClient apiClient, IHostApplicationLifetime hostApplicationLifetime, SetQueryStringHttpMessageHandler queryStringHandler) + : BackgroundService +{ + private readonly ExampleApiClient _apiClient = apiClient; + private readonly IHostApplicationLifetime _hostApplicationLifetime = hostApplicationLifetime; + private readonly SetQueryStringHttpMessageHandler _queryStringHandler = queryStringHandler; + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + try + { + using (_queryStringHandler.CreateScope(new Dictionary + { + // Workaround for https://github.com/microsoft/kiota/issues/3800. + ["filter"] = "has(assignedTodoItems)", + ["sort"] = "-lastName", + ["page[size]"] = "5", + ["include"] = "assignedTodoItems.tags" + })) + { + (PersonCollectionResponseDocument? getResponse, string? eTag) = await GetPeopleAsync(_apiClient, null, stoppingToken); + PeopleMessageFormatter.PrintPeople(getResponse); + + (PersonCollectionResponseDocument? getResponseAgain, _) = await GetPeopleAsync(_apiClient, eTag, stoppingToken); + PeopleMessageFormatter.PrintPeople(getResponseAgain); + } + + await UpdatePersonAsync(stoppingToken); + + _ = await _apiClient.Api.People["999999"].GetAsync(cancellationToken: stoppingToken); + } + catch (ErrorResponseDocument exception) + { + Console.WriteLine($"JSON:API ERROR: {exception.Errors!.First().Detail}"); + } + catch (HttpRequestException exception) + { + Console.WriteLine($"ERROR: {exception.Message}"); + } + + _hostApplicationLifetime.StopApplication(); + } + + private async Task<(PersonCollectionResponseDocument? response, string? eTag)> GetPeopleAsync(ExampleApiClient apiClient, string? ifNoneMatch, + CancellationToken cancellationToken) + { + try + { + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + PersonCollectionResponseDocument? responseDocument = await apiClient.Api.People.GetAsync(configuration => + { + if (!string.IsNullOrEmpty(ifNoneMatch)) + { + configuration.Headers.Add("If-None-Match", ifNoneMatch); + } + + configuration.Options.Add(headerInspector); + }, cancellationToken); + + string eTag = headerInspector.ResponseHeaders["ETag"].Single(); + + return (responseDocument, eTag); + } + // Workaround for https://github.com/microsoft/kiota/issues/4190. + catch (ApiException exception) when (exception.ResponseStatusCode == (int)HttpStatusCode.NotModified) + { + return (null, null); + } + } + + private async Task UpdatePersonAsync(CancellationToken cancellationToken) + { + var patchRequest = new PersonPatchRequestDocument + { + Data = new PersonDataInPatchRequest + { + Type = PersonResourceType.People, + Id = "1", + Attributes = new PersonAttributesInPatchRequest + { + LastName = "Doe" + } + } + }; + + _ = await _apiClient.Api.People[patchRequest.Data.Id].PatchAsync(patchRequest, cancellationToken: cancellationToken); + } +} diff --git a/src/Examples/OpenApiKiotaClientExample/appsettings.json b/src/Examples/OpenApiKiotaClientExample/appsettings.json new file mode 100644 index 0000000000..2b94cdb46d --- /dev/null +++ b/src/Examples/OpenApiKiotaClientExample/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System.Net.Http.HttpClient": "Information" + } + } +} diff --git a/src/Examples/OpenApiNSwagClientExample/ColoredConsoleLogHttpMessageHandler.cs b/src/Examples/OpenApiNSwagClientExample/ColoredConsoleLogHttpMessageHandler.cs new file mode 100644 index 0000000000..d999a7d9bf --- /dev/null +++ b/src/Examples/OpenApiNSwagClientExample/ColoredConsoleLogHttpMessageHandler.cs @@ -0,0 +1,67 @@ +using JetBrains.Annotations; + +namespace OpenApiNSwagClientExample; + +/// +/// Writes incoming and outgoing HTTP messages to the console. +/// +internal sealed class ColoredConsoleLogHttpMessageHandler : DelegatingHandler +{ + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { +#if DEBUG + await LogRequestAsync(request, cancellationToken); +#endif + + HttpResponseMessage response = await base.SendAsync(request, cancellationToken); + +#if DEBUG + await LogResponseAsync(response, cancellationToken); +#endif + + return response; + } + + [UsedImplicitly] + private static async Task LogRequestAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + using var _ = new ConsoleColorScope(ConsoleColor.Green); + + Console.WriteLine($"--> {request}"); + string? requestBody = request.Content != null ? await request.Content.ReadAsStringAsync(cancellationToken) : null; + + if (!string.IsNullOrEmpty(requestBody)) + { + Console.WriteLine(); + Console.WriteLine(requestBody); + } + } + + [UsedImplicitly] + private static async Task LogResponseAsync(HttpResponseMessage response, CancellationToken cancellationToken) + { + using var _ = new ConsoleColorScope(ConsoleColor.Cyan); + + Console.WriteLine($"<-- {response}"); + string responseBody = await response.Content.ReadAsStringAsync(cancellationToken); + + if (!string.IsNullOrEmpty(responseBody)) + { + Console.WriteLine(); + Console.WriteLine(responseBody); + } + } + + private sealed class ConsoleColorScope : IDisposable + { + public ConsoleColorScope(ConsoleColor foregroundColor) + { + Console.ForegroundColor = foregroundColor; + } + + public void Dispose() + { + Console.ResetColor(); + } + } +} diff --git a/src/Examples/JsonApiDotNetCoreExampleClient/ExampleApiClient.cs b/src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs similarity index 81% rename from src/Examples/JsonApiDotNetCoreExampleClient/ExampleApiClient.cs rename to src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs index e55e79d97e..c60fb8f50f 100644 --- a/src/Examples/JsonApiDotNetCoreExampleClient/ExampleApiClient.cs +++ b/src/Examples/OpenApiNSwagClientExample/ExampleApiClient.cs @@ -1,8 +1,8 @@ using JetBrains.Annotations; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace JsonApiDotNetCoreExampleClient; +namespace OpenApiNSwagClientExample; [UsedImplicitly(ImplicitUseTargetFlags.Itself)] public partial class ExampleApiClient : JsonApiClient diff --git a/src/Examples/JsonApiDotNetCoreExampleClient/JsonApiDotNetCoreExampleClient.csproj b/src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj similarity index 53% rename from src/Examples/JsonApiDotNetCoreExampleClient/JsonApiDotNetCoreExampleClient.csproj rename to src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj index 326827e86f..72cbdf00e9 100644 --- a/src/Examples/JsonApiDotNetCoreExampleClient/JsonApiDotNetCoreExampleClient.csproj +++ b/src/Examples/OpenApiNSwagClientExample/OpenApiNSwagClientExample.csproj @@ -1,31 +1,30 @@ - + net8.0 - Exe - + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + + + - - all - runtime; build; native; contentfiles; analyzers; buildtransitive - + - - /GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client + + OpenApiNSwagClientExample + ExampleApiClient + ExampleApiClient.cs + NSwagCSharp + /GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag diff --git a/src/Examples/OpenApiNSwagClientExample/PeopleMessageFormatter.cs b/src/Examples/OpenApiNSwagClientExample/PeopleMessageFormatter.cs new file mode 100644 index 0000000000..4fd5bdc6b6 --- /dev/null +++ b/src/Examples/OpenApiNSwagClientExample/PeopleMessageFormatter.cs @@ -0,0 +1,66 @@ +using System.Net; +using System.Text; +using JetBrains.Annotations; +using JsonApiDotNetCore.OpenApi.Client.NSwag; + +namespace OpenApiNSwagClientExample; + +/// +/// Prints the specified people, their assigned todo-items, and its tags. +/// +[UsedImplicitly(ImplicitUseKindFlags.InstantiatedNoFixedConstructorSignature)] +internal sealed class PeopleMessageFormatter +{ + public static void PrintPeople(ApiResponse peopleResponse) + { + string message = WritePeople(peopleResponse); + Console.WriteLine(message); + } + + private static string WritePeople(ApiResponse peopleResponse) + { + if (peopleResponse is { StatusCode: (int)HttpStatusCode.NotModified, Result: null }) + { + return "The HTTP response hasn't changed, so no response body was returned."; + } + + var builder = new StringBuilder(); + builder.AppendLine($"Found {peopleResponse.Result!.Data.Count} people:"); + + foreach (PersonDataInResponse person in peopleResponse.Result!.Data) + { + WritePerson(person, peopleResponse.Result!.Included, builder); + } + + return builder.ToString(); + } + + private static void WritePerson(PersonDataInResponse person, ICollection includes, StringBuilder builder) + { + ToManyTodoItemInResponse assignedTodoItems = person.Relationships.AssignedTodoItems; + + builder.AppendLine($" Person {person.Id}: {person.Attributes.DisplayName} with {assignedTodoItems.Data.Count} assigned todo-items:"); + WriteRelatedTodoItems(assignedTodoItems.Data, includes, builder); + } + + private static void WriteRelatedTodoItems(IEnumerable todoItemIdentifiers, ICollection includes, StringBuilder builder) + { + foreach (TodoItemIdentifier todoItemIdentifier in todoItemIdentifiers) + { + TodoItemDataInResponse includedTodoItem = includes.OfType().Single(include => include.Id == todoItemIdentifier.Id); + ToManyTagInResponse tags = includedTodoItem.Relationships.Tags; + + builder.AppendLine($" TodoItem {includedTodoItem.Id}: {includedTodoItem.Attributes.Description} with {tags.Data.Count} tags:"); + WriteRelatedTags(tags.Data, includes, builder); + } + } + + private static void WriteRelatedTags(IEnumerable tagIdentifiers, ICollection includes, StringBuilder builder) + { + foreach (TagIdentifier tagIdentifier in tagIdentifiers) + { + TagDataInResponse includedTag = includes.OfType().Single(include => include.Id == tagIdentifier.Id); + builder.AppendLine($" Tag {includedTag.Id}: {includedTag.Attributes.Name}"); + } + } +} diff --git a/src/Examples/OpenApiNSwagClientExample/Program.cs b/src/Examples/OpenApiNSwagClientExample/Program.cs new file mode 100644 index 0000000000..67d81a7ad1 --- /dev/null +++ b/src/Examples/OpenApiNSwagClientExample/Program.cs @@ -0,0 +1,10 @@ +using OpenApiNSwagClientExample; + +HostApplicationBuilder builder = Host.CreateApplicationBuilder(args); +builder.Services.AddLogging(options => options.ClearProviders()); +builder.Services.AddHostedService(); +builder.Services.AddSingleton(); +builder.Services.AddHttpClient().AddHttpMessageHandler(); + +IHost host = builder.Build(); +await host.RunAsync(); diff --git a/src/Examples/OpenApiNSwagClientExample/Properties/launchSettings.json b/src/Examples/OpenApiNSwagClientExample/Properties/launchSettings.json new file mode 100644 index 0000000000..afb5e5dac4 --- /dev/null +++ b/src/Examples/OpenApiNSwagClientExample/Properties/launchSettings.json @@ -0,0 +1,12 @@ +{ + "$schema": "http://json.schemastore.org/launchsettings.json", + "profiles": { + "Kestrel": { + "commandName": "Project", + "dotnetRunMessages": true, + "environmentVariables": { + "DOTNET_ENVIRONMENT": "Development" + } + } + } +} diff --git a/src/Examples/OpenApiNSwagClientExample/Worker.cs b/src/Examples/OpenApiNSwagClientExample/Worker.cs new file mode 100644 index 0000000000..f4d8fe1166 --- /dev/null +++ b/src/Examples/OpenApiNSwagClientExample/Worker.cs @@ -0,0 +1,72 @@ +using JsonApiDotNetCore.OpenApi.Client.NSwag; + +namespace OpenApiNSwagClientExample; + +public sealed class Worker(ExampleApiClient apiClient, IHostApplicationLifetime hostApplicationLifetime) : BackgroundService +{ + private readonly ExampleApiClient _apiClient = apiClient; + private readonly IHostApplicationLifetime _hostApplicationLifetime = hostApplicationLifetime; + + protected override async Task ExecuteAsync(CancellationToken stoppingToken) + { + try + { + var queryString = new Dictionary + { + ["filter"] = "has(assignedTodoItems)", + ["sort"] = "-lastName", + ["page[size]"] = "5", + ["include"] = "assignedTodoItems.tags" + }; + + ApiResponse getResponse = await GetPeopleAsync(_apiClient, queryString, null, stoppingToken); + PeopleMessageFormatter.PrintPeople(getResponse); + + string eTag = getResponse.Headers["ETag"].Single(); + ApiResponse getResponseAgain = await GetPeopleAsync(_apiClient, queryString, eTag, stoppingToken); + PeopleMessageFormatter.PrintPeople(getResponseAgain); + + await UpdatePersonAsync(stoppingToken); + + _ = await _apiClient.GetPersonAsync("999999", null, null, stoppingToken); + } + catch (ApiException exception) + { + Console.WriteLine($"JSON:API ERROR: {exception.Result.Errors.First().Detail}"); + } + catch (HttpRequestException exception) + { + Console.WriteLine($"ERROR: {exception.Message}"); + } + + _hostApplicationLifetime.StopApplication(); + } + + private static Task> GetPeopleAsync(ExampleApiClient apiClient, IDictionary queryString, + string? ifNoneMatch, CancellationToken cancellationToken) + { + return ApiResponse.TranslateAsync(() => apiClient.GetPersonCollectionAsync(queryString, ifNoneMatch, cancellationToken)); + } + + private async Task UpdatePersonAsync(CancellationToken cancellationToken) + { + var patchRequest = new PersonPatchRequestDocument + { + Data = new PersonDataInPatchRequest + { + Id = "1", + Attributes = new PersonAttributesInPatchRequest + { + LastName = "Doe" + } + } + }; + + // This line results in sending "firstName: null" instead of omitting it. + using (_apiClient.WithPartialAttributeSerialization(patchRequest, + person => person.FirstName)) + { + _ = await ApiResponse.TranslateAsync(() => _apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest, cancellationToken)); + } + } +} diff --git a/src/Examples/OpenApiNSwagClientExample/appsettings.json b/src/Examples/OpenApiNSwagClientExample/appsettings.json new file mode 100644 index 0000000000..2b94cdb46d --- /dev/null +++ b/src/Examples/OpenApiNSwagClientExample/appsettings.json @@ -0,0 +1,9 @@ +{ + "Logging": { + "LogLevel": { + "Default": "Warning", + "Microsoft.Hosting.Lifetime": "Information", + "System.Net.Http.HttpClient": "Information" + } + } +} diff --git a/src/Examples/QueryStringExample/swagger.json b/src/Examples/QueryStringExample/swagger.json deleted file mode 100644 index 819aafdb8f..0000000000 --- a/src/Examples/QueryStringExample/swagger.json +++ /dev/null @@ -1,1602 +0,0 @@ -{ - "openapi": "3.0.1", - "info": { - "title": "QueryStringExample", - "version": "1.0" - }, - "paths": { - "/api/nodes": { - "get": { - "tags": [ - "nodes" - ], - "summary": "Retrieves a collection of nodes.", - "operationId": "getNodeCollection", - "parameters": [ - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "Successfully returns the found nodes, or an empty array if none were found.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nodeCollectionResponseDocument" - } - } - } - }, - "400": { - "description": "The query string is invalid." - } - } - }, - "head": { - "tags": [ - "nodes" - ], - "summary": "Retrieves a collection of nodes without returning them.", - "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", - "operationId": "headNodeCollection", - "parameters": [ - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "The operation completed successfully." - }, - "400": { - "description": "The query string is invalid." - } - } - }, - "post": { - "tags": [ - "nodes" - ], - "summary": "Creates a new node.", - "operationId": "postNode", - "parameters": [ - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "requestBody": { - "description": "The attributes and relationships of the node to create.", - "content": { - "application/vnd.api+json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/nodePostRequestDocument" - } - ] - } - } - } - }, - "responses": { - "201": { - "description": "The node was successfully created, which resulted in additional changes. The newly created node is returned.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nodePrimaryResponseDocument" - } - } - } - }, - "204": { - "description": "The node was successfully created, which did not result in additional changes." - }, - "400": { - "description": "The query string is invalid or the request body is missing or malformed." - }, - "403": { - "description": "Client-generated IDs cannot be used at this endpoint." - }, - "409": { - "description": "A resource type in the request body is incompatible." - }, - "422": { - "description": "Validation of the request body failed." - } - } - } - }, - "/api/nodes/{id}": { - "get": { - "tags": [ - "nodes" - ], - "summary": "Retrieves an individual node by its identifier.", - "operationId": "getNode", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "Successfully returns the found node.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nodePrimaryResponseDocument" - } - } - } - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "head": { - "tags": [ - "nodes" - ], - "summary": "Retrieves an individual node by its identifier without returning it.", - "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", - "operationId": "headNode", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "The operation completed successfully." - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "patch": { - "tags": [ - "nodes" - ], - "summary": "Updates an existing node.", - "operationId": "patchNode", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node to update.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "requestBody": { - "description": "The attributes and relationships of the node to update. Omitted fields are left unchanged.", - "content": { - "application/vnd.api+json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/nodePatchRequestDocument" - } - ] - } - } - } - }, - "responses": { - "200": { - "description": "The node was successfully updated, which resulted in additional changes. The updated node is returned.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nodePrimaryResponseDocument" - } - } - } - }, - "204": { - "description": "The node was successfully updated, which did not result in additional changes." - }, - "400": { - "description": "The query string is invalid or the request body is missing or malformed." - }, - "404": { - "description": "The node or a related resource does not exist." - }, - "409": { - "description": "A resource type or identifier in the request body is incompatible." - }, - "422": { - "description": "Validation of the request body failed." - } - } - }, - "delete": { - "tags": [ - "nodes" - ], - "summary": "Deletes an existing node by its identifier.", - "operationId": "deleteNode", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node to delete.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "responses": { - "204": { - "description": "The node was successfully deleted." - }, - "404": { - "description": "The node does not exist." - } - } - } - }, - "/api/nodes/{id}/children": { - "get": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related nodes of an individual node's children relationship.", - "operationId": "getNodeChildren", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related nodes to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "Successfully returns the found nodes, or an empty array if none were found.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nodeCollectionResponseDocument" - } - } - } - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "head": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related nodes of an individual node's children relationship without returning them.", - "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", - "operationId": "headNodeChildren", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related nodes to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "The operation completed successfully." - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - } - }, - "/api/nodes/{id}/relationships/children": { - "get": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related node identities of an individual node's children relationship.", - "operationId": "getNodeChildrenRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related node identities to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "Successfully returns the found node identities, or an empty array if none were found.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nodeIdentifierCollectionResponseDocument" - } - } - } - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "head": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related node identities of an individual node's children relationship without returning them.", - "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", - "operationId": "headNodeChildrenRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related node identities to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "The operation completed successfully." - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "post": { - "tags": [ - "nodes" - ], - "summary": "Adds existing nodes to the children relationship of an individual node.", - "operationId": "postNodeChildrenRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node to add nodes to.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "The identities of the nodes to add to the children relationship.", - "content": { - "application/vnd.api+json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/toManyNodeInRequest" - } - ] - } - } - } - }, - "responses": { - "204": { - "description": "The nodes were successfully added, which did not result in additional changes." - }, - "400": { - "description": "The request body is missing or malformed." - }, - "404": { - "description": "The node does not exist." - }, - "409": { - "description": "A resource type in the request body is incompatible." - } - } - }, - "patch": { - "tags": [ - "nodes" - ], - "summary": "Assigns existing nodes to the children relationship of an individual node.", - "operationId": "patchNodeChildrenRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose children relationship to assign.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "The identities of the nodes to assign to the children relationship, or an empty array to clear the relationship.", - "content": { - "application/vnd.api+json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/toManyNodeInRequest" - } - ] - } - } - } - }, - "responses": { - "204": { - "description": "The children relationship was successfully updated, which did not result in additional changes." - }, - "400": { - "description": "The request body is missing or malformed." - }, - "404": { - "description": "The node does not exist." - }, - "409": { - "description": "A resource type in the request body is incompatible." - } - } - }, - "delete": { - "tags": [ - "nodes" - ], - "summary": "Removes existing nodes from the children relationship of an individual node.", - "operationId": "deleteNodeChildrenRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node to remove nodes from.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "The identities of the nodes to remove from the children relationship.", - "content": { - "application/vnd.api+json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/toManyNodeInRequest" - } - ] - } - } - } - }, - "responses": { - "204": { - "description": "The nodes were successfully removed, which did not result in additional changes." - }, - "400": { - "description": "The request body is missing or malformed." - }, - "404": { - "description": "The node does not exist." - }, - "409": { - "description": "A resource type in the request body is incompatible." - } - } - } - }, - "/api/nodes/{id}/parent": { - "get": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related node of an individual node's parent relationship.", - "operationId": "getNodeParent", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related node to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "Successfully returns the found node, or `null` if it was not found.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nullableNodeSecondaryResponseDocument" - } - } - } - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "head": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related node of an individual node's parent relationship without returning it.", - "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", - "operationId": "headNodeParent", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related node to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "The operation completed successfully." - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - } - }, - "/api/nodes/{id}/relationships/parent": { - "get": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related node identity of an individual node's parent relationship.", - "operationId": "getNodeParentRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related node identity to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "Successfully returns the found node identity, or `null` if it was not found.", - "content": { - "application/vnd.api+json": { - "schema": { - "$ref": "#/components/schemas/nullableNodeIdentifierResponseDocument" - } - } - } - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "head": { - "tags": [ - "nodes" - ], - "summary": "Retrieves the related node identity of an individual node's parent relationship without returning it.", - "description": "Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.", - "operationId": "headNodeParentRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose related node identity to retrieve.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - }, - { - "name": "query", - "in": "query", - "description": "For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters.", - "schema": { - "type": "object", - "additionalProperties": { - "type": "string", - "nullable": true - }, - "example": null - } - } - ], - "responses": { - "200": { - "description": "The operation completed successfully." - }, - "400": { - "description": "The query string is invalid." - }, - "404": { - "description": "The node does not exist." - } - } - }, - "patch": { - "tags": [ - "nodes" - ], - "summary": "Clears or assigns an existing node to the parent relationship of an individual node.", - "operationId": "patchNodeParentRelationship", - "parameters": [ - { - "name": "id", - "in": "path", - "description": "The identifier of the node whose parent relationship to assign or clear.", - "required": true, - "schema": { - "type": "integer", - "format": "int64" - } - } - ], - "requestBody": { - "description": "The identity of the node to assign to the parent relationship, or `null` to clear the relationship.", - "content": { - "application/vnd.api+json": { - "schema": { - "allOf": [ - { - "$ref": "#/components/schemas/nullableToOneNodeInRequest" - } - ] - } - } - } - }, - "responses": { - "204": { - "description": "The parent relationship was successfully updated, which did not result in additional changes." - }, - "400": { - "description": "The request body is missing or malformed." - }, - "404": { - "description": "The node does not exist." - }, - "409": { - "description": "A resource type in the request body is incompatible." - } - } - } - } - }, - "components": { - "schemas": { - "jsonapiObject": { - "type": "object", - "properties": { - "version": { - "type": "string" - }, - "ext": { - "type": "array", - "items": { - "type": "string" - } - }, - "profile": { - "type": "array", - "items": { - "type": "string" - } - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "linksInRelationshipObject": { - "required": [ - "related", - "self" - ], - "type": "object", - "properties": { - "self": { - "minLength": 1, - "type": "string" - }, - "related": { - "minLength": 1, - "type": "string" - } - }, - "additionalProperties": false - }, - "linksInResourceCollectionDocument": { - "required": [ - "self" - ], - "type": "object", - "properties": { - "self": { - "minLength": 1, - "type": "string" - }, - "describedby": { - "type": "string" - }, - "first": { - "type": "string" - }, - "last": { - "type": "string" - }, - "prev": { - "type": "string" - }, - "next": { - "type": "string" - } - }, - "additionalProperties": false - }, - "linksInResourceDocument": { - "required": [ - "self" - ], - "type": "object", - "properties": { - "self": { - "minLength": 1, - "type": "string" - }, - "describedby": { - "type": "string" - } - }, - "additionalProperties": false - }, - "linksInResourceIdentifierCollectionDocument": { - "required": [ - "related", - "self" - ], - "type": "object", - "properties": { - "self": { - "minLength": 1, - "type": "string" - }, - "related": { - "minLength": 1, - "type": "string" - }, - "describedby": { - "type": "string" - }, - "first": { - "type": "string" - }, - "last": { - "type": "string" - }, - "prev": { - "type": "string" - }, - "next": { - "type": "string" - } - }, - "additionalProperties": false - }, - "linksInResourceIdentifierDocument": { - "required": [ - "related", - "self" - ], - "type": "object", - "properties": { - "self": { - "minLength": 1, - "type": "string" - }, - "related": { - "minLength": 1, - "type": "string" - }, - "describedby": { - "type": "string" - } - }, - "additionalProperties": false - }, - "linksInResourceObject": { - "required": [ - "self" - ], - "type": "object", - "properties": { - "self": { - "minLength": 1, - "type": "string" - } - }, - "additionalProperties": false - }, - "nodeAttributesInPatchRequest": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "comment": { - "type": "string", - "nullable": true - } - }, - "additionalProperties": false - }, - "nodeAttributesInPostRequest": { - "required": [ - "name" - ], - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "comment": { - "type": "string", - "nullable": true - } - }, - "additionalProperties": false - }, - "nodeAttributesInResponse": { - "type": "object", - "properties": { - "name": { - "type": "string" - }, - "comment": { - "type": "string", - "nullable": true - } - }, - "additionalProperties": false - }, - "nodeCollectionResponseDocument": { - "required": [ - "data", - "links" - ], - "type": "object", - "properties": { - "jsonapi": { - "allOf": [ - { - "$ref": "#/components/schemas/jsonapiObject" - } - ] - }, - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInResourceCollectionDocument" - } - ] - }, - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/nodeDataInResponse" - } - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "nodeDataInPatchRequest": { - "required": [ - "id", - "type" - ], - "type": "object", - "properties": { - "type": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeResourceType" - } - ] - }, - "id": { - "minLength": 1, - "type": "string" - }, - "attributes": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeAttributesInPatchRequest" - } - ] - }, - "relationships": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeRelationshipsInPatchRequest" - } - ] - } - }, - "additionalProperties": false - }, - "nodeDataInPostRequest": { - "required": [ - "type" - ], - "type": "object", - "properties": { - "type": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeResourceType" - } - ] - }, - "attributes": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeAttributesInPostRequest" - } - ] - }, - "relationships": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeRelationshipsInPostRequest" - } - ] - } - }, - "additionalProperties": false - }, - "nodeDataInResponse": { - "required": [ - "id", - "links", - "type" - ], - "type": "object", - "properties": { - "type": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeResourceType" - } - ] - }, - "id": { - "minLength": 1, - "type": "string" - }, - "attributes": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeAttributesInResponse" - } - ] - }, - "relationships": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeRelationshipsInResponse" - } - ] - }, - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInResourceObject" - } - ] - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "nodeIdentifier": { - "required": [ - "id", - "type" - ], - "type": "object", - "properties": { - "type": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeResourceType" - } - ] - }, - "id": { - "minLength": 1, - "type": "string" - } - }, - "additionalProperties": false - }, - "nodeIdentifierCollectionResponseDocument": { - "required": [ - "data", - "links" - ], - "type": "object", - "properties": { - "jsonapi": { - "allOf": [ - { - "$ref": "#/components/schemas/jsonapiObject" - } - ] - }, - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInResourceIdentifierCollectionDocument" - } - ] - }, - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/nodeIdentifier" - } - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "nodePatchRequestDocument": { - "required": [ - "data" - ], - "type": "object", - "properties": { - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeDataInPatchRequest" - } - ] - } - }, - "additionalProperties": false - }, - "nodePostRequestDocument": { - "required": [ - "data" - ], - "type": "object", - "properties": { - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeDataInPostRequest" - } - ] - } - }, - "additionalProperties": false - }, - "nodePrimaryResponseDocument": { - "required": [ - "data", - "links" - ], - "type": "object", - "properties": { - "jsonapi": { - "allOf": [ - { - "$ref": "#/components/schemas/jsonapiObject" - } - ] - }, - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInResourceDocument" - } - ] - }, - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeDataInResponse" - } - ] - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "nodeRelationshipsInPatchRequest": { - "type": "object", - "properties": { - "parent": { - "allOf": [ - { - "$ref": "#/components/schemas/nullableToOneNodeInRequest" - } - ] - }, - "children": { - "allOf": [ - { - "$ref": "#/components/schemas/toManyNodeInRequest" - } - ] - } - }, - "additionalProperties": false - }, - "nodeRelationshipsInPostRequest": { - "type": "object", - "properties": { - "parent": { - "allOf": [ - { - "$ref": "#/components/schemas/nullableToOneNodeInRequest" - } - ] - }, - "children": { - "allOf": [ - { - "$ref": "#/components/schemas/toManyNodeInRequest" - } - ] - } - }, - "additionalProperties": false - }, - "nodeRelationshipsInResponse": { - "type": "object", - "properties": { - "parent": { - "allOf": [ - { - "$ref": "#/components/schemas/nullableToOneNodeInResponse" - } - ] - }, - "children": { - "allOf": [ - { - "$ref": "#/components/schemas/toManyNodeInResponse" - } - ] - } - }, - "additionalProperties": false - }, - "nodeResourceType": { - "enum": [ - "nodes" - ], - "type": "string" - }, - "nullableNodeIdentifierResponseDocument": { - "required": [ - "data", - "links" - ], - "type": "object", - "properties": { - "jsonapi": { - "allOf": [ - { - "$ref": "#/components/schemas/jsonapiObject" - } - ] - }, - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInResourceIdentifierDocument" - } - ] - }, - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeIdentifier" - } - ], - "nullable": true - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "nullableNodeSecondaryResponseDocument": { - "required": [ - "data", - "links" - ], - "type": "object", - "properties": { - "jsonapi": { - "allOf": [ - { - "$ref": "#/components/schemas/jsonapiObject" - } - ] - }, - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInResourceDocument" - } - ] - }, - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeDataInResponse" - } - ], - "nullable": true - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "nullableToOneNodeInRequest": { - "required": [ - "data" - ], - "type": "object", - "properties": { - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeIdentifier" - } - ], - "nullable": true - } - }, - "additionalProperties": false - }, - "nullableToOneNodeInResponse": { - "required": [ - "links" - ], - "type": "object", - "properties": { - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInRelationshipObject" - } - ] - }, - "data": { - "allOf": [ - { - "$ref": "#/components/schemas/nodeIdentifier" - } - ], - "nullable": true - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - }, - "toManyNodeInRequest": { - "required": [ - "data" - ], - "type": "object", - "properties": { - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/nodeIdentifier" - } - } - }, - "additionalProperties": false - }, - "toManyNodeInResponse": { - "required": [ - "links" - ], - "type": "object", - "properties": { - "links": { - "allOf": [ - { - "$ref": "#/components/schemas/linksInRelationshipObject" - } - ] - }, - "data": { - "type": "array", - "items": { - "$ref": "#/components/schemas/nodeIdentifier" - } - }, - "meta": { - "type": "object", - "additionalProperties": { } - } - }, - "additionalProperties": false - } - } - } -} \ No newline at end of file diff --git a/src/JsonApiDotNetCore.OpenApi.Client.Kiota/JsonApiDotNetCore.OpenApi.Client.Kiota.csproj b/src/JsonApiDotNetCore.OpenApi.Client.Kiota/JsonApiDotNetCore.OpenApi.Client.Kiota.csproj new file mode 100644 index 0000000000..21bacf9087 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi.Client.Kiota/JsonApiDotNetCore.OpenApi.Client.Kiota.csproj @@ -0,0 +1,41 @@ + + + net8.0;net6.0 + true + true + false + + + + + + $(JsonApiDotNetCoreVersionPrefix) + jsonapidotnetcore;jsonapi;json:api;dotnet;asp.net;rest;web-api;openapi;swagger;client;kiota + Provides OpenAPI support for JSON:API generated clients using Kiota. + json-api-dotnet + https://www.jsonapi.net/ + MIT + false + See https://github.com/json-api-dotnet/JsonApiDotNetCore/releases. + logo.png + PackageReadme.md + true + true + embedded + + + + + + + + + + + + + + + + + diff --git a/src/JsonApiDotNetCore.OpenApi.Client.Kiota/SetQueryStringHttpMessageHandler.cs b/src/JsonApiDotNetCore.OpenApi.Client.Kiota/SetQueryStringHttpMessageHandler.cs new file mode 100644 index 0000000000..8c30c0754e --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi.Client.Kiota/SetQueryStringHttpMessageHandler.cs @@ -0,0 +1,53 @@ +using JetBrains.Annotations; +using Microsoft.AspNetCore.WebUtilities; + +namespace JsonApiDotNetCore.OpenApi.Client.Kiota; + +/// +/// Enables setting the HTTP query string. Workaround for https://github.com/microsoft/kiota/issues/3800. +/// +[PublicAPI] +public sealed class SetQueryStringHttpMessageHandler : DelegatingHandler +{ + private IDictionary? _queryString; + + public IDisposable CreateScope(IDictionary queryString) + { + return new QueryStringScope(this, queryString); + } + + protected override Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + if (_queryString is { Count: > 0 } && request.RequestUri != null) + { + request.RequestUri = new Uri(QueryHelpers.AddQueryString(request.RequestUri.ToString(), _queryString)); + } + + return base.SendAsync(request, cancellationToken); + } + + private sealed class QueryStringScope : IDisposable + { + private readonly SetQueryStringHttpMessageHandler _owner; + private readonly IDictionary? _backupQueryString; + + public QueryStringScope(SetQueryStringHttpMessageHandler owner, IDictionary queryString) + { + _owner = owner; + _backupQueryString = owner._queryString; + + owner._queryString = SetEmptyStringForNullValues(queryString); + } + + private static Dictionary SetEmptyStringForNullValues(IDictionary queryString) + { + // QueryHelpers.AddQueryString ignores null values, so replace them with empty strings to get them sent. + return queryString.ToDictionary(pair => pair.Key, pair => pair.Value ?? (string?)string.Empty); + } + + public void Dispose() + { + _owner._queryString = _backupQueryString; + } + } +} diff --git a/src/JsonApiDotNetCore.OpenApi.Client/ApiException.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/ApiException.cs similarity index 96% rename from src/JsonApiDotNetCore.OpenApi.Client/ApiException.cs rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/ApiException.cs index d05aaeb111..8b66839e9e 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/ApiException.cs +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/ApiException.cs @@ -3,7 +3,7 @@ // We cannot rely on generating ApiException as soon as we are generating multiple clients, see https://github.com/RicoSuter/NSwag/issues/2839#issuecomment-776647377. // Instead, we configure NSwag to point to the exception below in the generated code. -namespace JsonApiDotNetCore.OpenApi.Client; +namespace JsonApiDotNetCore.OpenApi.Client.NSwag; [UsedImplicitly(ImplicitUseTargetFlags.Members)] public class ApiException(string message, int statusCode, string? response, IReadOnlyDictionary> headers, Exception? innerException) diff --git a/src/JsonApiDotNetCore.OpenApi.Client/ApiResponse.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/ApiResponse.cs similarity index 98% rename from src/JsonApiDotNetCore.OpenApi.Client/ApiResponse.cs rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/ApiResponse.cs index b719371d58..0961b197b6 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/ApiResponse.cs +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/ApiResponse.cs @@ -1,7 +1,7 @@ using System.Net; using JetBrains.Annotations; -namespace JsonApiDotNetCore.OpenApi.Client; +namespace JsonApiDotNetCore.OpenApi.Client.NSwag; [PublicAPI] public class ApiResponse(int statusCode, IReadOnlyDictionary> headers) diff --git a/src/JsonApiDotNetCore.OpenApi.Client/ArgumentGuard.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/ArgumentGuard.cs similarity index 90% rename from src/JsonApiDotNetCore.OpenApi.Client/ArgumentGuard.cs rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/ArgumentGuard.cs index 8d7434f689..282f37ec45 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/ArgumentGuard.cs +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/ArgumentGuard.cs @@ -4,7 +4,7 @@ #pragma warning disable AV1008 // Class should not be static -namespace JsonApiDotNetCore.OpenApi.Client; +namespace JsonApiDotNetCore.OpenApi.Client.NSwag; internal static class ArgumentGuard { diff --git a/src/JsonApiDotNetCore.OpenApi.Client/IJsonApiClient.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/IJsonApiClient.cs similarity index 95% rename from src/JsonApiDotNetCore.OpenApi.Client/IJsonApiClient.cs rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/IJsonApiClient.cs index 9c71e32380..df6a35d78e 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/IJsonApiClient.cs +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/IJsonApiClient.cs @@ -1,7 +1,9 @@ using System.Linq.Expressions; +using JetBrains.Annotations; -namespace JsonApiDotNetCore.OpenApi.Client; +namespace JsonApiDotNetCore.OpenApi.Client.NSwag; +[PublicAPI] public interface IJsonApiClient { /// diff --git a/src/JsonApiDotNetCore.OpenApi.Client/JsonApiClient.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiClient.cs similarity index 99% rename from src/JsonApiDotNetCore.OpenApi.Client/JsonApiClient.cs rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiClient.cs index 98ff7a8d91..ea5bc7fddc 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/JsonApiClient.cs +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiClient.cs @@ -3,7 +3,7 @@ using Newtonsoft.Json; using Newtonsoft.Json.Serialization; -namespace JsonApiDotNetCore.OpenApi.Client; +namespace JsonApiDotNetCore.OpenApi.Client.NSwag; /// /// Base class to inherit auto-generated OpenAPI clients from. Provides support for partial POST/PATCH in JSON:API requests. diff --git a/src/JsonApiDotNetCore.OpenApi.Client/JsonApiDotNetCore.OpenApi.Client.csproj b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiDotNetCore.OpenApi.Client.NSwag.csproj similarity index 78% rename from src/JsonApiDotNetCore.OpenApi.Client/JsonApiDotNetCore.OpenApi.Client.csproj rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiDotNetCore.OpenApi.Client.NSwag.csproj index 8feec15c9b..71d4b9de36 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/JsonApiDotNetCore.OpenApi.Client.csproj +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/JsonApiDotNetCore.OpenApi.Client.NSwag.csproj @@ -11,7 +11,7 @@ $(JsonApiDotNetCoreVersionPrefix) jsonapidotnetcore;jsonapi;json:api;dotnet;asp.net;rest;web-api;openapi;swagger;client;nswag - Provides support for OpenAPI generated clients in sending partial POST/PATCH requests against JSON:API endpoints. + Provides OpenAPI support for JSON:API generated clients using NSwag. json-api-dotnet https://www.jsonapi.net/ MIT @@ -31,9 +31,7 @@ + - - - diff --git a/src/JsonApiDotNetCore.OpenApi.Client.NSwag/Properties/AssemblyInfo.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/Properties/AssemblyInfo.cs new file mode 100644 index 0000000000..1ac53bb335 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/Properties/AssemblyInfo.cs @@ -0,0 +1,3 @@ +using System.Runtime.CompilerServices; + +[assembly: InternalsVisibleTo("OpenApiNSwagClientTests")] diff --git a/src/JsonApiDotNetCore.OpenApi.Client/UnreachableCodeException.cs b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/UnreachableCodeException.cs similarity index 66% rename from src/JsonApiDotNetCore.OpenApi.Client/UnreachableCodeException.cs rename to src/JsonApiDotNetCore.OpenApi.Client.NSwag/UnreachableCodeException.cs index 9778290d7d..137db782f5 100644 --- a/src/JsonApiDotNetCore.OpenApi.Client/UnreachableCodeException.cs +++ b/src/JsonApiDotNetCore.OpenApi.Client.NSwag/UnreachableCodeException.cs @@ -1,3 +1,3 @@ -namespace JsonApiDotNetCore.OpenApi.Client; +namespace JsonApiDotNetCore.OpenApi.Client.NSwag; internal sealed class UnreachableCodeException() : Exception("This code should not be reachable."); diff --git a/src/JsonApiDotNetCore.OpenApi.Client/AssemblyInfo.cs b/src/JsonApiDotNetCore.OpenApi.Client/AssemblyInfo.cs deleted file mode 100644 index 2871965d43..0000000000 --- a/src/JsonApiDotNetCore.OpenApi.Client/AssemblyInfo.cs +++ /dev/null @@ -1,3 +0,0 @@ -using System.Runtime.CompilerServices; - -[assembly: InternalsVisibleTo("OpenApiClientTests")] diff --git a/src/JsonApiDotNetCore.OpenApi/JsonApiDotNetCore.OpenApi.csproj b/src/JsonApiDotNetCore.OpenApi/JsonApiDotNetCore.OpenApi.csproj index 2f74aff5da..c7e68196e2 100644 --- a/src/JsonApiDotNetCore.OpenApi/JsonApiDotNetCore.OpenApi.csproj +++ b/src/JsonApiDotNetCore.OpenApi/JsonApiDotNetCore.OpenApi.csproj @@ -37,6 +37,5 @@ - diff --git a/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs b/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs index cc9c0f179c..ad976b6fc7 100644 --- a/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs +++ b/src/JsonApiDotNetCore.OpenApi/ServiceCollectionExtensions.cs @@ -15,12 +15,11 @@ public static class ServiceCollectionExtensions /// /// Adds the OpenAPI integration to JsonApiDotNetCore by configuring Swashbuckle. /// - public static void AddOpenApi(this IServiceCollection services, IMvcCoreBuilder mvcBuilder, Action? setupSwaggerGenAction = null) + public static void AddOpenApi(this IServiceCollection services, Action? setupSwaggerGenAction = null) { ArgumentGuard.NotNull(services); - ArgumentGuard.NotNull(mvcBuilder); - AddCustomApiExplorer(services, mvcBuilder); + AddCustomApiExplorer(services); AddCustomSwaggerComponents(services); AddSwaggerGenerator(services); @@ -30,7 +29,7 @@ public static void AddOpenApi(this IServiceCollection services, IMvcCoreBuilder } } - private static void AddCustomApiExplorer(IServiceCollection services, IMvcCoreBuilder mvcBuilder) + private static void AddCustomApiExplorer(IServiceCollection services) { services.TryAddSingleton(); services.TryAddSingleton(); @@ -49,11 +48,19 @@ private static void AddCustomApiExplorer(IServiceCollection services, IMvcCoreBu return new ApiDescriptionGroupCollectionProvider(actionDescriptorCollectionProvider, apiDescriptionProviders); })); - mvcBuilder.AddApiExplorer(); + AddApiExplorer(services); services.AddSingleton, ConfigureMvcOptions>(); } + private static void AddApiExplorer(IServiceCollection services) + { + // The code below was copied from the implementation of MvcApiExplorerMvcCoreBuilderExtensions.AddApiExplorer(), + // so we don't need to take IMvcCoreBuilder as an input parameter. + + services.TryAddEnumerable(ServiceDescriptor.Transient()); + } + private static void AddCustomSwaggerComponents(IServiceCollection services) { services.TryAddSingleton(); diff --git a/test/OpenApiClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs b/test/OpenApiClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs deleted file mode 100644 index 82a29a09d0..0000000000 --- a/test/OpenApiClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs +++ /dev/null @@ -1,6 +0,0 @@ -using JsonApiDotNetCore.OpenApi.Client; - -namespace OpenApiClientTests.LegacyClient.GeneratedCode; - -// ReSharper disable once MemberCanBeInternal -public partial interface IOpenApiClient : IJsonApiClient; diff --git a/test/OpenApiEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs b/test/OpenApiEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs deleted file mode 100644 index 8a90cfa0f5..0000000000 --- a/test/OpenApiEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs +++ /dev/null @@ -1,62 +0,0 @@ -using JsonApiDotNetCore.OpenApi.Client; -using Microsoft.Extensions.Logging; -using Newtonsoft.Json; -using TestBuildingBlocks; -using Xunit.Abstractions; - -// ReSharper disable UnusedParameterInPartialMethod - -namespace OpenApiEndToEndTests.QueryStrings.GeneratedCode; - -internal partial class QueryStringsClient : JsonApiClient -{ - private readonly ILogger? _logger; - - public QueryStringsClient(HttpClient httpClient, ITestOutputHelper testOutputHelper) - : this(httpClient, CreateLogger(testOutputHelper)) - { - } - - private QueryStringsClient(HttpClient httpClient, ILogger logger) - : this(httpClient) - { - _logger = logger; - } - - private static ILogger CreateLogger(ITestOutputHelper testOutputHelper) - { - var loggerFactory = new LoggerFactory(new[] - { - new XUnitLoggerProvider(testOutputHelper, null, LogOutputFields.Message) - }); - - return loggerFactory.CreateLogger(); - } - - partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) - { - SetSerializerSettingsForJsonApi(settings); - - settings.Formatting = Formatting.Indented; - } - - partial void PrepareRequest(HttpClient client, HttpRequestMessage request, string url) - { - if (_logger != null && _logger.IsEnabled(LogLevel.Debug)) - { - string? requestBody = request.Content?.ReadAsStringAsync().GetAwaiter().GetResult(); - _logger.LogDebug(requestBody != null ? $"--> {request}{Environment.NewLine}{Environment.NewLine}{requestBody}" : $"--> {request}"); - } - } - - partial void ProcessResponse(HttpClient client, HttpResponseMessage response) - { - if (_logger != null && _logger.IsEnabled(LogLevel.Debug)) - { - string responseBody = response.Content.ReadAsStringAsync().GetAwaiter().GetResult(); - - _logger.LogDebug( - !string.IsNullOrEmpty(responseBody) ? $"<-- {response}{Environment.NewLine}{Environment.NewLine}{responseBody}" : $"<-- {response}"); - } - } -} diff --git a/test/OpenApiKiotaEndToEndTests/AdditionalPropertiesTests.cs b/test/OpenApiKiotaEndToEndTests/AdditionalPropertiesTests.cs new file mode 100644 index 0000000000..c353e08224 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/AdditionalPropertiesTests.cs @@ -0,0 +1,31 @@ +using System.Reflection; +using FluentAssertions; +using Xunit; + +namespace OpenApiKiotaEndToEndTests; + +public sealed class AdditionalPropertiesTests +{ + private static readonly string GeneratedCodeDirectory = $"{Path.PathSeparator}GeneratedCode{Path.PathSeparator}"; + + [Fact] + public async Task Additional_properties_are_only_allowed_in_meta() + { + string startDirectory = Path.GetFullPath(Path.Combine(Assembly.GetExecutingAssembly().Location, "../../../../")); + + foreach (string path in Directory.EnumerateFiles(startDirectory, "*.cs", new EnumerationOptions + { + MatchType = MatchType.Simple, + RecurseSubdirectories = true + })) + { + if (path.Contains(GeneratedCodeDirectory, StringComparison.OrdinalIgnoreCase) && !path.EndsWith("_meta.cs", StringComparison.OrdinalIgnoreCase)) + { + string content = await File.ReadAllTextAsync(path); + bool containsAdditionalData = content.Contains("public IDictionary AdditionalData"); + + containsAdditionalData.Should().BeFalse($"file '{path}' should not contain AdditionalData"); + } + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs new file mode 100644 index 0000000000..6d38e6cf9d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/ETagTests.cs @@ -0,0 +1,222 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using Microsoft.Kiota.Http.HttpClientLibrary.Middleware.Options; +using Microsoft.Net.Http.Headers; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.Headers; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.Headers; + +public sealed class ETagTests : IClassFixture, HeadersDbContext>> +{ + private readonly IntegrationTestContext, HeadersDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly HeaderFakers _fakers = new(); + + public ETagTests(IntegrationTestContext, HeadersDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Returns_ETag_for_HEAD_request() + { + // Arrange + List countries = _fakers.Country.Generate(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Countries.AddRange(countries); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + Stream? response = await apiClient.Countries.HeadAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.Should().BeNullOrEmpty(); + + headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + } + + [Fact] + public async Task Returns_ETag_for_GET_request() + { + // Arrange + List countries = _fakers.Country.Generate(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Countries.AddRange(countries); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + CountryCollectionResponseDocument? response = await apiClient.Countries.GetAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.ShouldNotBeNull(); + + headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + } + + [Fact] + public async Task Returns_no_ETag_for_failed_GET_request() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + Func> action = () => apiClient.Countries[Unknown.StringId.For()] + .GetAsync(configuration => configuration.Options.Add(headerInspector)); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.Errors.ShouldHaveCount(1); + exception.Errors[0].Status.Should().Be(((int)HttpStatusCode.NotFound).ToString()); + + headerInspector.ResponseHeaders.Should().NotContainKey(HeaderNames.ETag); + } + + [Fact] + public async Task Returns_no_ETag_for_POST_request() + { + // Arrange + Country newCountry = _fakers.Country.Generate(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + CountryPrimaryResponseDocument? response = await apiClient.Countries.PostAsync(new CountryPostRequestDocument + { + Data = new CountryDataInPostRequest + { + Type = CountryResourceType.Countries, + Attributes = new CountryAttributesInPostRequest + { + Name = newCountry.Name, + Population = newCountry.Population + } + } + }, configuration => configuration.Options.Add(headerInspector)); + + // Assert + response.ShouldNotBeNull(); + + headerInspector.ResponseHeaders.Should().NotContainKey(HeaderNames.ETag); + } + + [Fact] + public async Task Returns_NotModified_for_matching_ETag() + { + // Arrange + List countries = _fakers.Country.Generate(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Countries.AddRange(countries); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + _ = await apiClient.Countries.GetAsync(configuration => configuration.Options.Add(headerInspector)); + + string responseETag = headerInspector.ResponseHeaders[HeaderNames.ETag].Single(); + headerInspector.ResponseHeaders.Clear(); + + // Act + Func> action = () => apiClient.Countries.GetAsync(configuration => + { + configuration.Headers.Add(HeaderNames.IfNoneMatch, responseETag); + configuration.Options.Add(headerInspector); + }); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotModified); + + headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().Equal([responseETag]); + } + + [Fact] + public async Task Returns_content_for_mismatching_ETag() + { + // Arrange + List countries = _fakers.Country.Generate(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Countries.AddRange(countries); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new HeadersClient(requestAdapter); + + var headerInspector = new HeadersInspectionHandlerOption + { + InspectResponseHeaders = true + }; + + // Act + CountryCollectionResponseDocument? response = await apiClient.Countries.GetAsync(configuration => + { + configuration.Headers.Add(HeaderNames.IfNoneMatch, "\"Not-a-matching-value\""); + configuration.Options.Add(headerInspector); + }); + + // Assert + response.ShouldNotBeNull(); + + headerInspector.ResponseHeaders.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs new file mode 100644 index 0000000000..b35a2d5664 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/CountriesRequestBuilder.cs @@ -0,0 +1,197 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries { + /// + /// Builds and executes requests for operations under \countries + /// + public class CountriesRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.Headers.GeneratedCode.countries.item collection + /// The identifier of the country to retrieve. + public CountriesItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new CountriesItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new CountriesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CountriesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries{?query*}", pathParameters) { + } + /// + /// Instantiates a new CountriesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CountriesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of countries. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, CountryCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new country. + /// + /// The request body + /// 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 PostAsync(CountryPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(CountryPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, CountryPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of countries. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Creates a new country. + /// + /// The request body + /// 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 ToPostRequestInformation(CountryPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(CountryPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public CountriesRequestBuilder WithUrl(string rawUrl) { + return new CountriesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of countries. + /// + public class CountriesRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class CountriesRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Creates a new country. + /// + public class CountriesRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/CountriesItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/CountriesItemRequestBuilder.cs new file mode 100644 index 0000000000..86f0b07adc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/CountriesItemRequestBuilder.cs @@ -0,0 +1,234 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item.Languages; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item.Relationships; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item { + /// + /// Builds and executes requests for operations under \countries\{id} + /// + public class CountriesItemRequestBuilder : BaseRequestBuilder { + /// The languages property + public LanguagesRequestBuilder Languages { get => + new LanguagesRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new CountriesItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CountriesItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new CountriesItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CountriesItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing country by its identifier. + /// + /// 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 DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual country by its identifier. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, CountryPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing country. + /// + /// The request body + /// 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 PatchAsync(CountryPatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(CountryPatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, CountryPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing country by its identifier. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Retrieves an individual country by its identifier. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Updates an existing country. + /// + /// The request body + /// 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(CountryPatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(CountryPatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public CountriesItemRequestBuilder WithUrl(string rawUrl) { + return new CountriesItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual country by its identifier. + /// + public class CountriesItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class CountriesItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Updates an existing country. + /// + public class CountriesItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Languages/LanguagesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Languages/LanguagesRequestBuilder.cs new file mode 100644 index 0000000000..21891c674d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Languages/LanguagesRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item.Languages { + /// + /// Builds and executes requests for operations under \countries\{id}\languages + /// + public class LanguagesRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new LanguagesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public LanguagesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}/languages{?query*}", pathParameters) { + } + /// + /// Instantiates a new LanguagesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public LanguagesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}/languages{?query*}", rawUrl) { + } + /// + /// Retrieves the related languages of an individual country's languages relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, LanguageCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related languages of an individual country's languages relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public LanguagesRequestBuilder WithUrl(string rawUrl) { + return new LanguagesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related languages of an individual country's languages relationship. + /// + public class LanguagesRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class LanguagesRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Relationships/Languages/LanguagesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Relationships/Languages/LanguagesRequestBuilder.cs new file mode 100644 index 0000000000..a796d4fe5d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Relationships/Languages/LanguagesRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item.Relationships.Languages { + /// + /// Builds and executes requests for operations under \countries\{id}\relationships\languages + /// + public class LanguagesRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new LanguagesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public LanguagesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}/relationships/languages{?query*}", pathParameters) { + } + /// + /// Instantiates a new LanguagesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public LanguagesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}/relationships/languages{?query*}", rawUrl) { + } + /// + /// Removes existing languages from the languages relationship of an individual country. + /// + /// The request body + /// 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 DeleteAsync(ToManyLanguageInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyLanguageInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related language identities of an individual country's languages relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, LanguageIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing languages to the languages relationship of an individual country. + /// + /// The request body + /// 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 PatchAsync(ToManyLanguageInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyLanguageInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing languages to the languages relationship of an individual country. + /// + /// The request body + /// 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 PostAsync(ToManyLanguageInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyLanguageInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing languages from the languages relationship of an individual country. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyLanguageInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyLanguageInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related language identities of an individual country's languages relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing languages to the languages relationship of an individual country. + /// + /// The request body + /// 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(ToManyLanguageInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyLanguageInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing languages to the languages relationship of an individual country. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyLanguageInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyLanguageInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public LanguagesRequestBuilder WithUrl(string rawUrl) { + return new LanguagesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related language identities of an individual country's languages relationship. + /// + public class LanguagesRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class LanguagesRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..15a0b5c480 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Countries/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,33 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item.Relationships.Languages; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries.Item.Relationships { + /// + /// Builds and executes requests for operations under \countries\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The languages property + public LanguagesRequestBuilder Languages { get => + new LanguagesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/countries/{id}/relationships", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/HeadersClient.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/HeadersClient.cs new file mode 100644 index 0000000000..88070236ca --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/HeadersClient.cs @@ -0,0 +1,44 @@ +// +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Serialization.Form; +using Microsoft.Kiota.Serialization.Json; +using Microsoft.Kiota.Serialization.Multipart; +using Microsoft.Kiota.Serialization.Text; +using OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Countries; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode { + /// + /// The main entry point of the SDK, exposes the configuration and the fluent API. + /// + public class HeadersClient : BaseRequestBuilder { + /// The countries property + public CountriesRequestBuilder Countries { get => + new CountriesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new HeadersClient and sets the default values. + /// + /// The backing store to use for the models. + /// The request adapter to use to execute the requests. + public HeadersClient(IRequestAdapter requestAdapter, IBackingStoreFactory backingStore = default) : base(requestAdapter, "{+baseurl}", new Dictionary()) { + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) { + RequestAdapter.BaseUrl = "http://localhost"; + } + PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl); + RequestAdapter.EnableBackingStore(backingStore); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/Countries.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/Countries.cs new file mode 100644 index 0000000000..0e68d27801 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/Countries.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class Countries : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public CountryAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Countries_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Countries_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public CountryRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Countries CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Countries(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(CountryAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Countries_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(CountryRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/Countries_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/Countries_meta.cs new file mode 100644 index 0000000000..33d4270e52 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/Countries_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class Countries_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new countries_meta and sets the default values. + /// + public Countries_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Countries_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Countries_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInPatchRequest.cs new file mode 100644 index 0000000000..0d9168e955 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInPatchRequest.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// The population property + public long? Population { + get { return BackingStore?.Get("population"); } + set { BackingStore?.Set("population", value); } + } + /// + /// Instantiates a new countryAttributesInPatchRequest and sets the default values. + /// + public CountryAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + {"population", n => { Population = n.GetLongValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteLongValue("population", Population); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInPostRequest.cs new file mode 100644 index 0000000000..9e26e5bb36 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInPostRequest.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// The population property + public long? Population { + get { return BackingStore?.Get("population"); } + set { BackingStore?.Set("population", value); } + } + /// + /// Instantiates a new countryAttributesInPostRequest and sets the default values. + /// + public CountryAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + {"population", n => { Population = n.GetLongValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteLongValue("population", Population); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInResponse.cs new file mode 100644 index 0000000000..007dbb02ea --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryAttributesInResponse.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// The population property + public long? Population { + get { return BackingStore?.Get("population"); } + set { BackingStore?.Set("population", value); } + } + /// + /// Instantiates a new countryAttributesInResponse and sets the default values. + /// + public CountryAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + {"population", n => { Population = n.GetLongValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteLongValue("population", Population); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryCollectionResponseDocument.cs new file mode 100644 index 0000000000..0ca14d4253 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public CountryCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new countryCollectionResponseDocument and sets the default values. + /// + public CountryCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(CountryDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(CountryCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..28f663f505 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new countryCollectionResponseDocument_meta and sets the default values. + /// + public CountryCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInPatchRequest.cs new file mode 100644 index 0000000000..527556b434 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public CountryAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public CountryRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public CountryResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new countryDataInPatchRequest and sets the default values. + /// + public CountryDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(CountryAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(CountryRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInPostRequest.cs new file mode 100644 index 0000000000..c6ddce1bb4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public CountryAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public CountryRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public CountryResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new countryDataInPostRequest and sets the default values. + /// + public CountryDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(CountryAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(CountryRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInResponse.cs new file mode 100644 index 0000000000..0091c947c5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public CountryAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public CountryDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public CountryRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new CountryDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(CountryAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(CountryDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(CountryRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInResponse_meta.cs new file mode 100644 index 0000000000..88f3b10b27 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new countryDataInResponse_meta and sets the default values. + /// + public CountryDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPatchRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPatchRequestDocument.cs new file mode 100644 index 0000000000..b3956a7a67 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryPatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public CountryDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new countryPatchRequestDocument and sets the default values. + /// + public CountryPatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryPatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryPatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(CountryDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPostRequestDocument.cs new file mode 100644 index 0000000000..a25de7c317 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public CountryDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new countryPostRequestDocument and sets the default values. + /// + public CountryPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(CountryDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPrimaryResponseDocument.cs new file mode 100644 index 0000000000..7dd8c9b92a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Countries? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Countries Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public CountryPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public CountryPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new countryPrimaryResponseDocument and sets the default values. + /// + public CountryPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Countries.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(CountryPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..fbd9a3bd94 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new countryPrimaryResponseDocument_meta and sets the default values. + /// + public CountryPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..2b715e81d3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInPatchRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryRelationshipsInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The languages property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyLanguageInRequest? Languages { + get { return BackingStore?.Get("languages"); } + set { BackingStore?.Set("languages", value); } + } +#nullable restore +#else + public ToManyLanguageInRequest Languages { + get { return BackingStore?.Get("languages"); } + set { BackingStore?.Set("languages", value); } + } +#endif + /// + /// Instantiates a new countryRelationshipsInPatchRequest and sets the default values. + /// + public CountryRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"languages", n => { Languages = n.GetObjectValue(ToManyLanguageInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("languages", Languages); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..0f26676fa4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryRelationshipsInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The languages property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyLanguageInRequest? Languages { + get { return BackingStore?.Get("languages"); } + set { BackingStore?.Set("languages", value); } + } +#nullable restore +#else + public ToManyLanguageInRequest Languages { + get { return BackingStore?.Get("languages"); } + set { BackingStore?.Set("languages", value); } + } +#endif + /// + /// Instantiates a new countryRelationshipsInPostRequest and sets the default values. + /// + public CountryRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"languages", n => { Languages = n.GetObjectValue(ToManyLanguageInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("languages", Languages); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInResponse.cs new file mode 100644 index 0000000000..92b027004b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryRelationshipsInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class CountryRelationshipsInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The languages property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyLanguageInResponse? Languages { + get { return BackingStore?.Get("languages"); } + set { BackingStore?.Set("languages", value); } + } +#nullable restore +#else + public ToManyLanguageInResponse Languages { + get { return BackingStore?.Get("languages"); } + set { BackingStore?.Set("languages", value); } + } +#endif + /// + /// Instantiates a new countryRelationshipsInResponse and sets the default values. + /// + public CountryRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static CountryRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new CountryRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"languages", n => { Languages = n.GetObjectValue(ToManyLanguageInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("languages", Languages); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryResourceType.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryResourceType.cs new file mode 100644 index 0000000000..1d78f5a9ba --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/CountryResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public enum CountryResourceType { + [EnumMember(Value = "countries")] + Countries, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/DataInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/DataInResponse.cs new file mode 100644 index 0000000000..c0e7adcb7b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/DataInResponse.cs @@ -0,0 +1,78 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class DataInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new dataInResponse and sets the default values. + /// + public DataInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch { + "countries" => new CountryDataInResponse(), + "languages" => new LanguageDataInResponse(), + _ => new DataInResponse(), + }; + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorLinks.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorLinks.cs new file mode 100644 index 0000000000..7e6c8baa71 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorLinks.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ErrorLinks : IBackedModel, IParsable { + /// The about property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#nullable restore +#else + public string About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new errorLinks and sets the default values. + /// + public ErrorLinks() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorLinks CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorLinks(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"about", n => { About = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("about", About); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorObject.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorObject.cs new file mode 100644 index 0000000000..7f3c7198ca --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorObject.cs @@ -0,0 +1,169 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ErrorObject : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The code property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#nullable restore +#else + public string Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#endif + /// The detail property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#nullable restore +#else + public string Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorLinks? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public ErrorLinks Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorObject_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorObject_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The source property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorSource? Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#nullable restore +#else + public ErrorSource Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#endif + /// The status property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#nullable restore +#else + public string Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#endif + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new errorObject and sets the default values. + /// + public ErrorObject() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"code", n => { Code = n.GetStringValue(); } }, + {"detail", n => { Detail = n.GetStringValue(); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"links", n => { Links = n.GetObjectValue(ErrorLinks.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorObject_meta.CreateFromDiscriminatorValue); } }, + {"source", n => { Source = n.GetObjectValue(ErrorSource.CreateFromDiscriminatorValue); } }, + {"status", n => { Status = n.GetStringValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("code", Code); + writer.WriteStringValue("detail", Detail); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("source", Source); + writer.WriteStringValue("status", Status); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorObject_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorObject_meta.cs new file mode 100644 index 0000000000..8408e0aea2 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorObject_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ErrorObject_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorObject_meta and sets the default values. + /// + public ErrorObject_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorResponseDocument.cs new file mode 100644 index 0000000000..d5b954dcb1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorResponseDocument.cs @@ -0,0 +1,60 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ErrorResponseDocument : ApiException, IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The errors property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Errors { + get { return BackingStore?.Get?>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#nullable restore +#else + public List Errors { + get { return BackingStore?.Get>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#endif + /// The primary error message. + public override string Message { get => base.Message; } + /// + /// Instantiates a new errorResponseDocument and sets the default values. + /// + public ErrorResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"errors", n => { Errors = n.GetCollectionOfObjectValues(ErrorObject.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("errors", Errors); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorSource.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorSource.cs new file mode 100644 index 0000000000..3f330dd405 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ErrorSource.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ErrorSource : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The header property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#nullable restore +#else + public string Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#endif + /// The parameter property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#nullable restore +#else + public string Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#endif + /// The pointer property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#nullable restore +#else + public string Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#endif + /// + /// Instantiates a new errorSource and sets the default values. + /// + public ErrorSource() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorSource CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorSource(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"header", n => { Header = n.GetStringValue(); } }, + {"parameter", n => { Parameter = n.GetStringValue(); } }, + {"pointer", n => { Pointer = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("header", Header); + writer.WriteStringValue("parameter", Parameter); + writer.WriteStringValue("pointer", Pointer); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageAttributesInResponse.cs new file mode 100644 index 0000000000..459fbb471a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageAttributesInResponse.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The code property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#nullable restore +#else + public string Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new languageAttributesInResponse and sets the default values. + /// + public LanguageAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"code", n => { Code = n.GetStringValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("code", Code); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageCollectionResponseDocument.cs new file mode 100644 index 0000000000..b8a9e3faa4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LanguageCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public LanguageCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new languageCollectionResponseDocument and sets the default values. + /// + public LanguageCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(LanguageDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(LanguageCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..5d84509432 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new languageCollectionResponseDocument_meta and sets the default values. + /// + public LanguageCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageDataInResponse.cs new file mode 100644 index 0000000000..1eae7d0ee3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageDataInResponse.cs @@ -0,0 +1,81 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LanguageAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public LanguageAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LanguageDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public LanguageDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new LanguageDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(LanguageAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(LanguageDataInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageDataInResponse_meta.cs new file mode 100644 index 0000000000..093cda80c0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new languageDataInResponse_meta and sets the default values. + /// + public LanguageDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifier.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifier.cs new file mode 100644 index 0000000000..3da61d6136 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public LanguageResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new languageIdentifier and sets the default values. + /// + public LanguageIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifierCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..d7fed9b03a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifierCollectionResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageIdentifierCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LanguageIdentifierCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public LanguageIdentifierCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new languageIdentifierCollectionResponseDocument and sets the default values. + /// + public LanguageIdentifierCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageIdentifierCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(LanguageIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(LanguageIdentifierCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifierCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifierCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..fa8ed9dc5c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageIdentifierCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LanguageIdentifierCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new languageIdentifierCollectionResponseDocument_meta and sets the default values. + /// + public LanguageIdentifierCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LanguageIdentifierCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LanguageIdentifierCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageResourceType.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageResourceType.cs new file mode 100644 index 0000000000..880ff9c453 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LanguageResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public enum LanguageResourceType { + [EnumMember(Value = "languages")] + Languages, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInRelationship.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInRelationship.cs new file mode 100644 index 0000000000..348014877d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInRelationship.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LinksInRelationship : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInRelationship and sets the default values. + /// + public LinksInRelationship() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInRelationship CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInRelationship(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceCollectionDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceCollectionDocument.cs new file mode 100644 index 0000000000..0ce41d64e1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceCollectionDocument.cs @@ -0,0 +1,137 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LinksInResourceCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceCollectionDocument and sets the default values. + /// + public LinksInResourceCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceData.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceData.cs new file mode 100644 index 0000000000..76aa642959 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceData.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LinksInResourceData : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceData and sets the default values. + /// + public LinksInResourceData() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceData CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceData(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceDocument.cs new file mode 100644 index 0000000000..d306b61e36 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LinksInResourceDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceDocument and sets the default values. + /// + public LinksInResourceDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs new file mode 100644 index 0000000000..47b032073c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs @@ -0,0 +1,153 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class LinksInResourceIdentifierCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierCollectionDocument and sets the default values. + /// + public LinksInResourceIdentifierCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInRequest.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInRequest.cs new file mode 100644 index 0000000000..237a75101b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ToManyLanguageInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyLanguageInRequest and sets the default values. + /// + public ToManyLanguageInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyLanguageInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyLanguageInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(LanguageIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInResponse.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInResponse.cs new file mode 100644 index 0000000000..ba1c9726ec --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ToManyLanguageInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyLanguageInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyLanguageInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyLanguageInResponse and sets the default values. + /// + public ToManyLanguageInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyLanguageInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyLanguageInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(LanguageIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyLanguageInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInResponse_meta.cs new file mode 100644 index 0000000000..722c526d81 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/Headers/GeneratedCode/Models/ToManyLanguageInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.Headers.GeneratedCode.Models { + public class ToManyLanguageInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyLanguageInResponse_meta and sets the default values. + /// + public ToManyLanguageInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyLanguageInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyLanguageInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj b/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj new file mode 100644 index 0000000000..cd5c358217 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj @@ -0,0 +1,40 @@ + + + net8.0 + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs new file mode 100644 index 0000000000..8ad34de5c7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/FilterTests.cs @@ -0,0 +1,175 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.QueryStrings; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.QueryStrings; + +public sealed class FilterTests : IClassFixture, QueryStringsDbContext>> +{ + private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly QueryStringFakers _fakers = new(); + + public FilterTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_filter_in_primary_resources() + { + // Arrange + List nodes = _fakers.Node.Generate(2); + nodes[0].Name = "John No Quote"; + nodes[1].Name = "Brian O'Quote"; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.AddRange(nodes); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["filter"] = "equals(name,'Brian O''Quote')" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); + response.Data.ElementAt(0).Attributes!.Name.Should().Be(nodes[1].Name); + response.Data.ElementAt(0).Attributes!.Comment.Should().Be(nodes[1].Comment); + response.Meta.ShouldNotBeNull(); + response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); + } + } + + [Fact] + public async Task Can_filter_in_secondary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(2).ToHashSet(); + node.Children.ElementAt(0).Comment = "Discount: $10"; + node.Children.ElementAt(1).Comment = "Discount: 5%"; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["filter"] = "and(startsWith(comment,'Discount:'),contains(comment,'%'))" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); + response.Data.ElementAt(0).Attributes!.Name.Should().Be(node.Children.ElementAt(1).Name); + response.Data.ElementAt(0).Attributes!.Comment.Should().Be(node.Children.ElementAt(1).Comment); + response.Meta.ShouldNotBeNull(); + response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); + } + } + + [Fact] + public async Task Can_filter_at_ToMany_relationship_endpoint() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(2).ToHashSet(); + node.Children.ElementAt(0).Children = _fakers.Node.Generate(1).ToHashSet(); + node.Children.ElementAt(1).Children = _fakers.Node.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["filter"] = "greaterThan(count(children),'1')" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeIdentifierCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Relationships.Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); + response.Meta.ShouldNotBeNull(); + response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(1)); + } + } + + [Fact] + public async Task Cannot_use_empty_filter() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["filter"] = null + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + Func action = async () => _ = await apiClient.Nodes[Unknown.StringId.Int64].GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("400"); + error.Title.Should().Be("Missing query string parameter value."); + error.Detail.Should().Be("Missing value for 'filter' query string parameter."); + error.Source.ShouldNotBeNull(); + error.Source.Parameter.Should().Be("filter"); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/DataInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/DataInResponse.cs new file mode 100644 index 0000000000..0a06745ede --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/DataInResponse.cs @@ -0,0 +1,78 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class DataInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new dataInResponse and sets the default values. + /// + public DataInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static DataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch { + "nameValuePairs" => new NameValuePairDataInResponse(), + "nodes" => new NodeDataInResponse(), + _ => new DataInResponse(), + }; + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorLinks.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorLinks.cs new file mode 100644 index 0000000000..6161d5a96b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorLinks.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ErrorLinks : IBackedModel, IParsable { + /// The about property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#nullable restore +#else + public string About { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The type property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#nullable restore +#else + public string Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } +#endif + /// + /// Instantiates a new errorLinks and sets the default values. + /// + public ErrorLinks() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorLinks CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorLinks(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"about", n => { About = n.GetStringValue(); } }, + {"type", n => { Type = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("about", About); + writer.WriteStringValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorObject.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorObject.cs new file mode 100644 index 0000000000..677a84a7c3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorObject.cs @@ -0,0 +1,169 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ErrorObject : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The code property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#nullable restore +#else + public string Code { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } +#endif + /// The detail property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#nullable restore +#else + public string Detail { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } +#endif + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorLinks? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public ErrorLinks Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorObject_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ErrorObject_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The source property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ErrorSource? Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#nullable restore +#else + public ErrorSource Source { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } +#endif + /// The status property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#nullable restore +#else + public string Status { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } +#endif + /// The title property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#nullable restore +#else + public string Title { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } +#endif + /// + /// Instantiates a new errorObject and sets the default values. + /// + public ErrorObject() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"code", n => { Code = n.GetStringValue(); } }, + {"detail", n => { Detail = n.GetStringValue(); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"links", n => { Links = n.GetObjectValue(ErrorLinks.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ErrorObject_meta.CreateFromDiscriminatorValue); } }, + {"source", n => { Source = n.GetObjectValue(ErrorSource.CreateFromDiscriminatorValue); } }, + {"status", n => { Status = n.GetStringValue(); } }, + {"title", n => { Title = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("code", Code); + writer.WriteStringValue("detail", Detail); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("source", Source); + writer.WriteStringValue("status", Status); + writer.WriteStringValue("title", Title); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorObject_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorObject_meta.cs new file mode 100644 index 0000000000..dbbdbb9555 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorObject_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ErrorObject_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new errorObject_meta and sets the default values. + /// + public ErrorObject_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorObject_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorObject_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorResponseDocument.cs new file mode 100644 index 0000000000..277dded362 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorResponseDocument.cs @@ -0,0 +1,60 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ErrorResponseDocument : ApiException, IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The errors property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Errors { + get { return BackingStore?.Get?>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#nullable restore +#else + public List Errors { + get { return BackingStore?.Get>("errors"); } + set { BackingStore?.Set("errors", value); } + } +#endif + /// The primary error message. + public override string Message { get => base.Message; } + /// + /// Instantiates a new errorResponseDocument and sets the default values. + /// + public ErrorResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"errors", n => { Errors = n.GetCollectionOfObjectValues(ErrorObject.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("errors", Errors); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorSource.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorSource.cs new file mode 100644 index 0000000000..1fb871df83 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ErrorSource.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ErrorSource : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The header property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#nullable restore +#else + public string Header { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } +#endif + /// The parameter property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#nullable restore +#else + public string Parameter { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } +#endif + /// The pointer property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#nullable restore +#else + public string Pointer { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } +#endif + /// + /// Instantiates a new errorSource and sets the default values. + /// + public ErrorSource() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ErrorSource CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ErrorSource(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"header", n => { Header = n.GetStringValue(); } }, + {"parameter", n => { Parameter = n.GetStringValue(); } }, + {"pointer", n => { Pointer = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("header", Header); + writer.WriteStringValue("parameter", Parameter); + writer.WriteStringValue("pointer", Pointer); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInRelationship.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInRelationship.cs new file mode 100644 index 0000000000..ea34f66b6d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInRelationship.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class LinksInRelationship : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInRelationship and sets the default values. + /// + public LinksInRelationship() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInRelationship CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInRelationship(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceCollectionDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceCollectionDocument.cs new file mode 100644 index 0000000000..a512383879 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceCollectionDocument.cs @@ -0,0 +1,137 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class LinksInResourceCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceCollectionDocument and sets the default values. + /// + public LinksInResourceCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceData.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceData.cs new file mode 100644 index 0000000000..bf02688ba1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceData.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class LinksInResourceData : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceData and sets the default values. + /// + public LinksInResourceData() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceData CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceData(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceDocument.cs new file mode 100644 index 0000000000..8ac07bd75b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceDocument.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class LinksInResourceDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceDocument and sets the default values. + /// + public LinksInResourceDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs new file mode 100644 index 0000000000..25207dd9f5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceIdentifierCollectionDocument.cs @@ -0,0 +1,153 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class LinksInResourceIdentifierCollectionDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The first property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#nullable restore +#else + public string First { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } +#endif + /// The last property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#nullable restore +#else + public string Last { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } +#endif + /// The next property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#nullable restore +#else + public string Next { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } +#endif + /// The prev property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#nullable restore +#else + public string Prev { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierCollectionDocument and sets the default values. + /// + public LinksInResourceIdentifierCollectionDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierCollectionDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierCollectionDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"first", n => { First = n.GetStringValue(); } }, + {"last", n => { Last = n.GetStringValue(); } }, + {"next", n => { Next = n.GetStringValue(); } }, + {"prev", n => { Prev = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("first", First); + writer.WriteStringValue("last", Last); + writer.WriteStringValue("next", Next); + writer.WriteStringValue("prev", Prev); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs new file mode 100644 index 0000000000..342d98002c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/LinksInResourceIdentifierDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class LinksInResourceIdentifierDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The describedby property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#nullable restore +#else + public string Describedby { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } +#endif + /// The related property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#nullable restore +#else + public string Related { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } +#endif + /// The self property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#nullable restore +#else + public string Self { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } +#endif + /// + /// Instantiates a new linksInResourceIdentifierDocument and sets the default values. + /// + public LinksInResourceIdentifierDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static LinksInResourceIdentifierDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new LinksInResourceIdentifierDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"describedby", n => { Describedby = n.GetStringValue(); } }, + {"related", n => { Related = n.GetStringValue(); } }, + {"self", n => { Self = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("describedby", Describedby); + writer.WriteStringValue("related", Related); + writer.WriteStringValue("self", Self); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInPatchRequest.cs new file mode 100644 index 0000000000..e3f48a7406 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInPatchRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// The value property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Value { + get { return BackingStore?.Get("value"); } + set { BackingStore?.Set("value", value); } + } +#nullable restore +#else + public string Value { + get { return BackingStore?.Get("value"); } + set { BackingStore?.Set("value", value); } + } +#endif + /// + /// Instantiates a new nameValuePairAttributesInPatchRequest and sets the default values. + /// + public NameValuePairAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + {"value", n => { Value = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteStringValue("value", Value); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInPostRequest.cs new file mode 100644 index 0000000000..82e25b01b7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInPostRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// The value property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Value { + get { return BackingStore?.Get("value"); } + set { BackingStore?.Set("value", value); } + } +#nullable restore +#else + public string Value { + get { return BackingStore?.Get("value"); } + set { BackingStore?.Set("value", value); } + } +#endif + /// + /// Instantiates a new nameValuePairAttributesInPostRequest and sets the default values. + /// + public NameValuePairAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + {"value", n => { Value = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteStringValue("value", Value); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInResponse.cs new file mode 100644 index 0000000000..89497ab6ba --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairAttributesInResponse.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// The value property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Value { + get { return BackingStore?.Get("value"); } + set { BackingStore?.Set("value", value); } + } +#nullable restore +#else + public string Value { + get { return BackingStore?.Get("value"); } + set { BackingStore?.Set("value", value); } + } +#endif + /// + /// Instantiates a new nameValuePairAttributesInResponse and sets the default values. + /// + public NameValuePairAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"name", n => { Name = n.GetStringValue(); } }, + {"value", n => { Value = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("name", Name); + writer.WriteStringValue("value", Value); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairCollectionResponseDocument.cs new file mode 100644 index 0000000000..af4f1ad716 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NameValuePairCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nameValuePairCollectionResponseDocument and sets the default values. + /// + public NameValuePairCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NameValuePairDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NameValuePairCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..0e31915d54 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nameValuePairCollectionResponseDocument_meta and sets the default values. + /// + public NameValuePairCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInPatchRequest.cs new file mode 100644 index 0000000000..0884b72823 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NameValuePairAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NameValuePairRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public NameValuePairResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new nameValuePairDataInPatchRequest and sets the default values. + /// + public NameValuePairDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(NameValuePairAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NameValuePairRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInPostRequest.cs new file mode 100644 index 0000000000..df9fefbe14 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NameValuePairAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NameValuePairRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public NameValuePairResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new nameValuePairDataInPostRequest and sets the default values. + /// + public NameValuePairDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(NameValuePairAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NameValuePairRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInResponse.cs new file mode 100644 index 0000000000..d518c2ca9d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NameValuePairAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NameValuePairDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NameValuePairRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new NameValuePairDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(NameValuePairAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NameValuePairDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NameValuePairRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInResponse_meta.cs new file mode 100644 index 0000000000..b9a222921f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nameValuePairDataInResponse_meta and sets the default values. + /// + public NameValuePairDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifier.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifier.cs new file mode 100644 index 0000000000..bc45c46563 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public NameValuePairResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new nameValuePairIdentifier and sets the default values. + /// + public NameValuePairIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifierCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..82b599d92b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifierCollectionResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairIdentifierCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairIdentifierCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NameValuePairIdentifierCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nameValuePairIdentifierCollectionResponseDocument and sets the default values. + /// + public NameValuePairIdentifierCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairIdentifierCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NameValuePairIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NameValuePairIdentifierCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifierCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifierCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..13bffcc9b3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairIdentifierCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairIdentifierCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nameValuePairIdentifierCollectionResponseDocument_meta and sets the default values. + /// + public NameValuePairIdentifierCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairIdentifierCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairIdentifierCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPatchRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPatchRequestDocument.cs new file mode 100644 index 0000000000..57dd4fc438 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairPatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NameValuePairDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nameValuePairPatchRequestDocument and sets the default values. + /// + public NameValuePairPatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairPatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairPatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NameValuePairDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPostRequestDocument.cs new file mode 100644 index 0000000000..1e988f4687 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairPostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NameValuePairDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nameValuePairPostRequestDocument and sets the default values. + /// + public NameValuePairPostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairPostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairPostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NameValuePairDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPrimaryResponseDocument.cs new file mode 100644 index 0000000000..b26aed2bb3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairPrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairs? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NameValuePairs Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairPrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NameValuePairPrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nameValuePairPrimaryResponseDocument and sets the default values. + /// + public NameValuePairPrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairPrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairPrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NameValuePairs.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NameValuePairPrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..c79b1661a8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairPrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairPrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nameValuePairPrimaryResponseDocument_meta and sets the default values. + /// + public NameValuePairPrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairPrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairPrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..923eef08a4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInPatchRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairRelationshipsInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The owner property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneNodeInRequest? Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#nullable restore +#else + public ToOneNodeInRequest Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#endif + /// + /// Instantiates a new nameValuePairRelationshipsInPatchRequest and sets the default values. + /// + public NameValuePairRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"owner", n => { Owner = n.GetObjectValue(ToOneNodeInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("owner", Owner); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..15a1e2898c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInPostRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairRelationshipsInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The owner property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneNodeInRequest? Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#nullable restore +#else + public ToOneNodeInRequest Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#endif + /// + /// Instantiates a new nameValuePairRelationshipsInPostRequest and sets the default values. + /// + public NameValuePairRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"owner", n => { Owner = n.GetObjectValue(ToOneNodeInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("owner", Owner); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInResponse.cs new file mode 100644 index 0000000000..1d8dd7c6f5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairRelationshipsInResponse.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairRelationshipsInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The owner property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneNodeInResponse? Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#nullable restore +#else + public ToOneNodeInResponse Owner { + get { return BackingStore?.Get("owner"); } + set { BackingStore?.Set("owner", value); } + } +#endif + /// + /// Instantiates a new nameValuePairRelationshipsInResponse and sets the default values. + /// + public NameValuePairRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"owner", n => { Owner = n.GetObjectValue(ToOneNodeInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("owner", Owner); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairResourceType.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairResourceType.cs new file mode 100644 index 0000000000..d3fa1a1edc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public enum NameValuePairResourceType { + [EnumMember(Value = "nameValuePairs")] + NameValuePairs, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairs.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairs.cs new file mode 100644 index 0000000000..25a3b758ca --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairs.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairs : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NameValuePairAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairs_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NameValuePairs_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NameValuePairRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NameValuePairRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new NameValuePairs CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairs(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(NameValuePairAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NameValuePairs_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NameValuePairRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairs_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairs_meta.cs new file mode 100644 index 0000000000..97e001855d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NameValuePairs_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NameValuePairs_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nameValuePairs_meta and sets the default values. + /// + public NameValuePairs_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NameValuePairs_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NameValuePairs_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInPatchRequest.cs new file mode 100644 index 0000000000..12a9caaf1b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInPatchRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeAttributesInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The comment property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Comment { + get { return BackingStore?.Get("comment"); } + set { BackingStore?.Set("comment", value); } + } +#nullable restore +#else + public string Comment { + get { return BackingStore?.Get("comment"); } + set { BackingStore?.Set("comment", value); } + } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new nodeAttributesInPatchRequest and sets the default values. + /// + public NodeAttributesInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeAttributesInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeAttributesInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", n => { Comment = n.GetStringValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInPostRequest.cs new file mode 100644 index 0000000000..265f71daee --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInPostRequest.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeAttributesInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The comment property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Comment { + get { return BackingStore?.Get("comment"); } + set { BackingStore?.Set("comment", value); } + } +#nullable restore +#else + public string Comment { + get { return BackingStore?.Get("comment"); } + set { BackingStore?.Set("comment", value); } + } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new nodeAttributesInPostRequest and sets the default values. + /// + public NodeAttributesInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeAttributesInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeAttributesInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", n => { Comment = n.GetStringValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInResponse.cs new file mode 100644 index 0000000000..f82419e9f7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeAttributesInResponse.cs @@ -0,0 +1,73 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeAttributesInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The comment property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Comment { + get { return BackingStore?.Get("comment"); } + set { BackingStore?.Set("comment", value); } + } +#nullable restore +#else + public string Comment { + get { return BackingStore?.Get("comment"); } + set { BackingStore?.Set("comment", value); } + } +#endif + /// The name property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#nullable restore +#else + public string Name { + get { return BackingStore?.Get("name"); } + set { BackingStore?.Set("name", value); } + } +#endif + /// + /// Instantiates a new nodeAttributesInResponse and sets the default values. + /// + public NodeAttributesInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeAttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeAttributesInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"comment", n => { Comment = n.GetStringValue(); } }, + {"name", n => { Name = n.GetStringValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("comment", Comment); + writer.WriteStringValue("name", Name); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeCollectionResponseDocument.cs new file mode 100644 index 0000000000..97ffe6f896 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeCollectionResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NodeCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nodeCollectionResponseDocument and sets the default values. + /// + public NodeCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NodeDataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NodeCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..fcfb417982 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodeCollectionResponseDocument_meta and sets the default values. + /// + public NodeCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInPatchRequest.cs new file mode 100644 index 0000000000..51b7f9db02 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInPatchRequest.cs @@ -0,0 +1,96 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeDataInPatchRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeAttributesInPatchRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NodeAttributesInPatchRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeRelationshipsInPatchRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NodeRelationshipsInPatchRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public NodeResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new nodeDataInPatchRequest and sets the default values. + /// + public NodeDataInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeDataInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeDataInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(NodeAttributesInPatchRequest.CreateFromDiscriminatorValue); } }, + {"id", n => { Id = n.GetStringValue(); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NodeRelationshipsInPatchRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteStringValue("id", Id); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInPostRequest.cs new file mode 100644 index 0000000000..6694277fe4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInPostRequest.cs @@ -0,0 +1,80 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeDataInPostRequest : IBackedModel, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeAttributesInPostRequest? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NodeAttributesInPostRequest Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeRelationshipsInPostRequest? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NodeRelationshipsInPostRequest Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// The type property + public NodeResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new nodeDataInPostRequest and sets the default values. + /// + public NodeDataInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeDataInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeDataInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"attributes", n => { Attributes = n.GetObjectValue(NodeAttributesInPostRequest.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NodeRelationshipsInPostRequest.CreateFromDiscriminatorValue); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("relationships", Relationships); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInResponse.cs new file mode 100644 index 0000000000..701e32fbf7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInResponse.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeDataInResponse : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NodeAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeDataInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NodeDataInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NodeRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new NodeDataInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeDataInResponse(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(NodeAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NodeDataInResponse_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NodeRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInResponse_meta.cs new file mode 100644 index 0000000000..aaa1cda671 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeDataInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeDataInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodeDataInResponse_meta and sets the default values. + /// + public NodeDataInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeDataInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeDataInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifier.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifier.cs new file mode 100644 index 0000000000..453ebec678 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifier.cs @@ -0,0 +1,64 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeIdentifier : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The id property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public string? Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#nullable restore +#else + public string Id { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } +#endif + /// The type property + public NodeResourceType? Type { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + /// + /// Instantiates a new nodeIdentifier and sets the default values. + /// + public NodeIdentifier() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeIdentifier(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"id", n => { Id = n.GetStringValue(); } }, + {"type", n => { Type = n.GetEnumValue(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteStringValue("id", Id); + writer.WriteEnumValue("type", Type); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..5214782009 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierCollectionResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeIdentifierCollectionResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierCollectionDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierCollectionDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifierCollectionResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NodeIdentifierCollectionResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nodeIdentifierCollectionResponseDocument and sets the default values. + /// + public NodeIdentifierCollectionResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeIdentifierCollectionResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NodeIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierCollectionDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NodeIdentifierCollectionResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierCollectionResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierCollectionResponseDocument_meta.cs new file mode 100644 index 0000000000..41066dfbb8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierCollectionResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeIdentifierCollectionResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodeIdentifierCollectionResponseDocument_meta and sets the default values. + /// + public NodeIdentifierCollectionResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeIdentifierCollectionResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeIdentifierCollectionResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierResponseDocument.cs new file mode 100644 index 0000000000..60ea5d2fa6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeIdentifierResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifierResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NodeIdentifierResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nodeIdentifierResponseDocument and sets the default values. + /// + public NodeIdentifierResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeIdentifierResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NodeIdentifierResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierResponseDocument_meta.cs new file mode 100644 index 0000000000..c4e140f45d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeIdentifierResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeIdentifierResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodeIdentifierResponseDocument_meta and sets the default values. + /// + public NodeIdentifierResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeIdentifierResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeIdentifierResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePatchRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePatchRequestDocument.cs new file mode 100644 index 0000000000..b3e5bff4a7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePatchRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodePatchRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeDataInPatchRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeDataInPatchRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nodePatchRequestDocument and sets the default values. + /// + public NodePatchRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodePatchRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodePatchRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeDataInPatchRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePostRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePostRequestDocument.cs new file mode 100644 index 0000000000..959122d0a4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePostRequestDocument.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodePostRequestDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeDataInPostRequest? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeDataInPostRequest Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nodePostRequestDocument and sets the default values. + /// + public NodePostRequestDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodePostRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodePostRequestDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeDataInPostRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePrimaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePrimaryResponseDocument.cs new file mode 100644 index 0000000000..a7b1890552 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePrimaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodePrimaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Nodes? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Nodes Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodePrimaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NodePrimaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nodePrimaryResponseDocument and sets the default values. + /// + public NodePrimaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodePrimaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodePrimaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Nodes.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NodePrimaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePrimaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePrimaryResponseDocument_meta.cs new file mode 100644 index 0000000000..662307f923 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodePrimaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodePrimaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodePrimaryResponseDocument_meta and sets the default values. + /// + public NodePrimaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodePrimaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodePrimaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInPatchRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInPatchRequest.cs new file mode 100644 index 0000000000..651c4d4c40 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInPatchRequest.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeRelationshipsInPatchRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The children property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNodeInRequest? Children { + get { return BackingStore?.Get("children"); } + set { BackingStore?.Set("children", value); } + } +#nullable restore +#else + public ToManyNodeInRequest Children { + get { return BackingStore?.Get("children"); } + set { BackingStore?.Set("children", value); } + } +#endif + /// The parent property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneNodeInRequest? Parent { + get { return BackingStore?.Get("parent"); } + set { BackingStore?.Set("parent", value); } + } +#nullable restore +#else + public NullableToOneNodeInRequest Parent { + get { return BackingStore?.Get("parent"); } + set { BackingStore?.Set("parent", value); } + } +#endif + /// The values property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNameValuePairInRequest? Values { + get { return BackingStore?.Get("values"); } + set { BackingStore?.Set("values", value); } + } +#nullable restore +#else + public ToManyNameValuePairInRequest Values { + get { return BackingStore?.Get("values"); } + set { BackingStore?.Set("values", value); } + } +#endif + /// + /// Instantiates a new nodeRelationshipsInPatchRequest and sets the default values. + /// + public NodeRelationshipsInPatchRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeRelationshipsInPatchRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeRelationshipsInPatchRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"children", n => { Children = n.GetObjectValue(ToManyNodeInRequest.CreateFromDiscriminatorValue); } }, + {"parent", n => { Parent = n.GetObjectValue(NullableToOneNodeInRequest.CreateFromDiscriminatorValue); } }, + {"values", n => { Values = n.GetObjectValue(ToManyNameValuePairInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("children", Children); + writer.WriteObjectValue("parent", Parent); + writer.WriteObjectValue("values", Values); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInPostRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInPostRequest.cs new file mode 100644 index 0000000000..0930e89528 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInPostRequest.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeRelationshipsInPostRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The children property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNodeInRequest? Children { + get { return BackingStore?.Get("children"); } + set { BackingStore?.Set("children", value); } + } +#nullable restore +#else + public ToManyNodeInRequest Children { + get { return BackingStore?.Get("children"); } + set { BackingStore?.Set("children", value); } + } +#endif + /// The parent property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneNodeInRequest? Parent { + get { return BackingStore?.Get("parent"); } + set { BackingStore?.Set("parent", value); } + } +#nullable restore +#else + public NullableToOneNodeInRequest Parent { + get { return BackingStore?.Get("parent"); } + set { BackingStore?.Set("parent", value); } + } +#endif + /// The values property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNameValuePairInRequest? Values { + get { return BackingStore?.Get("values"); } + set { BackingStore?.Set("values", value); } + } +#nullable restore +#else + public ToManyNameValuePairInRequest Values { + get { return BackingStore?.Get("values"); } + set { BackingStore?.Set("values", value); } + } +#endif + /// + /// Instantiates a new nodeRelationshipsInPostRequest and sets the default values. + /// + public NodeRelationshipsInPostRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeRelationshipsInPostRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeRelationshipsInPostRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"children", n => { Children = n.GetObjectValue(ToManyNodeInRequest.CreateFromDiscriminatorValue); } }, + {"parent", n => { Parent = n.GetObjectValue(NullableToOneNodeInRequest.CreateFromDiscriminatorValue); } }, + {"values", n => { Values = n.GetObjectValue(ToManyNameValuePairInRequest.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("children", Children); + writer.WriteObjectValue("parent", Parent); + writer.WriteObjectValue("values", Values); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInResponse.cs new file mode 100644 index 0000000000..b90f1fd0b4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeRelationshipsInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeRelationshipsInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The children property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNodeInResponse? Children { + get { return BackingStore?.Get("children"); } + set { BackingStore?.Set("children", value); } + } +#nullable restore +#else + public ToManyNodeInResponse Children { + get { return BackingStore?.Get("children"); } + set { BackingStore?.Set("children", value); } + } +#endif + /// The parent property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneNodeInResponse? Parent { + get { return BackingStore?.Get("parent"); } + set { BackingStore?.Set("parent", value); } + } +#nullable restore +#else + public NullableToOneNodeInResponse Parent { + get { return BackingStore?.Get("parent"); } + set { BackingStore?.Set("parent", value); } + } +#endif + /// The values property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNameValuePairInResponse? Values { + get { return BackingStore?.Get("values"); } + set { BackingStore?.Set("values", value); } + } +#nullable restore +#else + public ToManyNameValuePairInResponse Values { + get { return BackingStore?.Get("values"); } + set { BackingStore?.Set("values", value); } + } +#endif + /// + /// Instantiates a new nodeRelationshipsInResponse and sets the default values. + /// + public NodeRelationshipsInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeRelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeRelationshipsInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"children", n => { Children = n.GetObjectValue(ToManyNodeInResponse.CreateFromDiscriminatorValue); } }, + {"parent", n => { Parent = n.GetObjectValue(NullableToOneNodeInResponse.CreateFromDiscriminatorValue); } }, + {"values", n => { Values = n.GetObjectValue(ToManyNameValuePairInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("children", Children); + writer.WriteObjectValue("parent", Parent); + writer.WriteObjectValue("values", Values); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeResourceType.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeResourceType.cs new file mode 100644 index 0000000000..669d7f543c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeResourceType.cs @@ -0,0 +1,9 @@ +// +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public enum NodeResourceType { + [EnumMember(Value = "nodes")] + Nodes, + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeSecondaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeSecondaryResponseDocument.cs new file mode 100644 index 0000000000..c6ff108eb8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeSecondaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeSecondaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Owner? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Owner Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeSecondaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NodeSecondaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nodeSecondaryResponseDocument and sets the default values. + /// + public NodeSecondaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeSecondaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeSecondaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Owner.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NodeSecondaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeSecondaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeSecondaryResponseDocument_meta.cs new file mode 100644 index 0000000000..e6a7659ef4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NodeSecondaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NodeSecondaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodeSecondaryResponseDocument_meta and sets the default values. + /// + public NodeSecondaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NodeSecondaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NodeSecondaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Nodes.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Nodes.cs new file mode 100644 index 0000000000..43048e29f3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Nodes.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class Nodes : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NodeAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Nodes_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Nodes_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NodeRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Nodes CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Nodes(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(NodeAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Nodes_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NodeRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Nodes_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Nodes_meta.cs new file mode 100644 index 0000000000..3eb78d60d1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Nodes_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class Nodes_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nodes_meta and sets the default values. + /// + public Nodes_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Nodes_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Nodes_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeIdentifierResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeIdentifierResponseDocument.cs new file mode 100644 index 0000000000..605caff767 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeIdentifierResponseDocument.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableNodeIdentifierResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceIdentifierDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceIdentifierDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableNodeIdentifierResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableNodeIdentifierResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableNodeIdentifierResponseDocument and sets the default values. + /// + public NullableNodeIdentifierResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableNodeIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableNodeIdentifierResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceIdentifierDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableNodeIdentifierResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeIdentifierResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeIdentifierResponseDocument_meta.cs new file mode 100644 index 0000000000..35ebdd3f63 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeIdentifierResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableNodeIdentifierResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableNodeIdentifierResponseDocument_meta and sets the default values. + /// + public NullableNodeIdentifierResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableNodeIdentifierResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableNodeIdentifierResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeSecondaryResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeSecondaryResponseDocument.cs new file mode 100644 index 0000000000..482b4039e8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeSecondaryResponseDocument.cs @@ -0,0 +1,105 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableNodeSecondaryResponseDocument : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Parent? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public Parent Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The included property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Included { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } +#nullable restore +#else + public List Included { + get { return BackingStore?.Get>("included"); } + set { BackingStore?.Set("included", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceDocument? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceDocument Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableNodeSecondaryResponseDocument_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableNodeSecondaryResponseDocument_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableNodeSecondaryResponseDocument and sets the default values. + /// + public NullableNodeSecondaryResponseDocument() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableNodeSecondaryResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableNodeSecondaryResponseDocument(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(Parent.CreateFromDiscriminatorValue); } }, + {"included", n => { Included = n.GetCollectionOfObjectValues(DataInResponse.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceDocument.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableNodeSecondaryResponseDocument_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteCollectionOfObjectValues("included", Included); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeSecondaryResponseDocument_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeSecondaryResponseDocument_meta.cs new file mode 100644 index 0000000000..13e12e9a38 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableNodeSecondaryResponseDocument_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableNodeSecondaryResponseDocument_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableNodeSecondaryResponseDocument_meta and sets the default values. + /// + public NullableNodeSecondaryResponseDocument_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableNodeSecondaryResponseDocument_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableNodeSecondaryResponseDocument_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInRequest.cs new file mode 100644 index 0000000000..4c0ab1ff09 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableToOneNodeInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new nullableToOneNodeInRequest and sets the default values. + /// + public NullableToOneNodeInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOneNodeInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOneNodeInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeIdentifier.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInResponse.cs new file mode 100644 index 0000000000..5eaa208a00 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableToOneNodeInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NullableToOneNodeInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public NullableToOneNodeInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new nullableToOneNodeInResponse and sets the default values. + /// + public NullableToOneNodeInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOneNodeInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOneNodeInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(NullableToOneNodeInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInResponse_meta.cs new file mode 100644 index 0000000000..4b91235e8d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/NullableToOneNodeInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class NullableToOneNodeInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new nullableToOneNodeInResponse_meta and sets the default values. + /// + public NullableToOneNodeInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static NullableToOneNodeInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new NullableToOneNodeInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Owner.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Owner.cs new file mode 100644 index 0000000000..96948e7361 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Owner.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class Owner : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NodeAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Owner_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Owner_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NodeRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Owner CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Owner(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(NodeAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Owner_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NodeRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Owner_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Owner_meta.cs new file mode 100644 index 0000000000..ec1c0a136d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Owner_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class Owner_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new owner_meta and sets the default values. + /// + public Owner_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Owner_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Owner_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Parent.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Parent.cs new file mode 100644 index 0000000000..e122cfe54a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Parent.cs @@ -0,0 +1,97 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class Parent : DataInResponse, IParsable { + /// The attributes property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeAttributesInResponse? Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#nullable restore +#else + public NodeAttributesInResponse Attributes { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInResourceData? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInResourceData Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public Parent_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public Parent_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// The relationships property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeRelationshipsInResponse? Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#nullable restore +#else + public NodeRelationshipsInResponse Relationships { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } +#endif + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static new Parent CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Parent(); + } + /// + /// The deserialization information for the current model + /// + public override IDictionary> GetFieldDeserializers() { + return new Dictionary>(base.GetFieldDeserializers()) { + {"attributes", n => { Attributes = n.GetObjectValue(NodeAttributesInResponse.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInResourceData.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(Parent_meta.CreateFromDiscriminatorValue); } }, + {"relationships", n => { Relationships = n.GetObjectValue(NodeRelationshipsInResponse.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public override void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + base.Serialize(writer); + writer.WriteObjectValue("attributes", Attributes); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + writer.WriteObjectValue("relationships", Relationships); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Parent_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Parent_meta.cs new file mode 100644 index 0000000000..6d24696fc6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/Parent_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class Parent_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new parent_meta and sets the default values. + /// + public Parent_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static Parent_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new Parent_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInRequest.cs new file mode 100644 index 0000000000..26f0a57344 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToManyNameValuePairInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyNameValuePairInRequest and sets the default values. + /// + public ToManyNameValuePairInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyNameValuePairInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyNameValuePairInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NameValuePairIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInResponse.cs new file mode 100644 index 0000000000..31235b3e27 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToManyNameValuePairInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNameValuePairInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyNameValuePairInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyNameValuePairInResponse and sets the default values. + /// + public ToManyNameValuePairInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyNameValuePairInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyNameValuePairInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NameValuePairIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyNameValuePairInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInResponse_meta.cs new file mode 100644 index 0000000000..d516af03f4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNameValuePairInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToManyNameValuePairInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyNameValuePairInResponse_meta and sets the default values. + /// + public ToManyNameValuePairInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyNameValuePairInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyNameValuePairInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInRequest.cs new file mode 100644 index 0000000000..8c41d38baa --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToManyNodeInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toManyNodeInRequest and sets the default values. + /// + public ToManyNodeInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyNodeInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyNodeInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NodeIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInResponse.cs new file mode 100644 index 0000000000..0fada50c4e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToManyNodeInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public List? Data { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public List Data { + get { return BackingStore?.Get>("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToManyNodeInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToManyNodeInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toManyNodeInResponse and sets the default values. + /// + public ToManyNodeInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyNodeInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyNodeInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetCollectionOfObjectValues(NodeIdentifier.CreateFromDiscriminatorValue)?.ToList(); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToManyNodeInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteCollectionOfObjectValues("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInResponse_meta.cs new file mode 100644 index 0000000000..e1e0cc4d1d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToManyNodeInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToManyNodeInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toManyNodeInResponse_meta and sets the default values. + /// + public ToManyNodeInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToManyNodeInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToManyNodeInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInRequest.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInRequest.cs new file mode 100644 index 0000000000..72e967ece3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInRequest.cs @@ -0,0 +1,57 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToOneNodeInRequest : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// + /// Instantiates a new toOneNodeInRequest and sets the default values. + /// + public ToOneNodeInRequest() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOneNodeInRequest CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOneNodeInRequest(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeIdentifier.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInResponse.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInResponse.cs new file mode 100644 index 0000000000..f69d9ca672 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInResponse.cs @@ -0,0 +1,89 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToOneNodeInResponse : IBackedModel, IParsable { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// The data property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public NodeIdentifier? Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#nullable restore +#else + public NodeIdentifier Data { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } +#endif + /// The links property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public LinksInRelationship? Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#nullable restore +#else + public LinksInRelationship Links { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } +#endif + /// The meta property +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + public ToOneNodeInResponse_meta? Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#nullable restore +#else + public ToOneNodeInResponse_meta Meta { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } +#endif + /// + /// Instantiates a new toOneNodeInResponse and sets the default values. + /// + public ToOneNodeInResponse() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOneNodeInResponse CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOneNodeInResponse(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + {"data", n => { Data = n.GetObjectValue(NodeIdentifier.CreateFromDiscriminatorValue); } }, + {"links", n => { Links = n.GetObjectValue(LinksInRelationship.CreateFromDiscriminatorValue); } }, + {"meta", n => { Meta = n.GetObjectValue(ToOneNodeInResponse_meta.CreateFromDiscriminatorValue); } }, + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteObjectValue("data", Data); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInResponse_meta.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInResponse_meta.cs new file mode 100644 index 0000000000..bf6a2e861c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Models/ToOneNodeInResponse_meta.cs @@ -0,0 +1,48 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models { + public class ToOneNodeInResponse_meta : IAdditionalDataHolder, IBackedModel, IParsable { + /// Stores additional data not described in the OpenAPI description found when deserializing. Can be used for serialization as well. + public IDictionary AdditionalData { + get { return BackingStore?.Get>("AdditionalData"); } + set { BackingStore?.Set("AdditionalData", value); } + } + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + /// + /// Instantiates a new toOneNodeInResponse_meta and sets the default values. + /// + public ToOneNodeInResponse_meta() { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// The parse node to use to read the discriminator value and create the object + public static ToOneNodeInResponse_meta CreateFromDiscriminatorValue(IParseNode parseNode) { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new ToOneNodeInResponse_meta(); + } + /// + /// The deserialization information for the current model + /// + public virtual IDictionary> GetFieldDeserializers() { + return new Dictionary> { + }; + } + /// + /// Serializes information the current object + /// + /// Serialization writer to use to serialize this model + public virtual void Serialize(ISerializationWriter writer) { + _ = writer ?? throw new ArgumentNullException(nameof(writer)); + writer.WriteAdditionalData(AdditionalData); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/NameValuePairsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/NameValuePairsItemRequestBuilder.cs new file mode 100644 index 0000000000..03fc4cfc4e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/NameValuePairsItemRequestBuilder.cs @@ -0,0 +1,234 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item.Owner; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item.Relationships; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item { + /// + /// Builds and executes requests for operations under \nameValuePairs\{id} + /// + public class NameValuePairsItemRequestBuilder : BaseRequestBuilder { + /// The owner property + public OwnerRequestBuilder Owner { get => + new OwnerRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new NameValuePairsItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public NameValuePairsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new NameValuePairsItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public NameValuePairsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing nameValuePair by its identifier. + /// + /// 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 DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual nameValuePair by its identifier. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NameValuePairPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing nameValuePair. + /// + /// The request body + /// 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 PatchAsync(NameValuePairPatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(NameValuePairPatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NameValuePairPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing nameValuePair by its identifier. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Retrieves an individual nameValuePair by its identifier. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Updates an existing nameValuePair. + /// + /// The request body + /// 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(NameValuePairPatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(NameValuePairPatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public NameValuePairsItemRequestBuilder WithUrl(string rawUrl) { + return new NameValuePairsItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual nameValuePair by its identifier. + /// + public class NameValuePairsItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class NameValuePairsItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Updates an existing nameValuePair. + /// + public class NameValuePairsItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Owner/OwnerRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Owner/OwnerRequestBuilder.cs new file mode 100644 index 0000000000..eabf5c445e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Owner/OwnerRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item.Owner { + /// + /// Builds and executes requests for operations under \nameValuePairs\{id}\owner + /// + public class OwnerRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}/owner{?query*}", pathParameters) { + } + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}/owner{?query*}", rawUrl) { + } + /// + /// Retrieves the related node of an individual nameValuePair's owner relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodeSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related node of an individual nameValuePair's owner relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public OwnerRequestBuilder WithUrl(string rawUrl) { + return new OwnerRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related node of an individual nameValuePair's owner relationship. + /// + public class OwnerRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class OwnerRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Relationships/Owner/OwnerRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Relationships/Owner/OwnerRequestBuilder.cs new file mode 100644 index 0000000000..1d03068a0e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Relationships/Owner/OwnerRequestBuilder.cs @@ -0,0 +1,174 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item.Relationships.Owner { + /// + /// Builds and executes requests for operations under \nameValuePairs\{id}\relationships\owner + /// + public class OwnerRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}/relationships/owner{?query*}", pathParameters) { + } + /// + /// Instantiates a new OwnerRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OwnerRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}/relationships/owner{?query*}", rawUrl) { + } + /// + /// Retrieves the related node identity of an individual nameValuePair's owner relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodeIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns an existing node to the owner relationship of an individual nameValuePair. + /// + /// The request body + /// 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 PatchAsync(ToOneNodeInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToOneNodeInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related node identity of an individual nameValuePair's owner relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns an existing node to the owner relationship of an individual nameValuePair. + /// + /// The request body + /// 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(ToOneNodeInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToOneNodeInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public OwnerRequestBuilder WithUrl(string rawUrl) { + return new OwnerRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related node identity of an individual nameValuePair's owner relationship. + /// + public class OwnerRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class OwnerRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..af4128e86a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,33 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item.Relationships.Owner; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item.Relationships { + /// + /// Builds and executes requests for operations under \nameValuePairs\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The owner property + public OwnerRequestBuilder Owner { get => + new OwnerRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs/{id}/relationships", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs new file mode 100644 index 0000000000..74592af605 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/NameValuePairs/NameValuePairsRequestBuilder.cs @@ -0,0 +1,197 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs.Item; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs { + /// + /// Builds and executes requests for operations under \nameValuePairs + /// + public class NameValuePairsRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.nameValuePairs.item collection + /// The identifier of the nameValuePair to retrieve. + public NameValuePairsItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new NameValuePairsItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new NameValuePairsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public NameValuePairsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs{?query*}", pathParameters) { + } + /// + /// Instantiates a new NameValuePairsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public NameValuePairsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nameValuePairs{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of nameValuePairs. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NameValuePairCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new nameValuePair. + /// + /// The request body + /// 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 PostAsync(NameValuePairPostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(NameValuePairPostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NameValuePairPrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of nameValuePairs. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Creates a new nameValuePair. + /// + /// The request body + /// 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 ToPostRequestInformation(NameValuePairPostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(NameValuePairPostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public NameValuePairsRequestBuilder WithUrl(string rawUrl) { + return new NameValuePairsRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of nameValuePairs. + /// + public class NameValuePairsRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class NameValuePairsRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Creates a new nameValuePair. + /// + public class NameValuePairsRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Children/ChildrenRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Children/ChildrenRequestBuilder.cs new file mode 100644 index 0000000000..d82560dcc3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Children/ChildrenRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Children { + /// + /// Builds and executes requests for operations under \nodes\{id}\children + /// + public class ChildrenRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new ChildrenRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ChildrenRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/children{?query*}", pathParameters) { + } + /// + /// Instantiates a new ChildrenRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ChildrenRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/children{?query*}", rawUrl) { + } + /// + /// Retrieves the related nodes of an individual node's children relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodeCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related nodes of an individual node's children relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ChildrenRequestBuilder WithUrl(string rawUrl) { + return new ChildrenRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related nodes of an individual node's children relationship. + /// + public class ChildrenRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ChildrenRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/NodesItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/NodesItemRequestBuilder.cs new file mode 100644 index 0000000000..e38e26fb88 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/NodesItemRequestBuilder.cs @@ -0,0 +1,244 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Children; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Parent; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Values; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item { + /// + /// Builds and executes requests for operations under \nodes\{id} + /// + public class NodesItemRequestBuilder : BaseRequestBuilder { + /// The children property + public ChildrenRequestBuilder Children { get => + new ChildrenRequestBuilder(PathParameters, RequestAdapter); + } + /// The parent property + public ParentRequestBuilder Parent { get => + new ParentRequestBuilder(PathParameters, RequestAdapter); + } + /// The relationships property + public RelationshipsRequestBuilder Relationships { get => + new RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + /// The values property + public ValuesRequestBuilder Values { get => + new ValuesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new NodesItemRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public NodesItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}{?query*}", pathParameters) { + } + /// + /// Instantiates a new NodesItemRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public NodesItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}{?query*}", rawUrl) { + } + /// + /// Deletes an existing node by its identifier. + /// + /// 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 DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves an individual node by its identifier. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodePrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Updates an existing node. + /// + /// The request body + /// 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 PatchAsync(NodePatchRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(NodePatchRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodePrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Deletes an existing node by its identifier. + /// + /// 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 ToDeleteRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Retrieves an individual node by its identifier. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Updates an existing node. + /// + /// The request body + /// 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(NodePatchRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(NodePatchRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public NodesItemRequestBuilder WithUrl(string rawUrl) { + return new NodesItemRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves an individual node by its identifier. + /// + public class NodesItemRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class NodesItemRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Updates an existing node. + /// + public class NodesItemRequestBuilderPatchQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Parent/ParentRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Parent/ParentRequestBuilder.cs new file mode 100644 index 0000000000..7268cf9075 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Parent/ParentRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Parent { + /// + /// Builds and executes requests for operations under \nodes\{id}\parent + /// + public class ParentRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new ParentRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ParentRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/parent{?query*}", pathParameters) { + } + /// + /// Instantiates a new ParentRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ParentRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/parent{?query*}", rawUrl) { + } + /// + /// Retrieves the related node of an individual node's parent relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullableNodeSecondaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related node of an individual node's parent relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ParentRequestBuilder WithUrl(string rawUrl) { + return new ParentRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related node of an individual node's parent relationship. + /// + public class ParentRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ParentRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Children/ChildrenRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Children/ChildrenRequestBuilder.cs new file mode 100644 index 0000000000..6fdc78f3d1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Children/ChildrenRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships.Children { + /// + /// Builds and executes requests for operations under \nodes\{id}\relationships\children + /// + public class ChildrenRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new ChildrenRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ChildrenRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships/children{?query*}", pathParameters) { + } + /// + /// Instantiates a new ChildrenRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ChildrenRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships/children{?query*}", rawUrl) { + } + /// + /// Removes existing nodes from the children relationship of an individual node. + /// + /// The request body + /// 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 DeleteAsync(ToManyNodeInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyNodeInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related node identities of an individual node's children relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodeIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing nodes to the children relationship of an individual node. + /// + /// The request body + /// 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 PatchAsync(ToManyNodeInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyNodeInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing nodes to the children relationship of an individual node. + /// + /// The request body + /// 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 PostAsync(ToManyNodeInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyNodeInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing nodes from the children relationship of an individual node. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyNodeInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyNodeInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related node identities of an individual node's children relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing nodes to the children relationship of an individual node. + /// + /// The request body + /// 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(ToManyNodeInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyNodeInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing nodes to the children relationship of an individual node. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyNodeInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyNodeInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ChildrenRequestBuilder WithUrl(string rawUrl) { + return new ChildrenRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related node identities of an individual node's children relationship. + /// + public class ChildrenRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ChildrenRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Parent/ParentRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Parent/ParentRequestBuilder.cs new file mode 100644 index 0000000000..29207b1516 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Parent/ParentRequestBuilder.cs @@ -0,0 +1,174 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships.Parent { + /// + /// Builds and executes requests for operations under \nodes\{id}\relationships\parent + /// + public class ParentRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new ParentRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ParentRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships/parent{?query*}", pathParameters) { + } + /// + /// Instantiates a new ParentRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ParentRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships/parent{?query*}", rawUrl) { + } + /// + /// Retrieves the related node identity of an individual node's parent relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NullableNodeIdentifierResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Clears or assigns an existing node to the parent relationship of an individual node. + /// + /// The request body + /// 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 PatchAsync(NullableToOneNodeInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(NullableToOneNodeInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related node identity of an individual node's parent relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Clears or assigns an existing node to the parent relationship of an individual node. + /// + /// The request body + /// 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(NullableToOneNodeInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(NullableToOneNodeInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ParentRequestBuilder WithUrl(string rawUrl) { + return new ParentRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related node identity of an individual node's parent relationship. + /// + public class ParentRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ParentRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..f35eb431f4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,43 @@ +// +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships.Children; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships.Parent; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships.Values; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships { + /// + /// Builds and executes requests for operations under \nodes\{id}\relationships + /// + public class RelationshipsRequestBuilder : BaseRequestBuilder { + /// The children property + public ChildrenRequestBuilder Children { get => + new ChildrenRequestBuilder(PathParameters, RequestAdapter); + } + /// The parent property + public ParentRequestBuilder Parent { get => + new ParentRequestBuilder(PathParameters, RequestAdapter); + } + /// The values property + public ValuesRequestBuilder Values { get => + new ValuesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships", pathParameters) { + } + /// + /// Instantiates a new RelationshipsRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships", rawUrl) { + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Values/ValuesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Values/ValuesRequestBuilder.cs new file mode 100644 index 0000000000..2c26297504 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Relationships/Values/ValuesRequestBuilder.cs @@ -0,0 +1,256 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Relationships.Values { + /// + /// Builds and executes requests for operations under \nodes\{id}\relationships\values + /// + public class ValuesRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new ValuesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ValuesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships/values{?query*}", pathParameters) { + } + /// + /// Instantiates a new ValuesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ValuesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/relationships/values{?query*}", rawUrl) { + } + /// + /// Removes existing nameValuePairs from the values relationship of an individual node. + /// + /// The request body + /// 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 DeleteAsync(ToManyNameValuePairInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task DeleteAsync(ToManyNameValuePairInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related nameValuePair identities of an individual node's values relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NameValuePairIdentifierCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Assigns existing nameValuePairs to the values relationship of an individual node. + /// + /// The request body + /// 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 PatchAsync(ToManyNameValuePairInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PatchAsync(ToManyNameValuePairInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Adds existing nameValuePairs to the values relationship of an individual node. + /// + /// The request body + /// 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 PostAsync(ToManyNameValuePairInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(ToManyNameValuePairInRequest body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Removes existing nameValuePairs from the values relationship of an individual node. + /// + /// The request body + /// 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 ToDeleteRequestInformation(ToManyNameValuePairInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToDeleteRequestInformation(ToManyNameValuePairInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Retrieves the related nameValuePair identities of an individual node's values relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Assigns existing nameValuePairs to the values relationship of an individual node. + /// + /// The request body + /// 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(ToManyNameValuePairInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPatchRequestInformation(ToManyNameValuePairInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.PATCH, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Adds existing nameValuePairs to the values relationship of an individual node. + /// + /// The request body + /// 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 ToPostRequestInformation(ToManyNameValuePairInRequest body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(ToManyNameValuePairInRequest body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ValuesRequestBuilder WithUrl(string rawUrl) { + return new ValuesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related nameValuePair identities of an individual node's values relationship. + /// + public class ValuesRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ValuesRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Values/ValuesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Values/ValuesRequestBuilder.cs new file mode 100644 index 0000000000..ba721bd8e8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/Item/Values/ValuesRequestBuilder.cs @@ -0,0 +1,133 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item.Values { + /// + /// Builds and executes requests for operations under \nodes\{id}\values + /// + public class ValuesRequestBuilder : BaseRequestBuilder { + /// + /// Instantiates a new ValuesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public ValuesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/values{?query*}", pathParameters) { + } + /// + /// Instantiates a new ValuesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public ValuesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes/{id}/values{?query*}", rawUrl) { + } + /// + /// Retrieves the related nameValuePairs of an individual node's values relationship. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"404", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NameValuePairCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves the related nameValuePairs of an individual node's values relationship. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public ValuesRequestBuilder WithUrl(string rawUrl) { + return new ValuesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves the related nameValuePairs of an individual node's values relationship. + /// + public class ValuesRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class ValuesRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs new file mode 100644 index 0000000000..d1f0ce9a41 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/Nodes/NodesRequestBuilder.cs @@ -0,0 +1,197 @@ +// +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes.Item; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes { + /// + /// Builds and executes requests for operations under \nodes + /// + public class NodesRequestBuilder : BaseRequestBuilder { + /// Gets an item from the OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.nodes.item collection + /// The identifier of the node to retrieve. + public NodesItemRequestBuilder this[string position] { get { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new NodesItemRequestBuilder(urlTplParams, RequestAdapter); + } } + /// + /// Instantiates a new NodesRequestBuilder and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public NodesRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes{?query*}", pathParameters) { + } + /// + /// Instantiates a new NodesRequestBuilder and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public NodesRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/nodes{?query*}", rawUrl) { + } + /// + /// Retrieves a collection of nodes. + /// + /// 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) { +#nullable restore +#else + public async Task GetAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodeCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task HeadAsync(Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + var requestInfo = ToHeadRequestInformation(requestConfiguration); + return await RequestAdapter.SendPrimitiveAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + /// + /// Creates a new node. + /// + /// The request body + /// 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 PostAsync(NodePostRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) { +#nullable restore +#else + public async Task PostAsync(NodePostRequestDocument body, Action> requestConfiguration = default, CancellationToken cancellationToken = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> { + {"400", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"403", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"409", ErrorResponseDocument.CreateFromDiscriminatorValue}, + {"422", ErrorResponseDocument.CreateFromDiscriminatorValue}, + }; + return await RequestAdapter.SendAsync(requestInfo, NodePrimaryResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + /// + /// Retrieves a collection of nodes. + /// + /// 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) { +#nullable restore +#else + public RequestInformation ToGetRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + return requestInfo; + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// 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 ToHeadRequestInformation(Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToHeadRequestInformation(Action> requestConfiguration = default) { +#endif + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + /// + /// Creates a new node. + /// + /// The request body + /// 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 ToPostRequestInformation(NodePostRequestDocument body, Action>? requestConfiguration = default) { +#nullable restore +#else + public RequestInformation ToPostRequestInformation(NodePostRequestDocument body, Action> requestConfiguration = default) { +#endif + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json", body); + return requestInfo; + } + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// The raw URL to use for the request builder. + public NodesRequestBuilder WithUrl(string rawUrl) { + return new NodesRequestBuilder(rawUrl, RequestAdapter); + } + /// + /// Retrieves a collection of nodes. + /// + public class NodesRequestBuilderGetQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + public class NodesRequestBuilderHeadQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + /// + /// Creates a new node. + /// + public class NodesRequestBuilderPostQueryParameters { + /// For syntax, see the documentation for the [`include`](https://www.jsonapi.net/usage/reading/including-relationships.html)/[`filter`](https://www.jsonapi.net/usage/reading/filtering.html)/[`sort`](https://www.jsonapi.net/usage/reading/sorting.html)/[`page`](https://www.jsonapi.net/usage/reading/pagination.html)/[`fields`](https://www.jsonapi.net/usage/reading/sparse-fieldset-selection.html) query string parameters. +#if NETSTANDARD2_1_OR_GREATER || NETCOREAPP3_1_OR_GREATER +#nullable enable + [QueryParameter("query")] + public string? Query { get; set; } +#nullable restore +#else + [QueryParameter("query")] + public string Query { get; set; } +#endif + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs new file mode 100644 index 0000000000..c5142daaf5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs @@ -0,0 +1,49 @@ +// +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using Microsoft.Kiota.Serialization.Form; +using Microsoft.Kiota.Serialization.Json; +using Microsoft.Kiota.Serialization.Multipart; +using Microsoft.Kiota.Serialization.Text; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.NameValuePairs; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Nodes; +using System.Collections.Generic; +using System.IO; +using System.Linq; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode { + /// + /// The main entry point of the SDK, exposes the configuration and the fluent API. + /// + public class QueryStringsClient : BaseRequestBuilder { + /// The nameValuePairs property + public NameValuePairsRequestBuilder NameValuePairs { get => + new NameValuePairsRequestBuilder(PathParameters, RequestAdapter); + } + /// The nodes property + public NodesRequestBuilder Nodes { get => + new NodesRequestBuilder(PathParameters, RequestAdapter); + } + /// + /// Instantiates a new QueryStringsClient and sets the default values. + /// + /// The backing store to use for the models. + /// The request adapter to use to execute the requests. + public QueryStringsClient(IRequestAdapter requestAdapter, IBackingStoreFactory backingStore = default) : base(requestAdapter, "{+baseurl}", new Dictionary()) { + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultSerializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + ApiClientBuilder.RegisterDefaultDeserializer(); + if (string.IsNullOrEmpty(RequestAdapter.BaseUrl)) { + RequestAdapter.BaseUrl = "http://localhost"; + } + PathParameters.TryAdd("baseurl", RequestAdapter.BaseUrl); + RequestAdapter.EnableBackingStore(backingStore); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs new file mode 100644 index 0000000000..c366d98ed8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/IncludeTests.cs @@ -0,0 +1,219 @@ +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.QueryStrings; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.QueryStrings; + +public sealed class IncludeTests : IClassFixture, QueryStringsDbContext>> +{ + private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly QueryStringFakers _fakers = new(); + + public IncludeTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + testContext.UseController(); + } + + [Fact] + public async Task Can_include_in_primary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Values = _fakers.NameValuePair.Generate(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["include"] = "values.owner" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(node.StringId); + + response.Included.ShouldHaveCount(2); + response.Included.Should().ContainSingle(include => include is NameValuePairDataInResponse && include.Id == node.Values.ElementAt(0).StringId); + response.Included.Should().ContainSingle(include => include is NameValuePairDataInResponse && include.Id == node.Values.ElementAt(1).StringId); + } + } + + [Fact] + public async Task Can_include_in_primary_resource() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Values = _fakers.NameValuePair.Generate(1); + node.Children = _fakers.Node.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["include"] = "children.parent,values" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId].GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(node.StringId); + + response.Included.ShouldHaveCount(3); + response.Included.Should().ContainSingle(include => include is NodeDataInResponse && include.Id == node.Children.ElementAt(0).StringId); + response.Included.Should().ContainSingle(include => include is NodeDataInResponse && include.Id == node.Children.ElementAt(1).StringId); + response.Included.Should().ContainSingle(include => include is NameValuePairDataInResponse && include.Id == node.Values[0].StringId); + } + } + + [Fact] + public async Task Can_include_in_secondary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Parent = _fakers.Node.Generate(); + node.Values = _fakers.NameValuePair.Generate(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["include"] = "owner.parent,owner.values" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NameValuePairCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Values.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + + response.Included.ShouldHaveCount(2); + response.Included.Should().ContainSingle(include => include is NodeDataInResponse && include.Id == node.StringId); + response.Included.Should().ContainSingle(include => include is NodeDataInResponse && include.Id == node.Parent.StringId); + } + } + + [Fact] + public async Task Can_include_in_secondary_resource() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Parent = _fakers.Node.Generate(); + node.Parent.Parent = _fakers.Node.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["include"] = "parent.parent" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NullableNodeSecondaryResponseDocument? response = await apiClient.Nodes[node.StringId].Parent.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(node.Parent.StringId); + + response.Included.ShouldHaveCount(1); + + NodeDataInResponse? include = response.Included.ElementAt(0).Should().BeOfType().Subject; + include.Id.Should().Be(node.Parent.Parent.StringId); + include.Attributes.ShouldNotBeNull(); + include.Attributes.Name.Should().Be(node.Parent.Parent.Name); + } + } + + [Fact] + public async Task Can_use_empty_include() + { + // Arrange + Node node = _fakers.Node.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["include"] = null + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId].GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(node.StringId); + + response.Included.Should().BeEmpty(); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs new file mode 100644 index 0000000000..609ce51c51 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/PaginationTests.cs @@ -0,0 +1,200 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.QueryStrings; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.QueryStrings; + +public sealed class PaginationTests : IClassFixture, QueryStringsDbContext>> +{ + private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly QueryStringFakers _fakers = new(); + + public PaginationTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_paginate_in_primary_resources() + { + // Arrange + List nodes = _fakers.Node.Generate(3); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.AddRange(nodes); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["page[size]"] = "1", + ["page[number]"] = "2" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); + response.Meta.ShouldNotBeNull(); + response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); + } + } + + [Fact] + public async Task Can_paginate_in_secondary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(3).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["page[size]"] = "2", + ["page[number]"] = "1" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); + response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); + response.Meta.ShouldNotBeNull(); + response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); + } + } + + [Fact] + public async Task Can_paginate_at_ToMany_relationship_endpoint() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(3).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["page[size]"] = "2", + ["page[number]"] = "2" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeIdentifierCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Relationships.Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); + response.Meta.ShouldNotBeNull(); + response.Meta.AdditionalData.ShouldContainKey("total").With(total => total.Should().Be(3)); + } + } + + [Fact] + public async Task Cannot_use_empty_page_size() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["page[size]"] = null + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + Func action = async () => _ = await apiClient.Nodes[Unknown.StringId.Int64].GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("400"); + error.Title.Should().Be("Missing query string parameter value."); + error.Detail.Should().Be("Missing value for 'page[size]' query string parameter."); + error.Source.ShouldNotBeNull(); + error.Source.Parameter.Should().Be("page[size]"); + } + } + + [Fact] + public async Task Cannot_use_empty_page_number() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["page[number]"] = null + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + Func action = async () => _ = await apiClient.Nodes[Unknown.StringId.Int64].GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("400"); + error.Title.Should().Be("Missing query string parameter value."); + error.Detail.Should().Be("Missing value for 'page[number]' query string parameter."); + error.Source.ShouldNotBeNull(); + error.Source.Parameter.Should().Be("page[number]"); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs new file mode 100644 index 0000000000..04dd1d8659 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SortTests.cs @@ -0,0 +1,168 @@ +using System.Net; +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.QueryStrings; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.QueryStrings; + +public sealed class SortTests : IClassFixture, QueryStringsDbContext>> +{ + private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly QueryStringFakers _fakers = new(); + + public SortTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_sort_in_primary_resources() + { + // Arrange + List nodes = _fakers.Node.Generate(2); + nodes[0].Name = "A"; + nodes[1].Name = "B"; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.AddRange(nodes); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["sort"] = "-name" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); + response.Data.ElementAt(1).Id.Should().Be(nodes[0].StringId); + } + } + + [Fact] + public async Task Can_sort_in_secondary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(2).ToHashSet(); + node.Children.ElementAt(0).Name = "B"; + node.Children.ElementAt(1).Name = "A"; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["sort"] = "name" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); + response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(0).StringId); + } + } + + [Fact] + public async Task Can_sort_at_ToMany_relationship_endpoint() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(2).ToHashSet(); + node.Children.ElementAt(0).Children = _fakers.Node.Generate(1).ToHashSet(); + node.Children.ElementAt(1).Children = _fakers.Node.Generate(2).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["sort"] = "count(children)" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeIdentifierCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Relationships.Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(2); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); + response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); + } + } + + [Fact] + public async Task Cannot_use_empty_sort() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["sort"] = null + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + Func action = async () => _ = await apiClient.Nodes[Unknown.StringId.Int64].GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Errors.ShouldHaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("400"); + error.Title.Should().Be("Missing query string parameter value."); + error.Detail.Should().Be("Missing value for 'sort' query string parameter."); + error.Source.ShouldNotBeNull(); + error.Source.Parameter.Should().Be("sort"); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs new file mode 100644 index 0000000000..620fbfd1a3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -0,0 +1,214 @@ +using FluentAssertions; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiKiotaEndToEndTests.QueryStrings.GeneratedCode.Models; +using OpenApiTests; +using OpenApiTests.QueryStrings; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.QueryStrings; + +public sealed class SparseFieldSetTests : IClassFixture, QueryStringsDbContext>> +{ + private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly QueryStringFakers _fakers = new(); + + public SparseFieldSetTests(IntegrationTestContext, QueryStringsDbContext> testContext, + ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + } + + [Fact] + public async Task Can_select_attribute_in_primary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["fields[nodes]"] = "name" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(node.StringId); + response.Data.ElementAt(0).Attributes.ShouldNotBeNull(); + response.Data.ElementAt(0).Attributes!.Name.Should().Be(node.Name); + response.Data.ElementAt(0).Attributes!.Comment.Should().BeNull(); + response.Data.ElementAt(0).Relationships.Should().BeNull(); + } + } + + [Fact] + public async Task Can_select_fields_in_primary_resource() + { + // Arrange + Node node = _fakers.Node.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["fields[nodes]"] = "comment,parent" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId].GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(node.StringId); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Name.Should().BeNull(); + response.Data.Attributes.Comment.Should().Be(node.Comment); + response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.Parent.ShouldNotBeNull(); + response.Data.Relationships.Children.Should().BeNull(); + } + } + + [Fact] + public async Task Can_select_fields_in_secondary_resources() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Children = _fakers.Node.Generate(1).ToHashSet(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["fields[nodes]"] = "comment,children" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodeCollectionResponseDocument? response = await apiClient.Nodes[node.StringId].Children.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldHaveCount(1); + response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); + response.Data.ElementAt(0).Attributes.ShouldNotBeNull(); + response.Data.ElementAt(0).Attributes!.Name.Should().BeNull(); + response.Data.ElementAt(0).Attributes!.Comment.Should().Be(node.Children.ElementAt(0).Comment); + response.Data.ElementAt(0).Relationships.ShouldNotBeNull(); + response.Data.ElementAt(0).Relationships!.Parent.Should().BeNull(); + response.Data.ElementAt(0).Relationships!.Children.ShouldNotBeNull(); + } + } + + [Fact] + public async Task Can_select_fields_in_secondary_resource() + { + // Arrange + Node node = _fakers.Node.Generate(); + node.Parent = _fakers.Node.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["fields[nodes]"] = "comment,children" + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NullableNodeSecondaryResponseDocument? response = await apiClient.Nodes[node.StringId].Parent.GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(node.Parent.StringId); + response.Data.Attributes.ShouldNotBeNull(); + response.Data.Attributes.Name.Should().BeNull(); + response.Data.Attributes.Comment.Should().Be(node.Parent.Comment); + response.Data.Relationships.ShouldNotBeNull(); + response.Data.Relationships.Parent.Should().BeNull(); + response.Data.Relationships.Children.ShouldNotBeNull(); + } + } + + [Fact] + public async Task Can_select_empty_fieldset() + { + // Arrange + Node node = _fakers.Node.Generate(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.Nodes.Add(node); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new QueryStringsClient(requestAdapter); + + var queryString = new Dictionary + { + ["fields[nodes]"] = null + }; + + using (_requestAdapterFactory.WithQueryString(queryString)) + { + // Act + NodePrimaryResponseDocument? response = await apiClient.Nodes[node.StringId].GetAsync(); + + // Assert + response.ShouldNotBeNull(); + response.Data.ShouldNotBeNull(); + response.Data.Id.Should().Be(node.StringId); + response.Data.Attributes.Should().BeNull(); + } + } +} diff --git a/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs b/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs new file mode 100644 index 0000000000..0fd05d2aee --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs @@ -0,0 +1,39 @@ +using JsonApiDotNetCore.OpenApi.Client.Kiota; +using Microsoft.AspNetCore.Mvc.Testing; +using Microsoft.Kiota.Abstractions.Authentication; +using Microsoft.Kiota.Http.HttpClientLibrary; +using TestBuildingBlocks; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests; + +internal sealed class TestableHttpClientRequestAdapterFactory +{ + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly SetQueryStringHttpMessageHandler _queryStringMessageHandler = new(); + + public TestableHttpClientRequestAdapterFactory(ITestOutputHelper testOutputHelper) + { + ArgumentNullException.ThrowIfNull(testOutputHelper); + + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + } + + public HttpClientRequestAdapter CreateAdapter(WebApplicationFactory webApplicationFactory) + where TStartup : class + { + ArgumentNullException.ThrowIfNull(webApplicationFactory); + + IList delegatingHandlers = KiotaClientFactory.CreateDefaultHandlers(); + delegatingHandlers.Add(_queryStringMessageHandler); + delegatingHandlers.Add(_logHttpMessageHandler); + HttpClient httpClient = webApplicationFactory.CreateDefaultClient(delegatingHandlers.ToArray()); + + return new HttpClientRequestAdapter(new AnonymousAuthenticationProvider(), httpClient: httpClient); + } + + public IDisposable WithQueryString(IDictionary queryString) + { + return _queryStringMessageHandler.CreateScope(queryString); + } +} diff --git a/test/OpenApiClientTests/.editorconfig b/test/OpenApiNSwagClientTests/.editorconfig similarity index 100% rename from test/OpenApiClientTests/.editorconfig rename to test/OpenApiNSwagClientTests/.editorconfig diff --git a/test/OpenApiClientTests/BaseOpenApiClientTests.cs b/test/OpenApiNSwagClientTests/BaseOpenApiNSwagClientTests.cs similarity index 96% rename from test/OpenApiClientTests/BaseOpenApiClientTests.cs rename to test/OpenApiNSwagClientTests/BaseOpenApiNSwagClientTests.cs index 6ebfa04e18..828d368c7e 100644 --- a/test/OpenApiClientTests/BaseOpenApiClientTests.cs +++ b/test/OpenApiNSwagClientTests/BaseOpenApiNSwagClientTests.cs @@ -1,10 +1,10 @@ using System.Linq.Expressions; using System.Reflection; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; -namespace OpenApiClientTests; +namespace OpenApiNSwagClientTests; -public abstract class BaseOpenApiClientTests +public abstract class BaseOpenApiNSwagClientTests { private const string AttributesObjectParameterName = "attributesObject"; diff --git a/test/OpenApiClientTests/FakeHttpClientWrapper.cs b/test/OpenApiNSwagClientTests/FakeHttpClientWrapper.cs similarity index 97% rename from test/OpenApiClientTests/FakeHttpClientWrapper.cs rename to test/OpenApiNSwagClientTests/FakeHttpClientWrapper.cs index c965d30b0d..05631bcf53 100644 --- a/test/OpenApiClientTests/FakeHttpClientWrapper.cs +++ b/test/OpenApiNSwagClientTests/FakeHttpClientWrapper.cs @@ -2,9 +2,9 @@ using System.Net.Http.Headers; using System.Text; using System.Text.Json; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; -namespace OpenApiClientTests; +namespace OpenApiNSwagClientTests; /// /// Enables to inject an outgoing response body and inspect the incoming request. diff --git a/test/OpenApiClientTests/FakerFactory.cs b/test/OpenApiNSwagClientTests/FakerFactory.cs similarity index 98% rename from test/OpenApiClientTests/FakerFactory.cs rename to test/OpenApiNSwagClientTests/FakerFactory.cs index 74b6a81223..b13be6f795 100644 --- a/test/OpenApiClientTests/FakerFactory.cs +++ b/test/OpenApiNSwagClientTests/FakerFactory.cs @@ -3,7 +3,7 @@ using JetBrains.Annotations; using TestBuildingBlocks; -namespace OpenApiClientTests; +namespace OpenApiNSwagClientTests; internal sealed class FakerFactory { diff --git a/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs b/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs new file mode 100644 index 0000000000..0f6f05177b --- /dev/null +++ b/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/IOpenApiClient.cs @@ -0,0 +1,6 @@ +using JsonApiDotNetCore.OpenApi.Client.NSwag; + +namespace OpenApiNSwagClientTests.LegacyClient.GeneratedCode; + +// ReSharper disable once MemberCanBeInternal +public partial interface IOpenApiClient : IJsonApiClient; diff --git a/test/OpenApiClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs b/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs similarity index 71% rename from test/OpenApiClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs rename to test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs index c8592a563c..3f1b385d9e 100644 --- a/test/OpenApiClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs +++ b/test/OpenApiNSwagClientTests/LegacyClient/GeneratedCode/OpenApiClient.cs @@ -1,7 +1,7 @@ -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace OpenApiClientTests.LegacyClient.GeneratedCode; +namespace OpenApiNSwagClientTests.LegacyClient.GeneratedCode; internal partial class OpenApiClient : JsonApiClient { diff --git a/test/OpenApiClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs b/test/OpenApiNSwagClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs similarity index 99% rename from test/OpenApiClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs rename to test/OpenApiNSwagClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs index 9b4d5b7fae..9019111e9a 100644 --- a/test/OpenApiClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyClient/PartialAttributeSerializationLifetimeTests.cs @@ -1,11 +1,11 @@ using System.Net; using FluentAssertions; -using JsonApiDotNetCore.OpenApi.Client; -using OpenApiClientTests.LegacyClient.GeneratedCode; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagClientTests.LegacyClient.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.LegacyClient; +namespace OpenApiNSwagClientTests.LegacyClient; public sealed class PartialAttributeSerializationLifetimeTests { diff --git a/test/OpenApiClientTests/LegacyClient/RequestTests.cs b/test/OpenApiNSwagClientTests/LegacyClient/RequestTests.cs similarity index 99% rename from test/OpenApiClientTests/LegacyClient/RequestTests.cs rename to test/OpenApiNSwagClientTests/LegacyClient/RequestTests.cs index 7a8edc786f..587a9f88ff 100644 --- a/test/OpenApiClientTests/LegacyClient/RequestTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyClient/RequestTests.cs @@ -3,13 +3,13 @@ using FluentAssertions.Common; using FluentAssertions.Extensions; using JsonApiDotNetCore.Middleware; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Microsoft.Net.Http.Headers; -using OpenApiClientTests.LegacyClient.GeneratedCode; +using OpenApiNSwagClientTests.LegacyClient.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.LegacyClient; +namespace OpenApiNSwagClientTests.LegacyClient; public sealed class RequestTests { diff --git a/test/OpenApiClientTests/LegacyClient/ResponseTests.cs b/test/OpenApiNSwagClientTests/LegacyClient/ResponseTests.cs similarity index 98% rename from test/OpenApiClientTests/LegacyClient/ResponseTests.cs rename to test/OpenApiNSwagClientTests/LegacyClient/ResponseTests.cs index a93789dea1..c2b949456c 100644 --- a/test/OpenApiClientTests/LegacyClient/ResponseTests.cs +++ b/test/OpenApiNSwagClientTests/LegacyClient/ResponseTests.cs @@ -1,12 +1,12 @@ using System.Globalization; using System.Net; using FluentAssertions; -using JsonApiDotNetCore.OpenApi.Client; -using OpenApiClientTests.LegacyClient.GeneratedCode; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagClientTests.LegacyClient.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.LegacyClient; +namespace OpenApiNSwagClientTests.LegacyClient; public sealed class ResponseTests { @@ -310,7 +310,7 @@ public async Task Posting_resource_translates_response() // Assert document.Data.Attributes.Should().BeNull(); - document.Data.Relationships.Purser.Data.Should().NotBeNull(); + document.Data.Relationships.Purser.Data.ShouldNotBeNull(); document.Data.Relationships.Purser.Data.Id.Should().Be(flightAttendantId); document.Data.Relationships.CabinCrewMembers.Data.Should().HaveCount(1); document.Data.Relationships.CabinCrewMembers.Data.First().Id.Should().Be(flightAttendantId); @@ -449,7 +449,7 @@ public async Task Getting_secondary_resource_translates_response() FlightAttendantSecondaryResponseDocument document = await apiClient.GetFlightPurserAsync(flightId, null, null); // Assert - document.Data.Should().NotBeNull(); + document.Data.ShouldNotBeNull(); document.Data.Id.Should().Be(purserId); document.Data.Attributes.EmailAddress.Should().Be(emailAddress); document.Data.Attributes.Age.Should().Be(int.Parse(age)); @@ -563,7 +563,7 @@ public async Task Getting_ToOne_relationship_translates_response() FlightAttendantIdentifierResponseDocument document = await apiClient.GetFlightPurserRelationshipAsync(flightId, null, null); // Assert - document.Data.Should().NotBeNull(); + document.Data.ShouldNotBeNull(); document.Data.Id.Should().Be(purserId); document.Data.Type.Should().Be(FlightAttendantResourceType.FlightAttendants); } diff --git a/test/OpenApiClientTests/NamingConventions/CamelCase/GeneratedTypesTests.cs b/test/OpenApiNSwagClientTests/NamingConventions/CamelCase/GeneratedTypesTests.cs similarity index 96% rename from test/OpenApiClientTests/NamingConventions/CamelCase/GeneratedTypesTests.cs rename to test/OpenApiNSwagClientTests/NamingConventions/CamelCase/GeneratedTypesTests.cs index b5adea1a5f..c46e126b25 100644 --- a/test/OpenApiClientTests/NamingConventions/CamelCase/GeneratedTypesTests.cs +++ b/test/OpenApiNSwagClientTests/NamingConventions/CamelCase/GeneratedTypesTests.cs @@ -1,8 +1,8 @@ -using OpenApiClientTests.NamingConventions.CamelCase.GeneratedCode; +using OpenApiNSwagClientTests.NamingConventions.CamelCase.GeneratedCode; using Xunit; -using GeneratedClient = OpenApiClientTests.NamingConventions.CamelCase.GeneratedCode.CamelCaseClient; +using GeneratedClient = OpenApiNSwagClientTests.NamingConventions.CamelCase.GeneratedCode.CamelCaseClient; -namespace OpenApiClientTests.NamingConventions.CamelCase; +namespace OpenApiNSwagClientTests.NamingConventions.CamelCase; public sealed class GeneratedTypesTests { diff --git a/test/OpenApiClientTests/NamingConventions/KebabCase/GeneratedTypesTests.cs b/test/OpenApiNSwagClientTests/NamingConventions/KebabCase/GeneratedTypesTests.cs similarity index 96% rename from test/OpenApiClientTests/NamingConventions/KebabCase/GeneratedTypesTests.cs rename to test/OpenApiNSwagClientTests/NamingConventions/KebabCase/GeneratedTypesTests.cs index e0408281c0..be720ca21f 100644 --- a/test/OpenApiClientTests/NamingConventions/KebabCase/GeneratedTypesTests.cs +++ b/test/OpenApiNSwagClientTests/NamingConventions/KebabCase/GeneratedTypesTests.cs @@ -1,8 +1,8 @@ -using OpenApiClientTests.NamingConventions.KebabCase.GeneratedCode; +using OpenApiNSwagClientTests.NamingConventions.KebabCase.GeneratedCode; using Xunit; -using GeneratedClient = OpenApiClientTests.NamingConventions.KebabCase.GeneratedCode.KebabCaseClient; +using GeneratedClient = OpenApiNSwagClientTests.NamingConventions.KebabCase.GeneratedCode.KebabCaseClient; -namespace OpenApiClientTests.NamingConventions.KebabCase; +namespace OpenApiNSwagClientTests.NamingConventions.KebabCase; public sealed class GeneratedTypesTests { diff --git a/test/OpenApiClientTests/NamingConventions/PascalCase/GeneratedTypesTests.cs b/test/OpenApiNSwagClientTests/NamingConventions/PascalCase/GeneratedTypesTests.cs similarity index 96% rename from test/OpenApiClientTests/NamingConventions/PascalCase/GeneratedTypesTests.cs rename to test/OpenApiNSwagClientTests/NamingConventions/PascalCase/GeneratedTypesTests.cs index 4c33a27eec..a6c40f8254 100644 --- a/test/OpenApiClientTests/NamingConventions/PascalCase/GeneratedTypesTests.cs +++ b/test/OpenApiNSwagClientTests/NamingConventions/PascalCase/GeneratedTypesTests.cs @@ -1,8 +1,8 @@ -using OpenApiClientTests.NamingConventions.PascalCase.GeneratedCode; +using OpenApiNSwagClientTests.NamingConventions.PascalCase.GeneratedCode; using Xunit; -using GeneratedClient = OpenApiClientTests.NamingConventions.PascalCase.GeneratedCode.PascalCaseClient; +using GeneratedClient = OpenApiNSwagClientTests.NamingConventions.PascalCase.GeneratedCode.PascalCaseClient; -namespace OpenApiClientTests.NamingConventions.PascalCase; +namespace OpenApiNSwagClientTests.NamingConventions.PascalCase; public sealed class GeneratedTypesTests { diff --git a/test/OpenApiClientTests/ObjectExtensions.cs b/test/OpenApiNSwagClientTests/ObjectExtensions.cs similarity index 93% rename from test/OpenApiClientTests/ObjectExtensions.cs rename to test/OpenApiNSwagClientTests/ObjectExtensions.cs index 3f2633f5ff..fe6fb60da5 100644 --- a/test/OpenApiClientTests/ObjectExtensions.cs +++ b/test/OpenApiNSwagClientTests/ObjectExtensions.cs @@ -1,7 +1,7 @@ using System.Reflection; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; -namespace OpenApiClientTests; +namespace OpenApiNSwagClientTests; internal static class ObjectExtensions { diff --git a/test/OpenApiClientTests/OpenApiClientTests.csproj b/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj similarity index 60% rename from test/OpenApiClientTests/OpenApiClientTests.csproj rename to test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj index 6d2fb45151..7a80e2b6e0 100644 --- a/test/OpenApiClientTests/OpenApiClientTests.csproj +++ b/test/OpenApiNSwagClientTests/OpenApiNSwagClientTests.csproj @@ -7,7 +7,7 @@ - + @@ -23,61 +23,61 @@ - - OpenApiClientTests.LegacyClient.GeneratedCode + + OpenApiNSwagClientTests.LegacyClient.GeneratedCode OpenApiClient OpenApiClient.cs NSwagCSharp - /GenerateClientInterfaces:true /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client + /GenerateClientInterfaces:true /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag - - OpenApiClientTests.NamingConventions.KebabCase.GeneratedCode + + OpenApiNSwagClientTests.NamingConventions.KebabCase.GeneratedCode KebabCaseClient KebabCaseClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag - - OpenApiClientTests.NamingConventions.CamelCase.GeneratedCode + + OpenApiNSwagClientTests.NamingConventions.CamelCase.GeneratedCode CamelCaseClient CamelCaseClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag - - OpenApiClientTests.NamingConventions.PascalCase.GeneratedCode + + OpenApiNSwagClientTests.NamingConventions.PascalCase.GeneratedCode PascalCaseClient PascalCaseClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag - + NrtOffMsvOffClient NrtOffMsvOffClient.cs NSwagCSharp - OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client /GenerateNullableReferenceTypes:false + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:false - + NrtOffMsvOnClient NrtOffMsvOnClient.cs NSwagCSharp - OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client /GenerateNullableReferenceTypes:false + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:false - + NrtOnMsvOffClient NrtOnMsvOffClient.cs NSwagCSharp - OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client /GenerateNullableReferenceTypes:true + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true - + NrtOnMsvOnClient NrtOnMsvOnClient.cs NSwagCSharp - OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client /GenerateNullableReferenceTypes:true + OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true diff --git a/test/OpenApiClientTests/PropertyInfoAssertionsExtensions.cs b/test/OpenApiNSwagClientTests/PropertyInfoAssertionsExtensions.cs similarity index 95% rename from test/OpenApiClientTests/PropertyInfoAssertionsExtensions.cs rename to test/OpenApiNSwagClientTests/PropertyInfoAssertionsExtensions.cs index e49bef1a0d..bb0ff8dbd1 100644 --- a/test/OpenApiClientTests/PropertyInfoAssertionsExtensions.cs +++ b/test/OpenApiNSwagClientTests/PropertyInfoAssertionsExtensions.cs @@ -2,7 +2,7 @@ using FluentAssertions; using FluentAssertions.Types; -namespace OpenApiClientTests; +namespace OpenApiNSwagClientTests; internal static class PropertyInfoAssertionsExtensions { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs similarity index 96% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs index 5dbc88c8b2..4654462c60 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/CreateResourceTests.cs @@ -3,15 +3,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; -public sealed class CreateResourceTests : BaseOpenApiClientTests +public sealed class CreateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOffMsvOffFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs similarity index 62% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs index f3ee9a9c53..4a0eed4e39 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedCode/NrtOffMsvOffClient.cs @@ -1,7 +1,7 @@ -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; internal partial class NrtOffMsvOffClient : JsonApiClient { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NrtOffMsvOffFakers.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NrtOffMsvOffFakers.cs similarity index 83% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NrtOffMsvOffFakers.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NrtOffMsvOffFakers.cs index adb0e97833..32f67157bd 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NrtOffMsvOffFakers.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NrtOffMsvOffFakers.cs @@ -1,7 +1,7 @@ using Bogus; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; internal sealed class NrtOffMsvOffFakers { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs similarity index 90% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs index d15ba31e2b..dd0da75e35 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs @@ -1,10 +1,10 @@ using System.Reflection; using FluentAssertions; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; public sealed class NullabilityTests { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs similarity index 94% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs index 720a4821c5..d29235e95a 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs @@ -2,15 +2,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOff; -public sealed class UpdateResourceTests : BaseOpenApiClientTests +public sealed class UpdateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOffMsvOffFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs similarity index 97% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs index c8c1908070..ac17bc38c1 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/CreateResourceTests.cs @@ -3,15 +3,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; -public sealed class CreateResourceTests : BaseOpenApiClientTests +public sealed class CreateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOffMsvOnFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs similarity index 62% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs index a722c5d49b..1da4da6712 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedCode/NrtOffMsvOnClient.cs @@ -1,7 +1,7 @@ -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; internal partial class NrtOffMsvOnClient : JsonApiClient { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NrtOffMsvOnFakers.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NrtOffMsvOnFakers.cs similarity index 86% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NrtOffMsvOnFakers.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NrtOffMsvOnFakers.cs index 14d23cb247..0ce74c214c 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NrtOffMsvOnFakers.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NrtOffMsvOnFakers.cs @@ -1,7 +1,7 @@ using Bogus; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; internal sealed class NrtOffMsvOnFakers { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs similarity index 90% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs index 11e082fdb9..9b0c3e7b1d 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs @@ -1,10 +1,10 @@ using System.Reflection; using FluentAssertions; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; public sealed class NullabilityTests { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs similarity index 94% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs index 9c7689c509..38b485d1dc 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs @@ -2,15 +2,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOff.ModelStateValidationOn; -public sealed class UpdateResourceTests : BaseOpenApiClientTests +public sealed class UpdateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOffMsvOnFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs similarity index 97% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs index 1810d76ade..5f5d92e1a6 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/CreateResourceTests.cs @@ -3,15 +3,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; -public sealed class CreateResourceTests : BaseOpenApiClientTests +public sealed class CreateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOnMsvOffFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs similarity index 62% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs index 77b0854984..f86a5229fc 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedCode/NrtOnMsvOffClient.cs @@ -1,7 +1,7 @@ -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; internal partial class NrtOnMsvOffClient : JsonApiClient { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NrtOnMsvOffFakers.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NrtOnMsvOffFakers.cs similarity index 86% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NrtOnMsvOffFakers.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NrtOnMsvOffFakers.cs index 4b6365764e..99a015b6a2 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NrtOnMsvOffFakers.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NrtOnMsvOffFakers.cs @@ -1,7 +1,7 @@ using Bogus; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; internal sealed class NrtOnMsvOffFakers { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs similarity index 91% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs index 633133a63c..609d64bb15 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs @@ -1,10 +1,10 @@ using System.Reflection; using FluentAssertions; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; public sealed class NullabilityTests { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs similarity index 94% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs index 0e5b532aa2..c4b5789c0b 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs @@ -2,15 +2,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOff; -public sealed class UpdateResourceTests : BaseOpenApiClientTests +public sealed class UpdateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOnMsvOffFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs similarity index 98% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs index c7d70892cc..979338c5ed 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/CreateResourceTests.cs @@ -3,15 +3,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; -public sealed class CreateResourceTests : BaseOpenApiClientTests +public sealed class CreateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOnMsvOnFakers _fakers = new(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs similarity index 62% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs index 6679b1c168..0a506d41ec 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedCode/NrtOnMsvOnClient.cs @@ -1,7 +1,7 @@ -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; internal partial class NrtOnMsvOnClient : JsonApiClient { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NrtOnMsvOnFakers.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NrtOnMsvOnFakers.cs similarity index 86% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NrtOnMsvOnFakers.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NrtOnMsvOnFakers.cs index 9906627046..acf9821095 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NrtOnMsvOnFakers.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NrtOnMsvOnFakers.cs @@ -1,7 +1,7 @@ using Bogus; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; internal sealed class NrtOnMsvOnFakers { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs similarity index 91% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs index 83fce2a945..10b3b1b2f2 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs @@ -1,10 +1,10 @@ using System.Reflection; using FluentAssertions; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; public sealed class NullabilityTests { diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs similarity index 94% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs rename to test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs index 153aadc426..651368853c 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs +++ b/test/OpenApiNSwagClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs @@ -2,15 +2,15 @@ using System.Text.Json; using FluentAssertions; using FluentAssertions.Specialized; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Newtonsoft.Json; -using OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; +using OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn.GeneratedCode; using TestBuildingBlocks; using Xunit; -namespace OpenApiClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; +namespace OpenApiNSwagClientTests.ResourceFieldValidation.NullableReferenceTypesOn.ModelStateValidationOn; -public sealed class UpdateResourceTests : BaseOpenApiClientTests +public sealed class UpdateResourceTests : BaseOpenApiNSwagClientTests { private readonly NrtOnMsvOnFakers _fakers = new(); diff --git a/test/OpenApiEndToEndTests/.editorconfig b/test/OpenApiNSwagEndToEndTests/.editorconfig similarity index 100% rename from test/OpenApiEndToEndTests/.editorconfig rename to test/OpenApiNSwagEndToEndTests/.editorconfig diff --git a/test/OpenApiEndToEndTests/Headers/ETagTests.cs b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs similarity index 87% rename from test/OpenApiEndToEndTests/Headers/ETagTests.cs rename to test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs index 97a4dd9467..3608ef459b 100644 --- a/test/OpenApiEndToEndTests/Headers/ETagTests.cs +++ b/test/OpenApiNSwagEndToEndTests/Headers/ETagTests.cs @@ -1,23 +1,26 @@ using System.Net; using FluentAssertions; -using JsonApiDotNetCore.OpenApi.Client; +using JsonApiDotNetCore.OpenApi.Client.NSwag; using Microsoft.Net.Http.Headers; -using OpenApiEndToEndTests.Headers.GeneratedCode; +using OpenApiNSwagEndToEndTests.Headers.GeneratedCode; using OpenApiTests; using OpenApiTests.Headers; using TestBuildingBlocks; using Xunit; +using Xunit.Abstractions; -namespace OpenApiEndToEndTests.Headers; +namespace OpenApiNSwagEndToEndTests.Headers; public sealed class ETagTests : IClassFixture, HeadersDbContext>> { private readonly IntegrationTestContext, HeadersDbContext> _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly HeaderFakers _fakers = new(); - public ETagTests(IntegrationTestContext, HeadersDbContext> testContext) + public ETagTests(IntegrationTestContext, HeadersDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); } @@ -35,7 +38,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); // Act @@ -60,7 +63,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); // Act @@ -78,7 +81,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Returns_no_ETag_for_failed_GET_request() { // Arrange - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); // Act @@ -97,7 +100,7 @@ public async Task Returns_no_ETag_for_POST_request() // Arrange Country newCountry = _fakers.Country.Generate(); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); // Act @@ -135,7 +138,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); ApiResponse response1 = await ApiResponse.TranslateAsync(() => apiClient.GetCountryCollectionAsync(null, null)); @@ -167,18 +170,18 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); var apiClient = new HeadersClient(httpClient); // Act - ApiResponse response2 = + ApiResponse response = await ApiResponse.TranslateAsync(() => apiClient.GetCountryCollectionAsync(null, "\"Not-a-matching-value\"")); // Assert - response2.StatusCode.Should().Be((int)HttpStatusCode.OK); + response.StatusCode.Should().Be((int)HttpStatusCode.OK); - response2.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); + response.Headers.Should().ContainKey(HeaderNames.ETag).WhoseValue.Should().NotBeNullOrEmpty(); - response2.Result.ShouldNotBeNull(); + response.Result.ShouldNotBeNull(); } } diff --git a/test/OpenApiEndToEndTests/OpenApiEndToEndTests.csproj b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj similarity index 78% rename from test/OpenApiEndToEndTests/OpenApiEndToEndTests.csproj rename to test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj index 6566c17b4b..a069a30eb2 100644 --- a/test/OpenApiEndToEndTests/OpenApiEndToEndTests.csproj +++ b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj @@ -7,7 +7,7 @@ - + @@ -23,19 +23,19 @@ - - OpenApiEndToEndTests.Headers.GeneratedCode + + OpenApiNSwagEndToEndTests.Headers.GeneratedCode HeadersClient HeadersClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client /GenerateNullableReferenceTypes:true + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /WrapResponses:true /GenerateResponseClasses:false /ResponseClass:ApiResponse /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true - - OpenApiEndToEndTests.QueryStrings.GeneratedCode + + OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode QueryStringsClient QueryStringsClient.cs NSwagCSharp - /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client /GenerateNullableReferenceTypes:true + /ClientClassAccessModifier:internal /GenerateExceptionClasses:false /AdditionalNamespaceUsages:JsonApiDotNetCore.OpenApi.Client.NSwag /GenerateNullableReferenceTypes:true diff --git a/test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs similarity index 87% rename from test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs rename to test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs index b4e2d82ebe..70b9edabf6 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/FilterTests.cs @@ -1,25 +1,25 @@ using System.Net; using FluentAssertions; -using JsonApiDotNetCore.OpenApi.Client; -using OpenApiEndToEndTests.QueryStrings.GeneratedCode; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; using OpenApiTests; using OpenApiTests.QueryStrings; using TestBuildingBlocks; using Xunit; using Xunit.Abstractions; -namespace OpenApiEndToEndTests.QueryStrings; +namespace OpenApiNSwagEndToEndTests.QueryStrings; public sealed class FilterTests : IClassFixture, QueryStringsDbContext>> { private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; - private readonly ITestOutputHelper _testOutputHelper; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); public FilterTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; - _testOutputHelper = testOutputHelper; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); } @@ -39,8 +39,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(0).Attributes.Name.Should().Be(nodes[1].Name); response.Data.ElementAt(0).Attributes.Comment.Should().Be(nodes[1].Comment); @@ -75,8 +75,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -87,7 +87,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(0).Attributes.Name.Should().Be(node.Children.ElementAt(1).Name); response.Data.ElementAt(0).Attributes.Comment.Should().Be(node.Children.ElementAt(1).Comment); @@ -111,8 +111,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -123,7 +123,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); response.Meta.ShouldContainKey("total").With(total => total.Should().Be(1)); @@ -133,8 +133,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Cannot_use_empty_filter() { // Arrange - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { diff --git a/test/OpenApiNSwagEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs new file mode 100644 index 0000000000..9d507d3109 --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/GeneratedCode/QueryStringsClient.cs @@ -0,0 +1,14 @@ +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using Newtonsoft.Json; + +namespace OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; + +internal partial class QueryStringsClient : JsonApiClient +{ + partial void UpdateJsonSerializerSettings(JsonSerializerSettings settings) + { + SetSerializerSettingsForJsonApi(settings); + + settings.Formatting = Formatting.Indented; + } +} diff --git a/test/OpenApiEndToEndTests/QueryStrings/IncludeTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs similarity index 87% rename from test/OpenApiEndToEndTests/QueryStrings/IncludeTests.cs rename to test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs index 0892ff67fd..a88bab96ba 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/IncludeTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/IncludeTests.cs @@ -1,23 +1,23 @@ using FluentAssertions; -using OpenApiEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; using OpenApiTests; using OpenApiTests.QueryStrings; using TestBuildingBlocks; using Xunit; using Xunit.Abstractions; -namespace OpenApiEndToEndTests.QueryStrings; +namespace OpenApiNSwagEndToEndTests.QueryStrings; public sealed class IncludeTests : IClassFixture, QueryStringsDbContext>> { private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; - private readonly ITestOutputHelper _testOutputHelper; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); public IncludeTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; - _testOutputHelper = testOutputHelper; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); testContext.UseController(); @@ -37,8 +37,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -52,7 +52,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); - response.Included.Should().HaveCount(2); + response.Included.ShouldHaveCount(2); response.Included.Should().ContainSingle(include => include is NameValuePairDataInResponse && include.Id == node.Values.ElementAt(0).StringId); response.Included.Should().ContainSingle(include => include is NameValuePairDataInResponse && include.Id == node.Values.ElementAt(1).StringId); } @@ -72,8 +72,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -86,7 +86,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert response.Data.Id.Should().Be(node.StringId); - response.Included.Should().HaveCount(3); + response.Included.ShouldHaveCount(3); response.Included.Should().ContainSingle(include => include is NodeDataInResponse && include.Id == node.Children.ElementAt(0).StringId); response.Included.Should().ContainSingle(include => include is NodeDataInResponse && include.Id == node.Children.ElementAt(1).StringId); response.Included.Should().ContainSingle(include => include is NameValuePairDataInResponse && include.Id == node.Values[0].StringId); @@ -107,8 +107,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -141,8 +141,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -156,7 +156,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.ShouldNotBeNull(); response.Data.Id.Should().Be(node.Parent.StringId); - response.Included.Should().HaveCount(1); + response.Included.ShouldHaveCount(1); NodeDataInResponse? include = response.Included.ElementAt(0).Should().BeOfType().Subject; include.Id.Should().Be(node.Parent.Parent.StringId); @@ -175,8 +175,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { diff --git a/test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs similarity index 86% rename from test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs rename to test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs index 35eb780024..6d6650b9d1 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/PaginationTests.cs @@ -1,25 +1,25 @@ using System.Net; using FluentAssertions; -using JsonApiDotNetCore.OpenApi.Client; -using OpenApiEndToEndTests.QueryStrings.GeneratedCode; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; using OpenApiTests; using OpenApiTests.QueryStrings; using TestBuildingBlocks; using Xunit; using Xunit.Abstractions; -namespace OpenApiEndToEndTests.QueryStrings; +namespace OpenApiNSwagEndToEndTests.QueryStrings; public sealed class PaginationTests : IClassFixture, QueryStringsDbContext>> { private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; - private readonly ITestOutputHelper _testOutputHelper; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); public PaginationTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; - _testOutputHelper = testOutputHelper; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); } @@ -37,8 +37,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -50,7 +50,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Meta.ShouldNotBeNull(); response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); @@ -70,8 +70,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -83,7 +83,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(2); + response.Data.ShouldHaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Meta.ShouldNotBeNull(); @@ -104,8 +104,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -117,7 +117,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(2).StringId); response.Meta.ShouldNotBeNull(); response.Meta.ShouldContainKey("total").With(total => total.Should().Be(3)); @@ -127,8 +127,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Cannot_use_empty_page_size() { // Arrange - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -156,8 +156,8 @@ public async Task Cannot_use_empty_page_size() public async Task Cannot_use_empty_page_number() { // Arrange - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { diff --git a/test/OpenApiEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs similarity index 85% rename from test/OpenApiEndToEndTests/QueryStrings/SortTests.cs rename to test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs index e988989632..52e85dad0c 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SortTests.cs @@ -1,25 +1,25 @@ using System.Net; using FluentAssertions; -using JsonApiDotNetCore.OpenApi.Client; -using OpenApiEndToEndTests.QueryStrings.GeneratedCode; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; using OpenApiTests; using OpenApiTests.QueryStrings; using TestBuildingBlocks; using Xunit; using Xunit.Abstractions; -namespace OpenApiEndToEndTests.QueryStrings; +namespace OpenApiNSwagEndToEndTests.QueryStrings; public sealed class SortTests : IClassFixture, QueryStringsDbContext>> { private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; - private readonly ITestOutputHelper _testOutputHelper; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); public SortTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; - _testOutputHelper = testOutputHelper; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); } @@ -39,8 +39,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -51,7 +51,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString, null); // Assert - response.Data.Should().HaveCount(2); + response.Data.ShouldHaveCount(2); response.Data.ElementAt(0).Id.Should().Be(nodes[1].StringId); response.Data.ElementAt(1).Id.Should().Be(nodes[0].StringId); } @@ -72,8 +72,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -84,7 +84,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(2); + response.Data.ShouldHaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(1).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(0).StringId); } @@ -105,8 +105,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -117,7 +117,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(2); + response.Data.ShouldHaveCount(2); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(1).Id.Should().Be(node.Children.ElementAt(1).StringId); } @@ -126,8 +126,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Cannot_use_empty_sort() { // Arrange - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { diff --git a/test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs similarity index 85% rename from test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs rename to test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs index 05fa1f710a..c509082d40 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiNSwagEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -1,24 +1,24 @@ using FluentAssertions; -using OpenApiEndToEndTests.QueryStrings.GeneratedCode; +using OpenApiNSwagEndToEndTests.QueryStrings.GeneratedCode; using OpenApiTests; using OpenApiTests.QueryStrings; using TestBuildingBlocks; using Xunit; using Xunit.Abstractions; -namespace OpenApiEndToEndTests.QueryStrings; +namespace OpenApiNSwagEndToEndTests.QueryStrings; public sealed class SparseFieldSetTests : IClassFixture, QueryStringsDbContext>> { private readonly IntegrationTestContext, QueryStringsDbContext> _testContext; - private readonly ITestOutputHelper _testOutputHelper; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; private readonly QueryStringFakers _fakers = new(); public SparseFieldSetTests(IntegrationTestContext, QueryStringsDbContext> testContext, ITestOutputHelper testOutputHelper) { _testContext = testContext; - _testOutputHelper = testOutputHelper; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); testContext.UseController(); } @@ -36,8 +36,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -48,7 +48,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeCollectionAsync(queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.StringId); response.Data.ElementAt(0).Attributes.Name.Should().Be(node.Name); response.Data.ElementAt(0).Attributes.Comment.Should().BeNull(); @@ -67,8 +67,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -82,7 +82,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Id.Should().Be(node.StringId); response.Data.Attributes.Name.Should().BeNull(); response.Data.Attributes.Comment.Should().Be(node.Comment); - response.Data.Relationships.Parent.Should().NotBeNull(); + response.Data.Relationships.Parent.ShouldNotBeNull(); response.Data.Relationships.Children.Should().BeNull(); } @@ -100,8 +100,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -112,12 +112,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString, null); // Assert - response.Data.Should().HaveCount(1); + response.Data.ShouldHaveCount(1); response.Data.ElementAt(0).Id.Should().Be(node.Children.ElementAt(0).StringId); response.Data.ElementAt(0).Attributes.Name.Should().BeNull(); response.Data.ElementAt(0).Attributes.Comment.Should().Be(node.Children.ElementAt(0).Comment); response.Data.ElementAt(0).Relationships.Parent.Should().BeNull(); - response.Data.ElementAt(0).Relationships.Children.Should().NotBeNull(); + response.Data.ElementAt(0).Relationships.Children.ShouldNotBeNull(); } [Fact] @@ -133,8 +133,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { @@ -150,7 +150,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => response.Data.Attributes.Name.Should().BeNull(); response.Data.Attributes.Comment.Should().Be(node.Parent.Comment); response.Data.Relationships.Parent.Should().BeNull(); - response.Data.Relationships.Children.Should().NotBeNull(); + response.Data.Relationships.Children.ShouldNotBeNull(); } [Fact] @@ -165,8 +165,8 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - using HttpClient httpClient = _testContext.Factory.CreateClient(); - var apiClient = new QueryStringsClient(httpClient, _testOutputHelper); + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new QueryStringsClient(httpClient); var queryString = new Dictionary { diff --git a/test/OpenApiEndToEndTests/Headers/swagger.g.json b/test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiEndToEndTests/Headers/swagger.g.json rename to test/OpenApiTests/Headers/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/Headers/HeaderTests.cs b/test/OpenApiTests/Headers/HeaderTests.cs index 99b8738a05..9da34af6cd 100644 --- a/test/OpenApiTests/Headers/HeaderTests.cs +++ b/test/OpenApiTests/Headers/HeaderTests.cs @@ -15,7 +15,7 @@ public HeaderTests(OpenApiTestContext, HeadersD testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiEndToEndTests/Headers"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] diff --git a/test/OpenApiClientTests/LegacyClient/swagger.g.json b/test/OpenApiTests/LegacyOpenApiIntegration/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/LegacyClient/swagger.g.json rename to test/OpenApiTests/LegacyOpenApiIntegration/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs b/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs index 75bc093b25..2a98ceb6b7 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs +++ b/test/OpenApiTests/LegacyOpenApiIntegration/LegacyOpenApiIntegrationTests.cs @@ -15,7 +15,7 @@ public LegacyOpenApiIntegrationTests() UseController(); UseController(); - SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/LegacyClient"; + SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Fact] @@ -30,9 +30,9 @@ public async Task Retrieved_swagger_document_matches_expected_document() actualJsonText.Should().BeJson(expectedJsonText); } - private static async Task GetExpectedSwaggerDocumentAsync() + private async Task GetExpectedSwaggerDocumentAsync() { - const string embeddedResourceName = $"{nameof(OpenApiTests)}.{nameof(LegacyOpenApiIntegration)}.swagger.json"; + string embeddedResourceName = $"{GetType().Namespace!.Replace('/', '.')}.swagger.json"; var assembly = Assembly.GetExecutingAssembly(); await using Stream? stream = assembly.GetManifestResourceStream(embeddedResourceName); diff --git a/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs b/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs index ea72e0ba11..e3498ed6cc 100644 --- a/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/CamelCase/CamelCaseTests.cs @@ -15,7 +15,7 @@ public CamelCaseTests(OpenApiTestContext(); testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/NamingConventions/CamelCase"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Fact] diff --git a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json b/test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json rename to test/OpenApiTests/NamingConventions/CamelCase/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json b/test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json rename to test/OpenApiTests/NamingConventions/KebabCase/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs index 6c170ed024..6e516da190 100644 --- a/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/KebabCase/KebabCaseTests.cs @@ -15,7 +15,7 @@ public KebabCaseTests(OpenApiTestContext(); testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/NamingConventions/KebabCase"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Fact] diff --git a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json b/test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json rename to test/OpenApiTests/NamingConventions/PascalCase/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs b/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs index f501828e36..91a367d64a 100644 --- a/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs +++ b/test/OpenApiTests/NamingConventions/PascalCase/PascalCaseTests.cs @@ -16,7 +16,7 @@ public PascalCaseTests(OpenApiTestContext(); testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/NamingConventions/PascalCase"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Fact] diff --git a/test/OpenApiTests/OpenApiStartup.cs b/test/OpenApiTests/OpenApiStartup.cs index e46efe63f0..86e964cc49 100644 --- a/test/OpenApiTests/OpenApiStartup.cs +++ b/test/OpenApiTests/OpenApiStartup.cs @@ -13,11 +13,9 @@ public class OpenApiStartup : TestableStartup { public override void ConfigureServices(IServiceCollection services) { - IMvcCoreBuilder mvcBuilder = services.AddMvcCore(); + base.ConfigureServices(services); - services.AddJsonApi(SetJsonApiOptions, mvcBuilder: mvcBuilder); - - services.AddOpenApi(mvcBuilder, SetupSwaggerGenAction); + services.AddOpenApi(SetupSwaggerGenAction); } protected override void SetJsonApiOptions(JsonApiOptions options) diff --git a/test/OpenApiTests/OpenApiTestContext.cs b/test/OpenApiTests/OpenApiTestContext.cs index 9f4c578b87..6406a1a763 100644 --- a/test/OpenApiTests/OpenApiTestContext.cs +++ b/test/OpenApiTests/OpenApiTestContext.cs @@ -12,7 +12,7 @@ public class OpenApiTestContext : IntegrationTestContext> _lazySwaggerDocument; - internal string? SwaggerDocumentOutputDirectory { private get; set; } + internal string? SwaggerDocumentOutputDirectory { get; set; } public OpenApiTestContext() { @@ -41,8 +41,8 @@ private async Task CreateSwaggerDocumentAsync() private static string GetSwaggerDocumentAbsoluteOutputPath(string relativePath) { - string solutionRoot = Path.Combine(Assembly.GetExecutingAssembly().Location, "../../../../../../"); - string outputPath = Path.Combine(solutionRoot, relativePath, "swagger.g.json"); + string testRootDirectory = Path.Combine(Assembly.GetExecutingAssembly().Location, "../../../../../"); + string outputPath = Path.Combine(testRootDirectory, relativePath, "swagger.g.json"); return Path.GetFullPath(outputPath); } @@ -65,6 +65,9 @@ private static JsonElement ParseSwaggerDocument(string content) private static Task WriteToDiskAsync(string path, JsonElement jsonElement) { + string directory = Path.GetDirectoryName(path)!; + Directory.CreateDirectory(directory); + string contents = jsonElement.ToString(); return File.WriteAllTextAsync(path, contents); } diff --git a/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json b/test/OpenApiTests/QueryStrings/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiEndToEndTests/QueryStrings/swagger.g.json rename to test/OpenApiTests/QueryStrings/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/QueryStrings/QueryStringTests.cs b/test/OpenApiTests/QueryStrings/QueryStringTests.cs index ecff8a33ed..6f1d11f3b9 100644 --- a/test/OpenApiTests/QueryStrings/QueryStringTests.cs +++ b/test/OpenApiTests/QueryStrings/QueryStringTests.cs @@ -16,7 +16,7 @@ public QueryStringTests(OpenApiTestContext testContext.UseController(); testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiEndToEndTests/QueryStrings"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json rename to test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs index 5927cd79a8..62542f832d 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/NullabilityTests.cs @@ -14,7 +14,7 @@ public NullabilityTests(OpenApiTestContext, NrtOf _testContext = testContext; testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json rename to test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs index db0c7363e7..6602577442 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/NullabilityTests.cs @@ -14,7 +14,7 @@ public NullabilityTests(OpenApiTestContext, NrtO _testContext = testContext; testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json rename to test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs index 370d6b57a8..cb539f078e 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/NullabilityTests.cs @@ -14,7 +14,7 @@ public NullabilityTests(OpenApiTestContext, NrtOnD _testContext = testContext; testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json similarity index 100% rename from test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json rename to test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/GeneratedSwagger/swagger.g.json diff --git a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs index f2b997a74d..3f75d23a31 100644 --- a/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs +++ b/test/OpenApiTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/NullabilityTests.cs @@ -14,7 +14,7 @@ public NullabilityTests(OpenApiTestContext, NrtOn _testContext = testContext; testContext.UseController(); - testContext.SwaggerDocumentOutputDirectory = "test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn"; + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; } [Theory] diff --git a/test/TestBuildingBlocks/AssemblyInfo.cs b/test/TestBuildingBlocks/Properties/AssemblyInfo.cs similarity index 100% rename from test/TestBuildingBlocks/AssemblyInfo.cs rename to test/TestBuildingBlocks/Properties/AssemblyInfo.cs diff --git a/test/TestBuildingBlocks/StreamAssertions.cs b/test/TestBuildingBlocks/StreamAssertions.cs new file mode 100644 index 0000000000..a0b507dbe7 --- /dev/null +++ b/test/TestBuildingBlocks/StreamAssertions.cs @@ -0,0 +1,35 @@ +using FluentAssertions; +using FluentAssertions.Streams; + +namespace TestBuildingBlocks; + +public static class StreamAssertionsExtensions +{ + /// + /// Asserts that the current is empty. + /// + /// + /// The assertion for the to inspect. + /// + /// + /// A formatted phrase as is supported by explaining why the assertion is needed. If the phrase does not + /// start with the word because, it is prepended automatically. + /// + /// + /// Zero or more objects to format using the placeholders in . + /// + [CustomAssertion] + public static void BeNullOrEmpty(this StreamAssertions parent, string because = "", + params object[] becauseArgs) + where TSubject : Stream + where TAssertions : StreamAssertions + { + if (parent.Subject != null) + { + using var reader = new StreamReader(parent.Subject); + string content = reader.ReadToEnd(); + + content.Should().BeEmpty(because, becauseArgs); + } + } +} diff --git a/test/TestBuildingBlocks/XUnitLogHttpMessageHandler.cs b/test/TestBuildingBlocks/XUnitLogHttpMessageHandler.cs new file mode 100644 index 0000000000..5f321b2bd4 --- /dev/null +++ b/test/TestBuildingBlocks/XUnitLogHttpMessageHandler.cs @@ -0,0 +1,55 @@ +using Microsoft.Extensions.Logging; +using Xunit.Abstractions; + +namespace TestBuildingBlocks; + +/// +/// Writes incoming and outgoing HTTP messages to the test output window. +/// +public sealed class XUnitLogHttpMessageHandler : DelegatingHandler +{ + private readonly ILogger _logger; + + public XUnitLogHttpMessageHandler(ITestOutputHelper testOutputHelper) + { + ArgumentNullException.ThrowIfNull(testOutputHelper); + + _logger = CreateLogger(testOutputHelper); + } + + protected override async Task SendAsync(HttpRequestMessage request, CancellationToken cancellationToken) + { + if (_logger.IsEnabled(LogLevel.Debug)) + { + string? requestBody = request.Content == null ? null : await request.Content.ReadAsStringAsync(cancellationToken); + + string requestMessage = string.IsNullOrEmpty(requestBody) + ? $"--> {request}" + : $"--> {request}{Environment.NewLine}{Environment.NewLine}{requestBody}"; + + _logger.LogDebug(requestMessage); + } + + HttpResponseMessage response = await base.SendAsync(request, cancellationToken); + + if (_logger.IsEnabled(LogLevel.Debug)) + { + string responseBody = await response.Content.ReadAsStringAsync(cancellationToken); + + string responseMessage = string.IsNullOrEmpty(responseBody) + ? $"<-- {response}" + : $"<-- {response}{Environment.NewLine}{Environment.NewLine}{responseBody}"; + + _logger.LogDebug(responseMessage); + } + + return response; + } + + private static ILogger CreateLogger(ITestOutputHelper testOutputHelper) + { + var loggerProvider = new XUnitLoggerProvider(testOutputHelper, null, LogOutputFields.Message); + var loggerFactory = new LoggerFactory([loggerProvider]); + return loggerFactory.CreateLogger(); + } +}