Skip to content

Commit c8d2ec2

Browse files
committed
Add OpenAPI tests for ID obfuscation
1 parent 03bea8e commit c8d2ec2

File tree

114 files changed

+13768
-1
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

114 files changed

+13768
-1
lines changed

test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation;
44

5+
// Tip: Add [HideResourceIdTypeInOpenApi] if you're using OpenAPI with JsonApiDotNetCore.OpenApi.Swashbuckle.
56
public abstract class ObfuscatedIdentifiable : Identifiable<long>
67
{
78
protected override string? GetStringId(long value)
Lines changed: 194 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
// <auto-generated/>
2+
#nullable enable
3+
#pragma warning disable CS8625
4+
#pragma warning disable CS0618
5+
using Microsoft.Kiota.Abstractions.Extensions;
6+
using Microsoft.Kiota.Abstractions.Serialization;
7+
using Microsoft.Kiota.Abstractions;
8+
using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item;
9+
using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models;
10+
using System.Collections.Generic;
11+
using System.IO;
12+
using System.Threading.Tasks;
13+
using System.Threading;
14+
using System;
15+
namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts
16+
{
17+
/// <summary>
18+
/// Builds and executes requests for operations under \bankAccounts
19+
/// </summary>
20+
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
21+
public partial class BankAccountsRequestBuilder : BaseRequestBuilder
22+
{
23+
/// <summary>Gets an item from the OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.bankAccounts.item collection</summary>
24+
/// <param name="position">The identifier of the bankAccount to retrieve.</param>
25+
/// <returns>A <see cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder"/></returns>
26+
public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder this[string position]
27+
{
28+
get
29+
{
30+
var urlTplParams = new Dictionary<string, object>(PathParameters);
31+
urlTplParams.Add("id", position);
32+
return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder(urlTplParams, RequestAdapter);
33+
}
34+
}
35+
36+
/// <summary>
37+
/// Instantiates a new <see cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder"/> and sets the default values.
38+
/// </summary>
39+
/// <param name="pathParameters">Path parameters for the request</param>
40+
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
41+
public BankAccountsRequestBuilder(Dictionary<string, object> pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts{?query*}", pathParameters)
42+
{
43+
}
44+
45+
/// <summary>
46+
/// Instantiates a new <see cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder"/> and sets the default values.
47+
/// </summary>
48+
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
49+
/// <param name="requestAdapter">The request adapter to use to execute the requests.</param>
50+
public BankAccountsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts{?query*}", rawUrl)
51+
{
52+
}
53+
54+
/// <summary>
55+
/// Retrieves a collection of bankAccounts.
56+
/// </summary>
57+
/// <returns>A <see cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument"/></returns>
58+
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
59+
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
60+
/// <exception cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument">When receiving a 400 status code</exception>
61+
public async Task<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument?> GetAsync(Action<RequestConfiguration<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder.BankAccountsRequestBuilderGetQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
62+
{
63+
var requestInfo = ToGetRequestInformation(requestConfiguration);
64+
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
65+
{
66+
{ "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue },
67+
};
68+
return await RequestAdapter.SendAsync<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument>(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
69+
}
70+
71+
/// <summary>
72+
/// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.
73+
/// </summary>
74+
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
75+
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
76+
public async Task HeadAsync(Action<RequestConfiguration<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder.BankAccountsRequestBuilderHeadQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
77+
{
78+
var requestInfo = ToHeadRequestInformation(requestConfiguration);
79+
await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false);
80+
}
81+
82+
/// <summary>
83+
/// Creates a new bankAccount.
84+
/// </summary>
85+
/// <returns>A <see cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument"/></returns>
86+
/// <param name="body">The request body</param>
87+
/// <param name="cancellationToken">Cancellation token to use when cancelling requests</param>
88+
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
89+
/// <exception cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument">When receiving a 400 status code</exception>
90+
/// <exception cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument">When receiving a 403 status code</exception>
91+
/// <exception cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument">When receiving a 404 status code</exception>
92+
/// <exception cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument">When receiving a 409 status code</exception>
93+
/// <exception cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument">When receiving a 422 status code</exception>
94+
public async Task<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument?> PostAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountRequestDocument body, Action<RequestConfiguration<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder.BankAccountsRequestBuilderPostQueryParameters>>? requestConfiguration = default, CancellationToken cancellationToken = default)
95+
{
96+
_ = body ?? throw new ArgumentNullException(nameof(body));
97+
var requestInfo = ToPostRequestInformation(body, requestConfiguration);
98+
var errorMapping = new Dictionary<string, ParsableFactory<IParsable>>
99+
{
100+
{ "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue },
101+
{ "403", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue },
102+
{ "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue },
103+
{ "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue },
104+
{ "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue },
105+
};
106+
return await RequestAdapter.SendAsync<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument>(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false);
107+
}
108+
109+
/// <summary>
110+
/// Retrieves a collection of bankAccounts.
111+
/// </summary>
112+
/// <returns>A <see cref="RequestInformation"/></returns>
113+
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
114+
public RequestInformation ToGetRequestInformation(Action<RequestConfiguration<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder.BankAccountsRequestBuilderGetQueryParameters>>? requestConfiguration = default)
115+
{
116+
var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters);
117+
requestInfo.Configure(requestConfiguration);
118+
requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi");
119+
return requestInfo;
120+
}
121+
122+
/// <summary>
123+
/// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.
124+
/// </summary>
125+
/// <returns>A <see cref="RequestInformation"/></returns>
126+
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
127+
public RequestInformation ToHeadRequestInformation(Action<RequestConfiguration<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder.BankAccountsRequestBuilderHeadQueryParameters>>? requestConfiguration = default)
128+
{
129+
var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters);
130+
requestInfo.Configure(requestConfiguration);
131+
return requestInfo;
132+
}
133+
134+
/// <summary>
135+
/// Creates a new bankAccount.
136+
/// </summary>
137+
/// <returns>A <see cref="RequestInformation"/></returns>
138+
/// <param name="body">The request body</param>
139+
/// <param name="requestConfiguration">Configuration for the request such as headers, query parameters, and middleware options.</param>
140+
public RequestInformation ToPostRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountRequestDocument body, Action<RequestConfiguration<global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder.BankAccountsRequestBuilderPostQueryParameters>>? requestConfiguration = default)
141+
{
142+
_ = body ?? throw new ArgumentNullException(nameof(body));
143+
var requestInfo = new RequestInformation(Method.POST, UrlTemplate, PathParameters);
144+
requestInfo.Configure(requestConfiguration);
145+
requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi");
146+
requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body);
147+
return requestInfo;
148+
}
149+
150+
/// <summary>
151+
/// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored.
152+
/// </summary>
153+
/// <returns>A <see cref="global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder"/></returns>
154+
/// <param name="rawUrl">The raw URL to use for the request builder.</param>
155+
public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder WithUrl(string rawUrl)
156+
{
157+
return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder(rawUrl, RequestAdapter);
158+
}
159+
160+
/// <summary>
161+
/// Retrieves a collection of bankAccounts.
162+
/// </summary>
163+
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
164+
public partial class BankAccountsRequestBuilderGetQueryParameters
165+
{
166+
/// <summary>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.</summary>
167+
[QueryParameter("query")]
168+
public string? Query { get; set; }
169+
}
170+
171+
/// <summary>
172+
/// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched.
173+
/// </summary>
174+
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
175+
public partial class BankAccountsRequestBuilderHeadQueryParameters
176+
{
177+
/// <summary>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.</summary>
178+
[QueryParameter("query")]
179+
public string? Query { get; set; }
180+
}
181+
182+
/// <summary>
183+
/// Creates a new bankAccount.
184+
/// </summary>
185+
[global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")]
186+
public partial class BankAccountsRequestBuilderPostQueryParameters
187+
{
188+
/// <summary>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.</summary>
189+
[QueryParameter("query")]
190+
public string? Query { get; set; }
191+
}
192+
}
193+
}
194+
#pragma warning restore CS0618

0 commit comments

Comments
 (0)