diff --git a/src/JsonApiDotNetCore.OpenApi.Swashbuckle/Annotations/HideResourceIdTypeInOpenApiAttribute.cs b/src/JsonApiDotNetCore.OpenApi.Swashbuckle/Annotations/HideResourceIdTypeInOpenApiAttribute.cs new file mode 100644 index 0000000000..34ad22ffd1 --- /dev/null +++ b/src/JsonApiDotNetCore.OpenApi.Swashbuckle/Annotations/HideResourceIdTypeInOpenApiAttribute.cs @@ -0,0 +1,15 @@ +namespace JsonApiDotNetCore.OpenApi.Swashbuckle.Annotations; + +/// +/// Hides the underlying resource ID type in OpenAPI documents. +/// +/// +/// For example, when used on a resource type that implements ]]>, excludes the format property on the ID +/// schema. As a result, the ID type is displayed as string instead of +/// +/// string($int64) +/// +/// in SwaggerUI. +/// +[AttributeUsage(AttributeTargets.Class | AttributeTargets.Interface | AttributeTargets.Struct)] +public sealed class HideResourceIdTypeInOpenApiAttribute : Attribute; diff --git a/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/Components/ResourceIdSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/Components/ResourceIdSchemaGenerator.cs index 21bc5020ed..f361db8183 100644 --- a/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/Components/ResourceIdSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/Components/ResourceIdSchemaGenerator.cs @@ -1,4 +1,7 @@ +using System.Reflection; using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Middleware; +using JsonApiDotNetCore.OpenApi.Swashbuckle.Annotations; using Microsoft.OpenApi.Models; using Swashbuckle.AspNetCore.SwaggerGen; @@ -7,32 +10,48 @@ namespace JsonApiDotNetCore.OpenApi.Swashbuckle.SchemaGenerators.Components; internal sealed class ResourceIdSchemaGenerator { private readonly SchemaGenerator _defaultSchemaGenerator; + private readonly IControllerResourceMapping _controllerResourceMapping; - public ResourceIdSchemaGenerator(SchemaGenerator defaultSchemaGenerator) + public ResourceIdSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IControllerResourceMapping controllerResourceMapping) { ArgumentNullException.ThrowIfNull(defaultSchemaGenerator); + ArgumentNullException.ThrowIfNull(controllerResourceMapping); _defaultSchemaGenerator = defaultSchemaGenerator; + _controllerResourceMapping = controllerResourceMapping; } - public OpenApiSchema GenerateSchema(ResourceType resourceType, SchemaRepository schemaRepository) + public OpenApiSchema GenerateSchema(ParameterInfo parameter, SchemaRepository schemaRepository) { - ArgumentNullException.ThrowIfNull(resourceType); + ArgumentNullException.ThrowIfNull(parameter); + ArgumentNullException.ThrowIfNull(schemaRepository); + + Type? controllerType = parameter.Member.ReflectedType; + ConsistencyGuard.ThrowIf(controllerType == null); + + ResourceType? resourceType = _controllerResourceMapping.GetResourceTypeForController(controllerType); + ConsistencyGuard.ThrowIf(resourceType == null); - return GenerateSchema(resourceType.IdentityClrType, schemaRepository); + return GenerateSchema(resourceType, schemaRepository); } - public OpenApiSchema GenerateSchema(Type resourceIdClrType, SchemaRepository schemaRepository) + public OpenApiSchema GenerateSchema(ResourceType resourceType, SchemaRepository schemaRepository) { - ArgumentNullException.ThrowIfNull(resourceIdClrType); + ArgumentNullException.ThrowIfNull(resourceType); ArgumentNullException.ThrowIfNull(schemaRepository); - OpenApiSchema idSchema = _defaultSchemaGenerator.GenerateSchema(resourceIdClrType, schemaRepository); + OpenApiSchema idSchema = _defaultSchemaGenerator.GenerateSchema(resourceType.IdentityClrType, schemaRepository); ConsistencyGuard.ThrowIf(idSchema.Reference != null); idSchema.Type = "string"; - if (resourceIdClrType != typeof(string)) + var hideIdTypeAttribute = resourceType.ClrType.GetCustomAttribute(); + + if (hideIdTypeAttribute != null) + { + idSchema.Format = null; + } + else if (resourceType.IdentityClrType != typeof(string)) { // When using string IDs, it's discouraged (but possible) to use an empty string as primary key value, because // some things won't work: get-by-id, update and delete resource are impossible, and rendered links are unusable. diff --git a/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/JsonApiSchemaGenerator.cs index c7d50572c3..b8e1d9f053 100644 --- a/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi.Swashbuckle/SchemaGenerators/JsonApiSchemaGenerator.cs @@ -34,7 +34,7 @@ public OpenApiSchema GenerateSchema(Type schemaType, SchemaRepository schemaRepo if (parameterInfo is { Name: "id" } && IsJsonApiParameter(parameterInfo)) { - return _resourceIdSchemaGenerator.GenerateSchema(schemaType, schemaRepository); + return _resourceIdSchemaGenerator.GenerateSchema(parameterInfo, schemaRepository); } DocumentSchemaGenerator? schemaGenerator = GetDocumentSchemaGenerator(schemaType); diff --git a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs index 8ab2120d92..95365ed6a9 100644 --- a/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs +++ b/src/JsonApiDotNetCore/Configuration/ResourceGraphBuilder.cs @@ -167,6 +167,32 @@ private static bool IsImplicitManyToManyJoinEntity(IEntityType entityType) return entityType is { IsPropertyBag: true, HasSharedClrType: true }; } + /// + /// Removes a JSON:API resource. + /// + /// + /// The resource CLR type. + /// + public ResourceGraphBuilder Remove() + where TResource : class, IIdentifiable + { + return Remove(typeof(TResource)); + } + + /// + /// Removes a JSON:API resource. + /// + /// + /// The resource CLR type. + /// + public ResourceGraphBuilder Remove(Type resourceClrType) + { + ArgumentNullException.ThrowIfNull(resourceClrType); + + _resourceTypesByClrType.Remove(resourceClrType); + return this; + } + /// /// Adds a JSON:API resource. /// diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/BankAccountsController.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/BankAccountsController.cs index b34fe3a321..6b8b8e7f45 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/BankAccountsController.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/BankAccountsController.cs @@ -5,5 +5,5 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; public sealed class BankAccountsController( - IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) : ObfuscatedIdentifiableController(options, resourceGraph, loggerFactory, resourceService); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/DebitCardsController.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/DebitCardsController.cs index 7fb26d5708..a72e689ab0 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/DebitCardsController.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/DebitCardsController.cs @@ -5,5 +5,5 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; public sealed class DebitCardsController( - IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) : ObfuscatedIdentifiableController(options, resourceGraph, loggerFactory, resourceService); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/HexadecimalCodec.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/HexadecimalCodec.cs index a3feb15b9e..0cdc851308 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/HexadecimalCodec.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/HexadecimalCodec.cs @@ -8,7 +8,15 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; internal sealed class HexadecimalCodec { - public int Decode(string? value) + // This implementation is deliberately simple for demonstration purposes. + // Consider using something more robust, such as https://github.com/sqids/sqids-dotnet. + public static HexadecimalCodec Instance { get; } = new(); + + private HexadecimalCodec() + { + } + + public long Decode(string? value) { if (value == null) { @@ -25,7 +33,7 @@ public int Decode(string? value) } string stringValue = FromHexString(value[1..]); - return int.Parse(stringValue); + return long.Parse(stringValue, CultureInfo.InvariantCulture); } private static string FromHexString(string hexString) @@ -35,7 +43,7 @@ private static string FromHexString(string hexString) for (int index = 0; index < hexString.Length; index += 2) { string hexChar = hexString.Substring(index, 2); - byte bt = byte.Parse(hexChar, NumberStyles.HexNumber); + byte bt = byte.Parse(hexChar, NumberStyles.HexNumber, CultureInfo.InvariantCulture); bytes.Add(bt); } @@ -43,14 +51,14 @@ private static string FromHexString(string hexString) return new string(chars); } - public string? Encode(int value) + public string? Encode(long value) { if (value == 0) { return null; } - string stringValue = value.ToString(); + string stringValue = value.ToString(CultureInfo.InvariantCulture); return $"x{ToHexString(stringValue)}"; } @@ -60,7 +68,7 @@ private static string ToHexString(string value) foreach (byte bt in Encoding.ASCII.GetBytes(value)) { - builder.Append(bt.ToString("X2")); + builder.Append(bt.ToString("X2", CultureInfo.InvariantCulture)); } return builder.ToString(); diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs index e5383f3f7d..31646baefc 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/IdObfuscationTests.cs @@ -1,23 +1,57 @@ using System.Net; using FluentAssertions; +using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.Serialization.Objects; using Microsoft.EntityFrameworkCore; +using Microsoft.Extensions.DependencyInjection; using TestBuildingBlocks; using Xunit; namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; -public sealed class IdObfuscationTests : IClassFixture, ObfuscationDbContext>> +public sealed class IdObfuscationTests : IClassFixture> { - private readonly IntegrationTestContext, ObfuscationDbContext> _testContext; + private readonly IntegrationTestContext _testContext; private readonly ObfuscationFakers _fakers = new(); - public IdObfuscationTests(IntegrationTestContext, ObfuscationDbContext> testContext) + public IdObfuscationTests(IntegrationTestContext testContext) { _testContext = testContext; testContext.UseController(); testContext.UseController(); + testContext.UseController(); + + var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService(); + options.UseRelativeLinks = true; + } + + [Fact] + public void Encodes_resource_ID() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Id = 123; + + // Act + string? stringId = HexadecimalCodec.Instance.Encode(account.Id); + + // Assert + stringId.Should().Be(account.StringId); + } + + [Fact] + public void Decodes_resource_ID() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Id = 123; + + // Act + long id = HexadecimalCodec.Instance.Decode(account.StringId); + + // Assert + id.Should().Be(account.Id); } [Fact] @@ -41,8 +75,16 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[1].StringId); + responseDocument.Links.Should().NotBeNull(); + responseDocument.Links.Self.Should().Be(route); + responseDocument.Links.First.Should().Be($"/bankAccounts?filter=equals(id,%27{accounts[1].StringId}%27)"); + + responseDocument.Data.ManyValue.Should().ContainSingle().Which.With(resource => + { + resource.Id.Should().Be(accounts[1].StringId); + resource.Links.Should().NotBeNull(); + resource.Links.Self.Should().Be($"/bankAccounts/{accounts[1].StringId}"); + }); } [Fact] @@ -81,8 +123,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => await dbContext.SaveChangesAsync(); }); - var codec = new HexadecimalCodec(); - string route = $"/bankAccounts?filter=any(id,'{accounts[1].StringId}','{codec.Encode(Unknown.TypedId.Int32)}')"; + string route = $"/bankAccounts?filter=any(id,'{accounts[1].StringId}','{HexadecimalCodec.Instance.Encode(Unknown.TypedId.Int64)}')"; // Act (HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecuteGetAsync(route); @@ -90,8 +131,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Id.Should().Be(accounts[1].StringId); + responseDocument.Data.ManyValue.Should().ContainSingle().Which.Id.Should().Be(accounts[1].StringId); } [Fact] @@ -135,8 +175,12 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); + responseDocument.Links.Should().NotBeNull(); + responseDocument.Links.Self.Should().Be(route); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(card.StringId); + responseDocument.Data.SingleValue.Links.RefShould().NotBeNull().And.Subject.Self.Should().Be(route); } [Fact] @@ -160,9 +204,25 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); + responseDocument.Links.Should().NotBeNull(); + responseDocument.Links.Self.Should().Be(route); + responseDocument.Links.First.Should().Be(route); + responseDocument.Data.ManyValue.Should().HaveCount(2); - responseDocument.Data.ManyValue[0].Id.Should().Be(account.Cards[0].StringId); - responseDocument.Data.ManyValue[1].Id.Should().Be(account.Cards[1].StringId); + + responseDocument.Data.ManyValue[0].With(resource => + { + resource.Id.Should().Be(account.Cards[0].StringId); + resource.Links.Should().NotBeNull(); + resource.Links.Self.Should().Be($"/debitCards/{account.Cards[0].StringId}"); + }); + + responseDocument.Data.ManyValue[1].With(resource => + { + resource.Id.Should().Be(account.Cards[1].StringId); + resource.Links.Should().NotBeNull(); + resource.Links.Self.Should().Be($"/debitCards/{account.Cards[1].StringId}"); + }); } [Fact] @@ -186,13 +246,31 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); + responseDocument.Links.Should().NotBeNull(); + responseDocument.Links.Self.Should().Be(route); + responseDocument.Data.SingleValue.Should().NotBeNull(); responseDocument.Data.SingleValue.Id.Should().Be(account.StringId); - responseDocument.Included.Should().HaveCount(1); - responseDocument.Included[0].Id.Should().Be(account.Cards[0].StringId); - responseDocument.Included[0].Attributes.Should().HaveCount(1); - responseDocument.Included[0].Relationships.Should().BeNull(); + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("cards").WhoseValue.With(value => + { + value.Should().NotBeNull(); + value.Data.ManyValue.Should().ContainSingle().Which.Id.Should().Be(account.Cards[0].StringId); + + value.Links.Should().NotBeNull(); + value.Links.Self.Should().Be($"/bankAccounts/{account.StringId}/relationships/cards"); + value.Links.Related.Should().Be($"/bankAccounts/{account.StringId}/cards"); + }); + + responseDocument.Included.Should().ContainSingle().Which.With(resource => + { + resource.Id.Should().Be(account.Cards[0].StringId); + resource.Attributes.Should().HaveCount(1); + resource.Relationships.Should().BeNull(); + + resource.Links.Should().NotBeNull(); + resource.Links.Self.Should().Be($"/debitCards/{account.Cards[0].StringId}"); + }); } [Fact] @@ -216,8 +294,11 @@ await _testContext.RunOnDatabaseAsync(async dbContext => // Assert httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); - responseDocument.Data.ManyValue.Should().HaveCount(1); - responseDocument.Data.ManyValue[0].Id.Should().Be(account.Cards[0].StringId); + responseDocument.Links.Should().NotBeNull(); + responseDocument.Links.Self.Should().Be(route); + responseDocument.Links.First.Should().Be(route); + + responseDocument.Data.ManyValue.Should().ContainSingle().Which.Id.Should().Be(account.Cards[0].StringId); } [Fact] @@ -266,11 +347,22 @@ await _testContext.RunOnDatabaseAsync(async dbContext => httpResponse.ShouldHaveStatusCode(HttpStatusCode.Created); responseDocument.Data.SingleValue.Should().NotBeNull(); + + string newCardStringId = responseDocument.Data.SingleValue.Id.RefShould().NotBeNull().And.Subject; + + responseDocument.Data.SingleValue.Links.RefShould().NotBeNull().And.Subject.Self.Should().Be($"/debitCards/{newCardStringId}"); responseDocument.Data.SingleValue.Attributes.Should().ContainKey("ownerName").WhoseValue.Should().Be(newCard.OwnerName); responseDocument.Data.SingleValue.Attributes.Should().ContainKey("pinCode").WhoseValue.Should().Be(newCard.PinCode); - var codec = new HexadecimalCodec(); - int newCardId = codec.Decode(responseDocument.Data.SingleValue.Id); + responseDocument.Data.SingleValue.Relationships.Should().ContainKey("account").WhoseValue.With(value => + { + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().Be($"/debitCards/{newCardStringId}/relationships/account"); + value.Links.Related.Should().Be($"/debitCards/{newCardStringId}/account"); + }); + + long newCardId = HexadecimalCodec.Instance.Decode(responseDocument.Data.SingleValue.Id); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -476,8 +568,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => public async Task Cannot_delete_unknown_resource() { // Arrange - var codec = new HexadecimalCodec(); - string? stringId = codec.Encode(Unknown.TypedId.Int32); + string stringId = HexadecimalCodec.Instance.Encode(Unknown.TypedId.Int64)!; string route = $"/bankAccounts/{stringId}"; @@ -494,4 +585,111 @@ public async Task Cannot_delete_unknown_resource() error.Title.Should().Be("The requested resource does not exist."); error.Detail.Should().Be($"Resource of type 'bankAccounts' with ID '{stringId}' does not exist."); } + + [Fact] + public async Task Can_use_operations() + { + // Arrange + BankAccount newAccount = _fakers.BankAccount.GenerateOne(); + DebitCard newCard = _fakers.DebitCard.GenerateOne(); + + const string accountLocalId = "new-bank-account"; + + var requestBody = new + { + atomic__operations = new object[] + { + new + { + op = "add", + data = new + { + type = "bankAccounts", + lid = accountLocalId, + attributes = new + { + iban = newAccount.Iban + } + } + }, + new + { + op = "add", + data = new + { + type = "debitCards", + attributes = new + { + ownerName = newCard.OwnerName, + pinCode = newCard.PinCode + }, + relationships = new + { + account = new + { + data = new + { + type = "bankAccounts", + lid = accountLocalId + } + } + } + } + } + } + }; + + const string route = "/operations"; + + // Act + (HttpResponseMessage httpResponse, Document responseDocument) = await _testContext.ExecutePostAtomicAsync(route, requestBody); + + // Assert + httpResponse.ShouldHaveStatusCode(HttpStatusCode.OK); + + responseDocument.Results.Should().HaveCount(2); + + ResourceObject resultData1 = responseDocument.Results[0].Data.SingleValue.RefShould().NotBeNull().And.Subject; + ResourceObject resultData2 = responseDocument.Results[1].Data.SingleValue.RefShould().NotBeNull().And.Subject; + + string newAccountStringId = resultData1.Id.RefShould().NotBeNull().And.Subject; + string newCardStringId = resultData2.Id.RefShould().NotBeNull().And.Subject; + + resultData1.Type.Should().Be("bankAccounts"); + resultData1.Links.RefShould().NotBeNull().And.Subject.Self.Should().Be($"/bankAccounts/{newAccountStringId}"); + + resultData1.Relationships.Should().ContainKey("cards").WhoseValue.With(value => + { + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().Be($"/bankAccounts/{newAccountStringId}/relationships/cards"); + value.Links.Related.Should().Be($"/bankAccounts/{newAccountStringId}/cards"); + }); + + resultData2.Type.Should().Be("debitCards"); + resultData2.Links.RefShould().NotBeNull().And.Subject.Self.Should().Be($"/debitCards/{newCardStringId}"); + + resultData2.Relationships.Should().ContainKey("account").WhoseValue.With(value => + { + value.Should().NotBeNull(); + value.Links.Should().NotBeNull(); + value.Links.Self.Should().Be($"/debitCards/{newCardStringId}/relationships/account"); + value.Links.Related.Should().Be($"/debitCards/{newCardStringId}/account"); + }); + + long newAccountId = HexadecimalCodec.Instance.Decode(newAccountStringId); + long newCardId = HexadecimalCodec.Instance.Decode(newCardStringId); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + DebitCard cardInDatabase = await dbContext.DebitCards.Include(card => card.Account).FirstWithIdAsync(newCardId); + + cardInDatabase.OwnerName.Should().Be(newCard.OwnerName); + cardInDatabase.PinCode.Should().Be(newCard.PinCode); + + cardInDatabase.Account.Should().NotBeNull(); + cardInDatabase.Account.Id.Should().Be(newAccountId); + cardInDatabase.Account.Iban.Should().Be(newAccount.Iban); + }); + } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs index af6a8a1416..e968b33ef5 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiable.cs @@ -2,17 +2,16 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; -public abstract class ObfuscatedIdentifiable : Identifiable +// Tip: Add [HideResourceIdTypeInOpenApi] if you're using OpenAPI with JsonApiDotNetCore.OpenApi.Swashbuckle. +public abstract class ObfuscatedIdentifiable : Identifiable { - private static readonly HexadecimalCodec Codec = new(); - - protected override string? GetStringId(int value) + protected override string? GetStringId(long value) { - return value == 0 ? null : Codec.Encode(value); + return value == 0 ? null : HexadecimalCodec.Instance.Encode(value); } - protected override int GetTypedId(string? value) + protected override long GetTypedId(string? value) { - return value == null ? 0 : Codec.Decode(value); + return value == null ? 0 : HexadecimalCodec.Instance.Decode(value); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs index ffe73f7b9a..c9c096c3ea 100644 --- a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscatedIdentifiableController.cs @@ -11,12 +11,10 @@ namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; public abstract class ObfuscatedIdentifiableController( - IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) - : BaseJsonApiController(options, resourceGraph, loggerFactory, resourceService) - where TResource : class, IIdentifiable + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + : BaseJsonApiController(options, resourceGraph, loggerFactory, resourceService) + where TResource : class, IIdentifiable { - private readonly HexadecimalCodec _codec = new(); - [HttpGet] [HttpHead] public override Task GetAsync(CancellationToken cancellationToken) @@ -28,7 +26,7 @@ public override Task GetAsync(CancellationToken cancellationToken [HttpHead("{id}")] public Task GetAsync([Required] string id, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.GetAsync(idValue, cancellationToken); } @@ -37,7 +35,7 @@ public Task GetAsync([Required] string id, CancellationToken canc public Task GetSecondaryAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.GetSecondaryAsync(idValue, relationshipName, cancellationToken); } @@ -46,7 +44,7 @@ public Task GetSecondaryAsync([Required] string id, [Required] [P public Task GetRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.GetRelationshipAsync(idValue, relationshipName, cancellationToken); } @@ -60,14 +58,14 @@ public override Task PostAsync([FromBody] [Required] TResource re public Task PostRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, [FromBody] [Required] ISet rightResourceIds, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.PostRelationshipAsync(idValue, relationshipName, rightResourceIds, cancellationToken); } [HttpPatch("{id}")] public Task PatchAsync([Required] string id, [FromBody] [Required] TResource resource, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.PatchAsync(idValue, resource, cancellationToken); } @@ -76,14 +74,14 @@ public Task PatchAsync([Required] string id, [FromBody] [Required public Task PatchRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, [FromBody] [Required] object? rightValue, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.PatchRelationshipAsync(idValue, relationshipName, rightValue, cancellationToken); } [HttpDelete("{id}")] public Task DeleteAsync([Required] string id, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.DeleteAsync(idValue, cancellationToken); } @@ -91,7 +89,7 @@ public Task DeleteAsync([Required] string id, CancellationToken c public Task DeleteRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, [FromBody] [Required] ISet rightResourceIds, CancellationToken cancellationToken) { - int idValue = _codec.Decode(id); + long idValue = HexadecimalCodec.Instance.Decode(id); return base.DeleteRelationshipAsync(idValue, relationshipName, rightResourceIds, cancellationToken); } } diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationOperationFilter.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationOperationFilter.cs new file mode 100644 index 0000000000..a38b5e8f57 --- /dev/null +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationOperationFilter.cs @@ -0,0 +1,13 @@ +using JsonApiDotNetCore.AtomicOperations; +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; + +namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; + +internal sealed class ObfuscationOperationFilter : DefaultOperationFilter +{ + protected override JsonApiEndpoints? GetJsonApiEndpoints(ResourceType resourceType) + { + return resourceType.ClrType.Name == nameof(ObfuscatedIdentifiable) ? JsonApiEndpoints.None : JsonApiEndpoints.All; + } +} diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationStartup.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationStartup.cs new file mode 100644 index 0000000000..a9d8de87d7 --- /dev/null +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/ObfuscationStartup.cs @@ -0,0 +1,20 @@ +using JsonApiDotNetCore.AtomicOperations; +using JsonApiDotNetCore.Configuration; +using Microsoft.Extensions.DependencyInjection; +using TestBuildingBlocks; + +namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; + +public sealed class ObfuscationStartup : TestableStartup +{ + public override void ConfigureServices(IServiceCollection services) + { + services.AddSingleton(); + base.ConfigureServices(services); + } + + protected override void AddJsonApi(IServiceCollection services) + { + services.AddJsonApi(ConfigureJsonApiOptions, resources: builder => builder.Remove()); + } +} diff --git a/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/OperationsController.cs b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/OperationsController.cs new file mode 100644 index 0000000000..d501eea7bd --- /dev/null +++ b/test/JsonApiDotNetCoreTests/IntegrationTests/IdObfuscation/OperationsController.cs @@ -0,0 +1,13 @@ +using JsonApiDotNetCore.AtomicOperations; +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Middleware; +using JsonApiDotNetCore.Resources; +using Microsoft.Extensions.Logging; + +namespace JsonApiDotNetCoreTests.IntegrationTests.IdObfuscation; + +public sealed class OperationsController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IOperationsProcessor processor, IJsonApiRequest request, + ITargetedFields targetedFields, IAtomicOperationFilter operationFilter) + : JsonApiOperationsController(options, resourceGraph, loggerFactory, processor, request, targetedFields, operationFilter); diff --git a/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs b/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs index 8288595662..6ed5b6c67a 100644 --- a/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs +++ b/test/JsonApiDotNetCoreTests/UnitTests/ResourceGraph/ResourceGraphBuilderTests.cs @@ -163,6 +163,55 @@ public void Cannot_add_resource_that_implements_only_non_generic_IIdentifiable() .WithMessage($"Resource type '{typeof(ResourceWithoutId)}' implements 'IIdentifiable', but not 'IIdentifiable'."); } + [Fact] + public void Can_remove_existing_resource_type() + { + // Arrange + var options = new JsonApiOptions(); + var builder = new ResourceGraphBuilder(options, NullLoggerFactory.Instance); + builder.Add(); + builder.Add(); + + // Act + builder.Remove(); + + // Assert + IResourceGraph resourceGraph = builder.Build(); + resourceGraph.GetResourceTypes().Should().ContainSingle().Which.ClrType.Should().Be(); + } + + [Fact] + public void Can_remove_missing_resource_type() + { + // Arrange + var options = new JsonApiOptions(); + var builder = new ResourceGraphBuilder(options, NullLoggerFactory.Instance); + builder.Add(); + + // Act + builder.Remove(); + + // Assert + IResourceGraph resourceGraph = builder.Build(); + resourceGraph.GetResourceTypes().Should().ContainSingle().Which.ClrType.Should().Be(); + } + + [Fact] + public void Can_remove_non_resource_type() + { + // Arrange + var options = new JsonApiOptions(); + var builder = new ResourceGraphBuilder(options, NullLoggerFactory.Instance); + builder.Add(); + + // Act + builder.Remove(typeof(NonResource)); + + // Assert + IResourceGraph resourceGraph = builder.Build(); + resourceGraph.GetResourceTypes().Should().ContainSingle().Which.ClrType.Should().Be(); + } + [Fact] public void Cannot_build_graph_with_missing_related_HasOne_resource() { diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/BankAccountsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/BankAccountsRequestBuilder.cs new file mode 100644 index 0000000000..37930d4ebd --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/BankAccountsRequestBuilder.cs @@ -0,0 +1,194 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts +{ + /// + /// Builds and executes requests for operations under \bankAccounts + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsRequestBuilder : BaseRequestBuilder + { + /// Gets an item from the OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.bankAccounts.item collection + /// The identifier of the bankAccount to retrieve. + /// A + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public BankAccountsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public BankAccountsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts{?query*}", rawUrl) + { + } + + /// + /// Retrieves a collection of bankAccounts. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new bankAccount. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 403 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PostAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "403", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves a collection of bankAccounts. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + + /// + /// Creates a new bankAccount. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPostRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountRequestDocument body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves a collection of bankAccounts. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Creates a new bankAccount. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsRequestBuilderPostQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/BankAccountsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/BankAccountsItemRequestBuilder.cs new file mode 100644 index 0000000000..06f1e7d574 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/BankAccountsItemRequestBuilder.cs @@ -0,0 +1,223 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Cards; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item +{ + /// + /// Builds and executes requests for operations under \bankAccounts\{id} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsItemRequestBuilder : BaseRequestBuilder + { + /// The cards property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Cards.CardsRequestBuilder Cards + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Cards.CardsRequestBuilder(PathParameters, RequestAdapter); + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.RelationshipsRequestBuilder Relationships + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public BankAccountsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public BankAccountsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}{?query*}", rawUrl) + { + } + + /// + /// Deletes an existing bankAccount by its identifier. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 404 status code + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves an individual bankAccount by its identifier. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing bankAccount. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PatchAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing bankAccount by its identifier. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToDeleteRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Retrieves an individual bankAccount by its identifier. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + + /// + /// Updates an existing bankAccount. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPatchRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountRequestDocument body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.BankAccountsItemRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves an individual bankAccount by its identifier. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsItemRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsItemRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Updates an existing bankAccount. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class BankAccountsItemRequestBuilderPatchQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Cards/CardsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Cards/CardsRequestBuilder.cs new file mode 100644 index 0000000000..f4b5881108 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Cards/CardsRequestBuilder.cs @@ -0,0 +1,128 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Cards +{ + /// + /// Builds and executes requests for operations under \bankAccounts\{id}\cards + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CardsRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CardsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}/cards{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CardsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}/cards{?query*}", rawUrl) + { + } + + /// + /// Retrieves the related debitCards of an individual bankAccount's cards relationship. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardCollectionResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves the related debitCards of an individual bankAccount's cards relationship. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + 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. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Cards.CardsRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Cards.CardsRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves the related debitCards of an individual bankAccount's cards relationship. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CardsRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CardsRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Relationships/Cards/CardsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Relationships/Cards/CardsRequestBuilder.cs new file mode 100644 index 0000000000..e1f7102a09 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Relationships/Cards/CardsRequestBuilder.cs @@ -0,0 +1,248 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.Cards +{ + /// + /// Builds and executes requests for operations under \bankAccounts\{id}\relationships\cards + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CardsRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public CardsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}/relationships/cards{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public CardsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}/relationships/cards{?query*}", rawUrl) + { + } + + /// + /// Removes existing debitCards from the cards relationship of an individual bankAccount. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task DeleteAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToDeleteRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves the related debitCard identities of an individual bankAccount's cards relationship. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierCollectionResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Assigns existing debitCards to the cards relationship of an individual bankAccount. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PatchAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Adds existing debitCards to the cards relationship of an individual bankAccount. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PostAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Removes existing debitCards from the cards relationship of an individual bankAccount. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToDeleteRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Retrieves the related debitCard identities of an individual bankAccount's cards relationship. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + + /// + /// Assigns existing debitCards to the cards relationship of an individual bankAccount. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPatchRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Adds existing debitCards to the cards relationship of an individual bankAccount. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPostRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.Cards.CardsRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.Cards.CardsRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves the related debitCard identities of an individual bankAccount's cards relationship. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CardsRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class CardsRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..1b252b97df --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/BankAccounts/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,45 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.Cards; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships +{ + /// + /// Builds and executes requests for operations under \bankAccounts\{id}\relationships + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class RelationshipsRequestBuilder : BaseRequestBuilder + { + /// The cards property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.Cards.CardsRequestBuilder Cards + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.Item.Relationships.Cards.CardsRequestBuilder(PathParameters, RequestAdapter); + } + + /// + /// Instantiates a new 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}/bankAccounts/{id}/relationships", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/bankAccounts/{id}/relationships", rawUrl) + { + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/DebitCardsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/DebitCardsRequestBuilder.cs new file mode 100644 index 0000000000..20bcb7d70d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/DebitCardsRequestBuilder.cs @@ -0,0 +1,194 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards +{ + /// + /// Builds and executes requests for operations under \debitCards + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsRequestBuilder : BaseRequestBuilder + { + /// Gets an item from the OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.debitCards.item collection + /// The identifier of the debitCard to retrieve. + /// A + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.DebitCardsItemRequestBuilder this[string position] + { + get + { + var urlTplParams = new Dictionary(PathParameters); + urlTplParams.Add("id", position); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.DebitCardsItemRequestBuilder(urlTplParams, RequestAdapter); + } + } + + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public DebitCardsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public DebitCardsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards{?query*}", rawUrl) + { + } + + /// + /// Retrieves a collection of debitCards. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardCollectionResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Creates a new debitCard. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 403 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PostAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "403", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryDebitCardResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves a collection of debitCards. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + + /// + /// Creates a new debitCard. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPostRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardRequestDocument body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.DebitCardsRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.DebitCardsRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves a collection of debitCards. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Creates a new debitCard. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsRequestBuilderPostQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Account/AccountRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Account/AccountRequestBuilder.cs new file mode 100644 index 0000000000..b8b8f90b12 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Account/AccountRequestBuilder.cs @@ -0,0 +1,128 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Account +{ + /// + /// Builds and executes requests for operations under \debitCards\{id}\account + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class AccountRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AccountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}/account{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AccountRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}/account{?query*}", rawUrl) + { + } + + /// + /// Retrieves the related bankAccount of an individual debitCard's account relationship. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.SecondaryBankAccountResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves the related bankAccount of an individual debitCard's account relationship. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + 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. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Account.AccountRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Account.AccountRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves the related bankAccount of an individual debitCard's account relationship. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class AccountRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class AccountRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/DebitCardsItemRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/DebitCardsItemRequestBuilder.cs new file mode 100644 index 0000000000..58e668dbdc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/DebitCardsItemRequestBuilder.cs @@ -0,0 +1,223 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Account; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item +{ + /// + /// Builds and executes requests for operations under \debitCards\{id} + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsItemRequestBuilder : BaseRequestBuilder + { + /// The account property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Account.AccountRequestBuilder Account + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Account.AccountRequestBuilder(PathParameters, RequestAdapter); + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.RelationshipsRequestBuilder Relationships + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.RelationshipsRequestBuilder(PathParameters, RequestAdapter); + } + + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public DebitCardsItemRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public DebitCardsItemRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}{?query*}", rawUrl) + { + } + + /// + /// Deletes an existing debitCard by its identifier. + /// + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 404 status code + public async Task DeleteAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToDeleteRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves an individual debitCard by its identifier. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryDebitCardResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Updates an existing debitCard. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PatchAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryDebitCardResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Deletes an existing debitCard by its identifier. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToDeleteRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.DELETE, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Retrieves an individual debitCard by its identifier. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + + /// + /// Updates an existing debitCard. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPatchRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardRequestDocument body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.DebitCardsItemRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.DebitCardsItemRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves an individual debitCard by its identifier. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsItemRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsItemRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Updates an existing debitCard. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class DebitCardsItemRequestBuilderPatchQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Relationships/Account/AccountRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Relationships/Account/AccountRequestBuilder.cs new file mode 100644 index 0000000000..de0ae1ca90 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Relationships/Account/AccountRequestBuilder.cs @@ -0,0 +1,168 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.Account +{ + /// + /// Builds and executes requests for operations under \debitCards\{id}\relationships\account + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class AccountRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public AccountRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}/relationships/account{?query*}", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public AccountRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}/relationships/account{?query*}", rawUrl) + { + } + + /// + /// Retrieves the related bankAccount identity of an individual debitCard's account relationship. + /// + /// A + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + public async Task GetAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToGetRequestInformation(requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierResponseDocument.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. + public async Task HeadAsync(Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + var requestInfo = ToHeadRequestInformation(requestConfiguration); + await RequestAdapter.SendNoContentAsync(requestInfo, default, cancellationToken).ConfigureAwait(false); + } + + /// + /// Assigns an existing bankAccount to the account relationship of an individual debitCard. + /// + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PatchAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPatchRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + await RequestAdapter.SendNoContentAsync(requestInfo, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Retrieves the related bankAccount identity of an individual debitCard's account relationship. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToGetRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.GET, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + requestInfo.Headers.TryAdd("Accept", "application/vnd.api+json;ext=openapi"); + return requestInfo; + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + /// A + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToHeadRequestInformation(Action>? requestConfiguration = default) + { + var requestInfo = new RequestInformation(Method.HEAD, UrlTemplate, PathParameters); + requestInfo.Configure(requestConfiguration); + return requestInfo; + } + + /// + /// Assigns an existing bankAccount to the account relationship of an individual debitCard. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPatchRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest body, Action>? requestConfiguration = default) + { + _ = 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;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.Account.AccountRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.Account.AccountRequestBuilder(rawUrl, RequestAdapter); + } + + /// + /// Retrieves the related bankAccount identity of an individual debitCard's account relationship. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class AccountRequestBuilderGetQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + + /// + /// Compare the returned ETag HTTP header with an earlier one to determine if the response has changed since it was fetched. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class AccountRequestBuilderHeadQueryParameters + { + /// 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. + [QueryParameter("query")] + public string? Query { get; set; } + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Relationships/RelationshipsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Relationships/RelationshipsRequestBuilder.cs new file mode 100644 index 0000000000..cf3f9ecd9c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/DebitCards/Item/Relationships/RelationshipsRequestBuilder.cs @@ -0,0 +1,45 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.Account; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships +{ + /// + /// Builds and executes requests for operations under \debitCards\{id}\relationships + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class RelationshipsRequestBuilder : BaseRequestBuilder + { + /// The account property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.Account.AccountRequestBuilder Account + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.Item.Relationships.Account.AccountRequestBuilder(PathParameters, RequestAdapter); + } + + /// + /// Instantiates a new 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}/debitCards/{id}/relationships", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public RelationshipsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/debitCards/{id}/relationships", rawUrl) + { + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/IdObfuscationClient.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/IdObfuscationClient.cs new file mode 100644 index 0000000000..30816354ad --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/IdObfuscationClient.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +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.IdObfuscation.GeneratedCode.BankAccounts; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Operations; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode +{ + /// + /// The main entry point of the SDK, exposes the configuration and the fluent API. + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class IdObfuscationClient : BaseRequestBuilder + { + /// The bankAccounts property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder BankAccounts + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.BankAccounts.BankAccountsRequestBuilder(PathParameters, RequestAdapter); + } + + /// The debitCards property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.DebitCardsRequestBuilder DebitCards + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.DebitCards.DebitCardsRequestBuilder(PathParameters, RequestAdapter); + } + + /// The operations property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Operations.OperationsRequestBuilder Operations + { + get => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Operations.OperationsRequestBuilder(PathParameters, RequestAdapter); + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The backing store to use for the models. + /// The request adapter to use to execute the requests. + public IdObfuscationClient(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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AddOperationCode.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AddOperationCode.cs new file mode 100644 index 0000000000..73d67b4b2c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AddOperationCode.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum AddOperationCode + #pragma warning restore CS1591 + { + [EnumMember(Value = "add")] + #pragma warning disable CS1591 + Add, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AddToBankAccountCardsRelationshipOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AddToBankAccountCardsRelationshipOperation.cs new file mode 100644 index 0000000000..8e8304528d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AddToBankAccountCardsRelationshipOperation.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AddToBankAccountCardsRelationshipOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AddOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AddToBankAccountCardsRelationshipOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AddToBankAccountCardsRelationshipOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest.CreateFromDiscriminatorValue)?.AsList(); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier.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.WriteCollectionOfObjectValues("data", Data); + writer.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AtomicOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AtomicOperation.cs new file mode 100644 index 0000000000..98284e44d3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AtomicOperation.cs @@ -0,0 +1,93 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AtomicOperation : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The openapiDiscriminator property + public string? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public AtomicOperation() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "addBankAccount" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountOperation(), + "addDebitCard" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardOperation(), + "addToBankAccountCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AddToBankAccountCardsRelationshipOperation(), + "removeBankAccount" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DeleteBankAccountOperation(), + "removeDebitCard" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DeleteDebitCardOperation(), + "removeFromBankAccountCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RemoveFromBankAccountCardsRelationshipOperation(), + "updateBankAccount" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountOperation(), + "updateBankAccountCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountCardsRelationshipOperation(), + "updateDebitCard" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardOperation(), + "updateDebitCardAccount" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardAccountRelationshipOperation(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.CreateFromDiscriminatorValue); } }, + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteObjectValue("meta", Meta); + writer.WriteStringValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AtomicResult.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AtomicResult.cs new file mode 100644 index 0000000000..20049bcbe5 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AtomicResult.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AtomicResult : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public AtomicResult() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicResult CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicResult(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInBankAccountResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInBankAccountResponse.cs new file mode 100644 index 0000000000..4ccf5242e3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInBankAccountResponse.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInBankAccountResponse : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInResponse, IParsable + #pragma warning restore CS1591 + { + /// The iban property + public string? Iban + { + get { return BackingStore?.Get("iban"); } + set { BackingStore?.Set("iban", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInBankAccountResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInBankAccountResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "iban", n => { Iban = n.GetStringValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("iban", Iban); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateBankAccountRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateBankAccountRequest.cs new file mode 100644 index 0000000000..c368cdd597 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateBankAccountRequest.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInCreateBankAccountRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateRequest, IParsable + #pragma warning restore CS1591 + { + /// The iban property + public string? Iban + { + get { return BackingStore?.Get("iban"); } + set { BackingStore?.Set("iban", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateBankAccountRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateBankAccountRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "iban", n => { Iban = n.GetStringValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("iban", Iban); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateDebitCardRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateDebitCardRequest.cs new file mode 100644 index 0000000000..7220f279d0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateDebitCardRequest.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInCreateDebitCardRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateRequest, IParsable + #pragma warning restore CS1591 + { + /// The ownerName property + public string? OwnerName + { + get { return BackingStore?.Get("ownerName"); } + set { BackingStore?.Set("ownerName", value); } + } + + /// The pinCode property + public int? PinCode + { + get { return BackingStore?.Get("pinCode"); } + set { BackingStore?.Set("pinCode", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateDebitCardRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateDebitCardRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "ownerName", n => { OwnerName = n.GetStringValue(); } }, + { "pinCode", n => { PinCode = n.GetIntValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("ownerName", OwnerName); + writer.WriteIntValue("pinCode", PinCode); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateRequest.cs new file mode 100644 index 0000000000..7d4b1426eb --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInCreateRequest.cs @@ -0,0 +1,76 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInCreateRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The openapiDiscriminator property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public AttributesInCreateRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateBankAccountRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateDebitCardRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteEnumValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInDebitCardResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInDebitCardResponse.cs new file mode 100644 index 0000000000..7f3888ab85 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInDebitCardResponse.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInDebitCardResponse : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInResponse, IParsable + #pragma warning restore CS1591 + { + /// The ownerName property + public string? OwnerName + { + get { return BackingStore?.Get("ownerName"); } + set { BackingStore?.Set("ownerName", value); } + } + + /// The pinCode property + public int? PinCode + { + get { return BackingStore?.Get("pinCode"); } + set { BackingStore?.Set("pinCode", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInDebitCardResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInDebitCardResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "ownerName", n => { OwnerName = n.GetStringValue(); } }, + { "pinCode", n => { PinCode = n.GetIntValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("ownerName", OwnerName); + writer.WriteIntValue("pinCode", PinCode); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInResponse.cs new file mode 100644 index 0000000000..9f334f6c3f --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInResponse.cs @@ -0,0 +1,76 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The openapiDiscriminator property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public AttributesInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInBankAccountResponse(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInDebitCardResponse(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInResponse(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteEnumValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateBankAccountRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateBankAccountRequest.cs new file mode 100644 index 0000000000..c617fc2d69 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateBankAccountRequest.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInUpdateBankAccountRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateRequest, IParsable + #pragma warning restore CS1591 + { + /// The iban property + public string? Iban + { + get { return BackingStore?.Get("iban"); } + set { BackingStore?.Set("iban", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateBankAccountRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateBankAccountRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "iban", n => { Iban = n.GetStringValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("iban", Iban); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateDebitCardRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateDebitCardRequest.cs new file mode 100644 index 0000000000..fe8b16531d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateDebitCardRequest.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInUpdateDebitCardRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateRequest, IParsable + #pragma warning restore CS1591 + { + /// The ownerName property + public string? OwnerName + { + get { return BackingStore?.Get("ownerName"); } + set { BackingStore?.Set("ownerName", value); } + } + + /// The pinCode property + public int? PinCode + { + get { return BackingStore?.Get("pinCode"); } + set { BackingStore?.Set("pinCode", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateDebitCardRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateDebitCardRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "ownerName", n => { OwnerName = n.GetStringValue(); } }, + { "pinCode", n => { PinCode = n.GetIntValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("ownerName", OwnerName); + writer.WriteIntValue("pinCode", PinCode); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateRequest.cs new file mode 100644 index 0000000000..0fc4a8a517 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/AttributesInUpdateRequest.cs @@ -0,0 +1,76 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class AttributesInUpdateRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The openapiDiscriminator property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public AttributesInUpdateRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateBankAccountRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateDebitCardRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteEnumValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCardsRelationshipIdentifier.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCardsRelationshipIdentifier.cs new file mode 100644 index 0000000000..22e95f1aea --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCardsRelationshipIdentifier.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class BankAccountCardsRelationshipIdentifier : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// The relationship property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipName? Relationship + { + get { return BackingStore?.Get("relationship"); } + set { BackingStore?.Set("relationship", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public BankAccountCardsRelationshipIdentifier() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "id", n => { Id = n.GetStringValue(); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + { "relationship", n => { Relationship = n.GetEnumValue(); } }, + { "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.WriteStringValue("lid", Lid); + writer.WriteEnumValue("relationship", Relationship); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCardsRelationshipName.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCardsRelationshipName.cs new file mode 100644 index 0000000000..fbb3859f1d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCardsRelationshipName.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum BankAccountCardsRelationshipName + #pragma warning restore CS1591 + { + [EnumMember(Value = "cards")] + #pragma warning disable CS1591 + Cards, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCollectionResponseDocument.cs new file mode 100644 index 0000000000..1edf471c06 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountCollectionResponseDocument.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class BankAccountCollectionResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The included property + public List? Included + { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceCollectionTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public BankAccountCollectionResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCollectionResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "included", n => { Included = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceCollectionTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierInRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierInRequest.cs new file mode 100644 index 0000000000..7c444bad3c --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierInRequest.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class BankAccountIdentifierInRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.IdentifierInRequest, IParsable + #pragma warning restore CS1591 + { + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "id", n => { Id = n.GetStringValue(); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("id", Id); + writer.WriteStringValue("lid", Lid); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierInResponse.cs new file mode 100644 index 0000000000..15a17eb5d8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierInResponse.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class BankAccountIdentifierInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public BankAccountIdentifierInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "id", n => { Id = n.GetStringValue(); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.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.WriteStringValue("id", Id); + writer.WriteObjectValue("meta", Meta); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierResponseDocument.cs new file mode 100644 index 0000000000..33eaa39506 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountIdentifierResponseDocument.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class BankAccountIdentifierResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInResponse? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public BankAccountIdentifierResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInResponse.CreateFromDiscriminatorValue); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountResourceType.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountResourceType.cs new file mode 100644 index 0000000000..d1c3a85bc6 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/BankAccountResourceType.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum BankAccountResourceType + #pragma warning restore CS1591 + { + [EnumMember(Value = "bankAccounts")] + #pragma warning disable CS1591 + BankAccounts, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateBankAccountOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateBankAccountOperation.cs new file mode 100644 index 0000000000..4ba5b4c9ce --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateBankAccountOperation.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class CreateBankAccountOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AddOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest.CreateFromDiscriminatorValue); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + }; + } + + /// + /// 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("data", Data); + writer.WriteEnumValue("op", Op); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateBankAccountRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateBankAccountRequestDocument.cs new file mode 100644 index 0000000000..61b59d7c85 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateBankAccountRequestDocument.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class CreateBankAccountRequestDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public CreateBankAccountRequestDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateBankAccountRequestDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateDebitCardOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateDebitCardOperation.cs new file mode 100644 index 0000000000..2ee54aa59e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateDebitCardOperation.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class CreateDebitCardOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AddOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest.CreateFromDiscriminatorValue); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + }; + } + + /// + /// 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("data", Data); + writer.WriteEnumValue("op", Op); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateDebitCardRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateDebitCardRequestDocument.cs new file mode 100644 index 0000000000..4295dd6f22 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/CreateDebitCardRequestDocument.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class CreateDebitCardRequestDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public CreateDebitCardRequestDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.CreateDebitCardRequestDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInBankAccountResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInBankAccountResponse.cs new file mode 100644 index 0000000000..3d24b07f15 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInBankAccountResponse.cs @@ -0,0 +1,86 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DataInBankAccountResponse : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse, IParsable + #pragma warning restore CS1591 + { + /// The attributes property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInBankAccountResponse? Attributes + { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInBankAccountResponse? Relationships + { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "attributes", n => { Attributes = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInBankAccountResponse.CreateFromDiscriminatorValue); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceLinks.CreateFromDiscriminatorValue); } }, + { "relationships", n => { Relationships = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInBankAccountResponse.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.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("relationships", Relationships); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInCreateBankAccountRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInCreateBankAccountRequest.cs new file mode 100644 index 0000000000..b2656e9736 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInCreateBankAccountRequest.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DataInCreateBankAccountRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInCreateRequest, IParsable + #pragma warning restore CS1591 + { + /// The attributes property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateBankAccountRequest? Attributes + { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateBankAccountRequest? Relationships + { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "attributes", n => { Attributes = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateBankAccountRequest.CreateFromDiscriminatorValue); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + { "relationships", n => { Relationships = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateBankAccountRequest.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.WriteStringValue("lid", Lid); + writer.WriteObjectValue("relationships", Relationships); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInCreateDebitCardRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInCreateDebitCardRequest.cs new file mode 100644 index 0000000000..6399f9c0b1 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInCreateDebitCardRequest.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DataInCreateDebitCardRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInCreateRequest, IParsable + #pragma warning restore CS1591 + { + /// The attributes property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateDebitCardRequest? Attributes + { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateDebitCardRequest? Relationships + { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "attributes", n => { Attributes = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInCreateDebitCardRequest.CreateFromDiscriminatorValue); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + { "relationships", n => { Relationships = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateDebitCardRequest.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.WriteStringValue("lid", Lid); + writer.WriteObjectValue("relationships", Relationships); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInDebitCardResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInDebitCardResponse.cs new file mode 100644 index 0000000000..d1c123abbe --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInDebitCardResponse.cs @@ -0,0 +1,86 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DataInDebitCardResponse : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse, IParsable + #pragma warning restore CS1591 + { + /// The attributes property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInDebitCardResponse? Attributes + { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInDebitCardResponse? Relationships + { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInDebitCardResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInDebitCardResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "attributes", n => { Attributes = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInDebitCardResponse.CreateFromDiscriminatorValue); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceLinks.CreateFromDiscriminatorValue); } }, + { "relationships", n => { Relationships = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInDebitCardResponse.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.WriteStringValue("id", Id); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("relationships", Relationships); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInUpdateBankAccountRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInUpdateBankAccountRequest.cs new file mode 100644 index 0000000000..5c17399315 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInUpdateBankAccountRequest.cs @@ -0,0 +1,86 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DataInUpdateBankAccountRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInUpdateRequest, IParsable + #pragma warning restore CS1591 + { + /// The attributes property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateBankAccountRequest? Attributes + { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateBankAccountRequest? Relationships + { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "attributes", n => { Attributes = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateBankAccountRequest.CreateFromDiscriminatorValue); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + { "relationships", n => { Relationships = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateBankAccountRequest.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.WriteStringValue("id", Id); + writer.WriteStringValue("lid", Lid); + writer.WriteObjectValue("relationships", Relationships); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInUpdateDebitCardRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInUpdateDebitCardRequest.cs new file mode 100644 index 0000000000..ea2de41493 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DataInUpdateDebitCardRequest.cs @@ -0,0 +1,86 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DataInUpdateDebitCardRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInUpdateRequest, IParsable + #pragma warning restore CS1591 + { + /// The attributes property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateDebitCardRequest? Attributes + { + get { return BackingStore?.Get("attributes"); } + set { BackingStore?.Set("attributes", value); } + } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// The relationships property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateDebitCardRequest? Relationships + { + get { return BackingStore?.Get("relationships"); } + set { BackingStore?.Set("relationships", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "attributes", n => { Attributes = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AttributesInUpdateDebitCardRequest.CreateFromDiscriminatorValue); } }, + { "id", n => { Id = n.GetStringValue(); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + { "relationships", n => { Relationships = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateDebitCardRequest.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.WriteStringValue("id", Id); + writer.WriteStringValue("lid", Lid); + writer.WriteObjectValue("relationships", Relationships); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardAccountRelationshipIdentifier.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardAccountRelationshipIdentifier.cs new file mode 100644 index 0000000000..274b66c382 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardAccountRelationshipIdentifier.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DebitCardAccountRelationshipIdentifier : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// The relationship property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardAccountRelationshipName? Relationship + { + get { return BackingStore?.Get("relationship"); } + set { BackingStore?.Set("relationship", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public DebitCardAccountRelationshipIdentifier() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardAccountRelationshipIdentifier CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardAccountRelationshipIdentifier(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "id", n => { Id = n.GetStringValue(); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + { "relationship", n => { Relationship = n.GetEnumValue(); } }, + { "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.WriteStringValue("lid", Lid); + writer.WriteEnumValue("relationship", Relationship); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardAccountRelationshipName.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardAccountRelationshipName.cs new file mode 100644 index 0000000000..8936be12ed --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardAccountRelationshipName.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum DebitCardAccountRelationshipName + #pragma warning restore CS1591 + { + [EnumMember(Value = "account")] + #pragma warning disable CS1591 + Account, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardCollectionResponseDocument.cs new file mode 100644 index 0000000000..8c89a16715 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardCollectionResponseDocument.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DebitCardCollectionResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The included property + public List? Included + { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceCollectionTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public DebitCardCollectionResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardCollectionResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInDebitCardResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "included", n => { Included = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceCollectionTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierCollectionResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierCollectionResponseDocument.cs new file mode 100644 index 0000000000..f7449c674a --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierCollectionResponseDocument.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DebitCardIdentifierCollectionResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierCollectionTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public DebitCardIdentifierCollectionResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierCollectionResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierCollectionResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierCollectionTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierInRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierInRequest.cs new file mode 100644 index 0000000000..8f714afb03 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierInRequest.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DebitCardIdentifierInRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.IdentifierInRequest, IParsable + #pragma warning restore CS1591 + { + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The lid property + public string? Lid + { + get { return BackingStore?.Get("lid"); } + set { BackingStore?.Set("lid", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "id", n => { Id = n.GetStringValue(); } }, + { "lid", n => { Lid = n.GetStringValue(); } }, + }; + } + + /// + /// 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.WriteStringValue("id", Id); + writer.WriteStringValue("lid", Lid); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierInResponse.cs new file mode 100644 index 0000000000..bf52a1ee63 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardIdentifierInResponse.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DebitCardIdentifierInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public DebitCardIdentifierInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "id", n => { Id = n.GetStringValue(); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.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.WriteStringValue("id", Id); + writer.WriteObjectValue("meta", Meta); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardResourceType.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardResourceType.cs new file mode 100644 index 0000000000..18ea549bee --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DebitCardResourceType.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum DebitCardResourceType + #pragma warning restore CS1591 + { + [EnumMember(Value = "debitCards")] + #pragma warning disable CS1591 + DebitCards, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DeleteBankAccountOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DeleteBankAccountOperation.cs new file mode 100644 index 0000000000..7fdfde2fb8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DeleteBankAccountOperation.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DeleteBankAccountOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RemoveOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DeleteBankAccountOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DeleteBankAccountOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest.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.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DeleteDebitCardOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DeleteDebitCardOperation.cs new file mode 100644 index 0000000000..acd331e5f8 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/DeleteDebitCardOperation.cs @@ -0,0 +1,68 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class DeleteDebitCardOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RemoveOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DeleteDebitCardOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DeleteDebitCardOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest.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.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorLinks.cs new file mode 100644 index 0000000000..e67957e8ba --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorLinks.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ErrorLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// The about property + public string? About + { + get { return BackingStore?.Get("about"); } + set { BackingStore?.Set("about", value); } + } + + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The type property + public string? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ErrorLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorObject.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorObject.cs new file mode 100644 index 0000000000..d1416fb468 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorObject.cs @@ -0,0 +1,133 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ErrorObject : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The code property + public string? Code + { + get { return BackingStore?.Get("code"); } + set { BackingStore?.Set("code", value); } + } + + /// The detail property + public string? Detail + { + get { return BackingStore?.Get("detail"); } + set { BackingStore?.Set("detail", value); } + } + + /// The id property + public string? Id + { + get { return BackingStore?.Get("id"); } + set { BackingStore?.Set("id", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The source property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorSource? Source + { + get { return BackingStore?.Get("source"); } + set { BackingStore?.Set("source", value); } + } + + /// The status property + public string? Status + { + get { return BackingStore?.Get("status"); } + set { BackingStore?.Set("status", value); } + } + + /// The title property + public string? Title + { + get { return BackingStore?.Get("title"); } + set { BackingStore?.Set("title", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ErrorObject() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorObject CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorObject(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.CreateFromDiscriminatorValue); } }, + { "source", n => { Source = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorResponseDocument.cs new file mode 100644 index 0000000000..c5b5b9c392 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorResponseDocument.cs @@ -0,0 +1,92 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using Microsoft.Kiota.Abstractions; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ErrorResponseDocument : ApiException, IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The errors property + public List? Errors + { + get { return BackingStore?.Get?>("errors"); } + set { BackingStore?.Set("errors", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The primary error message. + public override string Message { get => base.Message; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ErrorResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "errors", n => { Errors = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorObject.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("errors", Errors); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorSource.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorSource.cs new file mode 100644 index 0000000000..966b2c6a9e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorSource.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ErrorSource : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The header property + public string? Header + { + get { return BackingStore?.Get("header"); } + set { BackingStore?.Set("header", value); } + } + + /// The parameter property + public string? Parameter + { + get { return BackingStore?.Get("parameter"); } + set { BackingStore?.Set("parameter", value); } + } + + /// The pointer property + public string? Pointer + { + get { return BackingStore?.Get("pointer"); } + set { BackingStore?.Set("pointer", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ErrorSource() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorSource CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorSource(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorTopLevelLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorTopLevelLinks.cs new file mode 100644 index 0000000000..6f7f56fc24 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ErrorTopLevelLinks.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ErrorTopLevelLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The describedby property + public string? Describedby + { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ErrorTopLevelLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorTopLevelLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorTopLevelLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/IdentifierInRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/IdentifierInRequest.cs new file mode 100644 index 0000000000..5dc6b08022 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/IdentifierInRequest.cs @@ -0,0 +1,85 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class IdentifierInRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public IdentifierInRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.IdentifierInRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.IdentifierInRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.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("meta", Meta); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/Meta.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/Meta.cs new file mode 100644 index 0000000000..0b80b73601 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/Meta.cs @@ -0,0 +1,70 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class Meta : IAdditionalDataHolder, IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// 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") ?? new Dictionary(); } + set { BackingStore.Set("AdditionalData", value); } + } + + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// + /// Instantiates a new and sets the default values. + /// + public Meta() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + AdditionalData = new Dictionary(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/OperationsRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/OperationsRequestDocument.cs new file mode 100644 index 0000000000..eeb7710491 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/OperationsRequestDocument.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class OperationsRequestDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// The atomicOperations property + public List? AtomicOperations + { + get { return BackingStore?.Get?>("atomic:operations"); } + set { BackingStore?.Set("atomic:operations", value); } + } + + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public OperationsRequestDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsRequestDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "atomic:operations", n => { AtomicOperations = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation.CreateFromDiscriminatorValue)?.AsList(); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("atomic:operations", AtomicOperations); + writer.WriteObjectValue("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/OperationsResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/OperationsResponseDocument.cs new file mode 100644 index 0000000000..fd53033107 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/OperationsResponseDocument.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class OperationsResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// The atomicResults property + public List? AtomicResults + { + get { return BackingStore?.Get?>("atomic:results"); } + set { BackingStore?.Set("atomic:results", value); } + } + + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public OperationsResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "atomic:results", n => { AtomicResults = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicResult.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("atomic:results", AtomicResults); + writer.WriteObjectValue("links", Links); + writer.WriteObjectValue("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/PrimaryBankAccountResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/PrimaryBankAccountResponseDocument.cs new file mode 100644 index 0000000000..f46253429d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/PrimaryBankAccountResponseDocument.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class PrimaryBankAccountResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The included property + public List? Included + { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public PrimaryBankAccountResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryBankAccountResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse.CreateFromDiscriminatorValue); } }, + { "included", n => { Included = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/PrimaryDebitCardResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/PrimaryDebitCardResponseDocument.cs new file mode 100644 index 0000000000..2f25c070bc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/PrimaryDebitCardResponseDocument.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class PrimaryDebitCardResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInDebitCardResponse? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The included property + public List? Included + { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public PrimaryDebitCardResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryDebitCardResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.PrimaryDebitCardResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInDebitCardResponse.CreateFromDiscriminatorValue); } }, + { "included", n => { Included = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipLinks.cs new file mode 100644 index 0000000000..9da60da7f9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipLinks.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The related property + public string? Related + { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public RelationshipLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInBankAccountResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInBankAccountResponse.cs new file mode 100644 index 0000000000..23804d0fef --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInBankAccountResponse.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInBankAccountResponse : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInResponse, IParsable + #pragma warning restore CS1591 + { + /// The cards property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInResponse? Cards + { + get { return BackingStore?.Get("cards"); } + set { BackingStore?.Set("cards", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInBankAccountResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInBankAccountResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "cards", n => { Cards = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInResponse.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("cards", Cards); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateBankAccountRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateBankAccountRequest.cs new file mode 100644 index 0000000000..a959b82b66 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateBankAccountRequest.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInCreateBankAccountRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateRequest, IParsable + #pragma warning restore CS1591 + { + /// The cards property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest? Cards + { + get { return BackingStore?.Get("cards"); } + set { BackingStore?.Set("cards", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateBankAccountRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateBankAccountRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "cards", n => { Cards = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest.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("cards", Cards); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateDebitCardRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateDebitCardRequest.cs new file mode 100644 index 0000000000..703e50055d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateDebitCardRequest.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInCreateDebitCardRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateRequest, IParsable + #pragma warning restore CS1591 + { + /// The account property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest? Account + { + get { return BackingStore?.Get("account"); } + set { BackingStore?.Set("account", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateDebitCardRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateDebitCardRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "account", n => { Account = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest.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("account", Account); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateRequest.cs new file mode 100644 index 0000000000..221fdd6a61 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInCreateRequest.cs @@ -0,0 +1,76 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInCreateRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The openapiDiscriminator property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public RelationshipsInCreateRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateBankAccountRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateDebitCardRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInCreateRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteEnumValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInDebitCardResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInDebitCardResponse.cs new file mode 100644 index 0000000000..eea5839da9 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInDebitCardResponse.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInDebitCardResponse : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInResponse, IParsable + #pragma warning restore CS1591 + { + /// The account property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInResponse? Account + { + get { return BackingStore?.Get("account"); } + set { BackingStore?.Set("account", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInDebitCardResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInDebitCardResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "account", n => { Account = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInResponse.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("account", Account); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInResponse.cs new file mode 100644 index 0000000000..1e28ecc430 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInResponse.cs @@ -0,0 +1,76 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The openapiDiscriminator property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public RelationshipsInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInBankAccountResponse(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInDebitCardResponse(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInResponse(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteEnumValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateBankAccountRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateBankAccountRequest.cs new file mode 100644 index 0000000000..1e01e9f5d4 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateBankAccountRequest.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInUpdateBankAccountRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateRequest, IParsable + #pragma warning restore CS1591 + { + /// The cards property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest? Cards + { + get { return BackingStore?.Get("cards"); } + set { BackingStore?.Set("cards", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateBankAccountRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateBankAccountRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "cards", n => { Cards = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest.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("cards", Cards); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateDebitCardRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateDebitCardRequest.cs new file mode 100644 index 0000000000..8d6b167dcb --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateDebitCardRequest.cs @@ -0,0 +1,59 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInUpdateDebitCardRequest : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateRequest, IParsable + #pragma warning restore CS1591 + { + /// The account property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest? Account + { + get { return BackingStore?.Get("account"); } + set { BackingStore?.Set("account", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateDebitCardRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateDebitCardRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "account", n => { Account = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest.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("account", Account); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateRequest.cs new file mode 100644 index 0000000000..a3f7b9c2a3 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RelationshipsInUpdateRequest.cs @@ -0,0 +1,76 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RelationshipsInUpdateRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The openapiDiscriminator property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? OpenapiDiscriminator + { + get { return BackingStore?.Get("openapi:discriminator"); } + set { BackingStore?.Set("openapi:discriminator", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public RelationshipsInUpdateRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("openapi:discriminator")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateBankAccountRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateDebitCardRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipsInUpdateRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "openapi:discriminator", n => { OpenapiDiscriminator = 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.WriteEnumValue("openapi:discriminator", OpenapiDiscriminator); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RemoveFromBankAccountCardsRelationshipOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RemoveFromBankAccountCardsRelationshipOperation.cs new file mode 100644 index 0000000000..c6d9e1adcf --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RemoveFromBankAccountCardsRelationshipOperation.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class RemoveFromBankAccountCardsRelationshipOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RemoveOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RemoveFromBankAccountCardsRelationshipOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RemoveFromBankAccountCardsRelationshipOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest.CreateFromDiscriminatorValue)?.AsList(); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier.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.WriteCollectionOfObjectValues("data", Data); + writer.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RemoveOperationCode.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RemoveOperationCode.cs new file mode 100644 index 0000000000..fc2c9980ef --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/RemoveOperationCode.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum RemoveOperationCode + #pragma warning restore CS1591 + { + [EnumMember(Value = "remove")] + #pragma warning disable CS1591 + Remove, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceCollectionTopLevelLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceCollectionTopLevelLinks.cs new file mode 100644 index 0000000000..a1945fd1d0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceCollectionTopLevelLinks.cs @@ -0,0 +1,115 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceCollectionTopLevelLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The describedby property + public string? Describedby + { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } + + /// The first property + public string? First + { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } + + /// The last property + public string? Last + { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } + + /// The next property + public string? Next + { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } + + /// The prev property + public string? Prev + { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceCollectionTopLevelLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceCollectionTopLevelLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceCollectionTopLevelLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceIdentifierCollectionTopLevelLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceIdentifierCollectionTopLevelLinks.cs new file mode 100644 index 0000000000..d1b3f3a799 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceIdentifierCollectionTopLevelLinks.cs @@ -0,0 +1,124 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceIdentifierCollectionTopLevelLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The describedby property + public string? Describedby + { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } + + /// The first property + public string? First + { + get { return BackingStore?.Get("first"); } + set { BackingStore?.Set("first", value); } + } + + /// The last property + public string? Last + { + get { return BackingStore?.Get("last"); } + set { BackingStore?.Set("last", value); } + } + + /// The next property + public string? Next + { + get { return BackingStore?.Get("next"); } + set { BackingStore?.Set("next", value); } + } + + /// The prev property + public string? Prev + { + get { return BackingStore?.Get("prev"); } + set { BackingStore?.Set("prev", value); } + } + + /// The related property + public string? Related + { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceIdentifierCollectionTopLevelLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierCollectionTopLevelLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierCollectionTopLevelLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceIdentifierTopLevelLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceIdentifierTopLevelLinks.cs new file mode 100644 index 0000000000..8a63f04950 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceIdentifierTopLevelLinks.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceIdentifierTopLevelLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The describedby property + public string? Describedby + { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } + + /// The related property + public string? Related + { + get { return BackingStore?.Get("related"); } + set { BackingStore?.Set("related", value); } + } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceIdentifierTopLevelLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierTopLevelLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceIdentifierTopLevelLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInCreateRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInCreateRequest.cs new file mode 100644 index 0000000000..168c9fea6d --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInCreateRequest.cs @@ -0,0 +1,85 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceInCreateRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceInCreateRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInCreateRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateBankAccountRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInCreateDebitCardRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInCreateRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.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("meta", Meta); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInResponse.cs new file mode 100644 index 0000000000..3050e3d441 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInResponse.cs @@ -0,0 +1,85 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInDebitCardResponse(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.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("meta", Meta); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInUpdateRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInUpdateRequest.cs new file mode 100644 index 0000000000..825923f950 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceInUpdateRequest.cs @@ -0,0 +1,85 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceInUpdateRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// The type property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceType? Type + { + get { return BackingStore?.Get("type"); } + set { BackingStore?.Set("type", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceInUpdateRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInUpdateRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + var mappingValue = parseNode.GetChildNode("type")?.GetStringValue(); + return mappingValue switch + { + "bankAccounts" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest(), + "debitCards" => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest(), + _ => new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInUpdateRequest(), + }; + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta.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("meta", Meta); + writer.WriteEnumValue("type", Type); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceLinks.cs new file mode 100644 index 0000000000..b17f9394e0 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceLinks.cs @@ -0,0 +1,70 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceTopLevelLinks.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceTopLevelLinks.cs new file mode 100644 index 0000000000..19ffe8b188 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceTopLevelLinks.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ResourceTopLevelLinks : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The describedby property + public string? Describedby + { + get { return BackingStore?.Get("describedby"); } + set { BackingStore?.Set("describedby", value); } + } + + /// The self property + public string? Self + { + get { return BackingStore?.Get("self"); } + set { BackingStore?.Set("self", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ResourceTopLevelLinks() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + 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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceType.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceType.cs new file mode 100644 index 0000000000..eae7c5d478 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ResourceType.cs @@ -0,0 +1,22 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum ResourceType + #pragma warning restore CS1591 + { + [EnumMember(Value = "bankAccounts")] + #pragma warning disable CS1591 + BankAccounts, + #pragma warning restore CS1591 + [EnumMember(Value = "debitCards")] + #pragma warning disable CS1591 + DebitCards, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/SecondaryBankAccountResponseDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/SecondaryBankAccountResponseDocument.cs new file mode 100644 index 0000000000..73ee756863 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/SecondaryBankAccountResponseDocument.cs @@ -0,0 +1,97 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class SecondaryBankAccountResponseDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The included property + public List? Included + { + get { return BackingStore?.Get?>("included"); } + set { BackingStore?.Set("included", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public SecondaryBankAccountResponseDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.SecondaryBankAccountResponseDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.SecondaryBankAccountResponseDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInBankAccountResponse.CreateFromDiscriminatorValue); } }, + { "included", n => { Included = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ResourceTopLevelLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToManyDebitCardInRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToManyDebitCardInRequest.cs new file mode 100644 index 0000000000..b38f0554ef --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToManyDebitCardInRequest.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ToManyDebitCardInRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ToManyDebitCardInRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest.CreateFromDiscriminatorValue)?.AsList(); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToManyDebitCardInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToManyDebitCardInResponse.cs new file mode 100644 index 0000000000..d419ad6925 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToManyDebitCardInResponse.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ToManyDebitCardInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ToManyDebitCardInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToManyDebitCardInResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInResponse.CreateFromDiscriminatorValue)?.AsList(); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToOneBankAccountInRequest.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToOneBankAccountInRequest.cs new file mode 100644 index 0000000000..51c3ec0ec2 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToOneBankAccountInRequest.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ToOneBankAccountInRequest : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ToOneBankAccountInRequest() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInRequest(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToOneBankAccountInResponse.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToOneBankAccountInResponse.cs new file mode 100644 index 0000000000..c534c9a85e --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/ToOneBankAccountInResponse.cs @@ -0,0 +1,88 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class ToOneBankAccountInResponse : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInResponse? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The links property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipLinks? Links + { + get { return BackingStore?.Get("links"); } + set { BackingStore?.Set("links", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public ToOneBankAccountInResponse() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInResponse CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ToOneBankAccountInResponse(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInResponse.CreateFromDiscriminatorValue); } }, + { "links", n => { Links = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.RelationshipLinks.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountCardsRelationshipOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountCardsRelationshipOperation.cs new file mode 100644 index 0000000000..9505921e74 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountCardsRelationshipOperation.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateBankAccountCardsRelationshipOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public List? Data + { + get { return BackingStore?.Get?>("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountCardsRelationshipOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountCardsRelationshipOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetCollectionOfObjectValues(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest.CreateFromDiscriminatorValue)?.AsList(); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountCardsRelationshipIdentifier.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.WriteCollectionOfObjectValues("data", Data); + writer.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountOperation.cs new file mode 100644 index 0000000000..d5ede842f7 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountOperation.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateBankAccountOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest.CreateFromDiscriminatorValue); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest.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("data", Data); + writer.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountRequestDocument.cs new file mode 100644 index 0000000000..e2318ca568 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateBankAccountRequestDocument.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateBankAccountRequestDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public UpdateBankAccountRequestDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateBankAccountRequestDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateBankAccountRequest.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardAccountRelationshipOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardAccountRelationshipOperation.cs new file mode 100644 index 0000000000..d42d5a63dc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardAccountRelationshipOperation.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateDebitCardAccountRelationshipOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardAccountRelationshipIdentifier? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardAccountRelationshipOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardAccountRelationshipOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.BankAccountIdentifierInRequest.CreateFromDiscriminatorValue); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardAccountRelationshipIdentifier.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("data", Data); + writer.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardOperation.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardOperation.cs new file mode 100644 index 0000000000..8c7d924a75 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardOperation.cs @@ -0,0 +1,77 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateDebitCardOperation : global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.AtomicOperation, IParsable + #pragma warning restore CS1591 + { + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The op property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateOperationCode? Op + { + get { return BackingStore?.Get("op"); } + set { BackingStore?.Set("op", value); } + } + + /// The ref property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest? Ref + { + get { return BackingStore?.Get("ref"); } + set { BackingStore?.Set("ref", value); } + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardOperation CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardOperation(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public override IDictionary> GetFieldDeserializers() + { + return new Dictionary>(base.GetFieldDeserializers()) + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest.CreateFromDiscriminatorValue); } }, + { "op", n => { Op = n.GetEnumValue(); } }, + { "ref", n => { Ref = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DebitCardIdentifierInRequest.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("data", Data); + writer.WriteEnumValue("op", Op); + writer.WriteObjectValue("ref", Ref); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardRequestDocument.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardRequestDocument.cs new file mode 100644 index 0000000000..f0611f5b08 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateDebitCardRequestDocument.cs @@ -0,0 +1,79 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions.Store; +using System.Collections.Generic; +using System.IO; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public partial class UpdateDebitCardRequestDocument : IBackedModel, IParsable + #pragma warning restore CS1591 + { + /// Stores model information. + public IBackingStore BackingStore { get; private set; } + + /// The data property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest? Data + { + get { return BackingStore?.Get("data"); } + set { BackingStore?.Set("data", value); } + } + + /// The meta property + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.Meta? Meta + { + get { return BackingStore?.Get("meta"); } + set { BackingStore?.Set("meta", value); } + } + + /// + /// Instantiates a new and sets the default values. + /// + public UpdateDebitCardRequestDocument() + { + BackingStore = BackingStoreFactorySingleton.Instance.CreateBackingStore(); + } + + /// + /// Creates a new instance of the appropriate class based on discriminator value + /// + /// A + /// The parse node to use to read the discriminator value and create the object + public static global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardRequestDocument CreateFromDiscriminatorValue(IParseNode parseNode) + { + _ = parseNode ?? throw new ArgumentNullException(nameof(parseNode)); + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.UpdateDebitCardRequestDocument(); + } + + /// + /// The deserialization information for the current model + /// + /// A IDictionary<string, Action<IParseNode>> + public virtual IDictionary> GetFieldDeserializers() + { + return new Dictionary> + { + { "data", n => { Data = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.DataInUpdateDebitCardRequest.CreateFromDiscriminatorValue); } }, + { "meta", n => { Meta = n.GetObjectValue(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.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("meta", Meta); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateOperationCode.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateOperationCode.cs new file mode 100644 index 0000000000..c7b36c314b --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Models/UpdateOperationCode.cs @@ -0,0 +1,18 @@ +// +#nullable enable +#pragma warning disable CS8625 +using System.Runtime.Serialization; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models +{ + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + #pragma warning disable CS1591 + public enum UpdateOperationCode + #pragma warning restore CS1591 + { + [EnumMember(Value = "update")] + #pragma warning disable CS1591 + Update, + #pragma warning restore CS1591 + } +} diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Operations/OperationsRequestBuilder.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Operations/OperationsRequestBuilder.cs new file mode 100644 index 0000000000..69cbc4bbf2 --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/GeneratedCode/Operations/OperationsRequestBuilder.cs @@ -0,0 +1,94 @@ +// +#nullable enable +#pragma warning disable CS8625 +#pragma warning disable CS0618 +using Microsoft.Kiota.Abstractions.Extensions; +using Microsoft.Kiota.Abstractions.Serialization; +using Microsoft.Kiota.Abstractions; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using System.Collections.Generic; +using System.IO; +using System.Threading.Tasks; +using System.Threading; +using System; +namespace OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Operations +{ + /// + /// Builds and executes requests for operations under \operations + /// + [global::System.CodeDom.Compiler.GeneratedCode("Kiota", "1.0.0")] + public partial class OperationsRequestBuilder : BaseRequestBuilder + { + /// + /// Instantiates a new and sets the default values. + /// + /// Path parameters for the request + /// The request adapter to use to execute the requests. + public OperationsRequestBuilder(Dictionary pathParameters, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/operations", pathParameters) + { + } + + /// + /// Instantiates a new and sets the default values. + /// + /// The raw URL to use for the request builder. + /// The request adapter to use to execute the requests. + public OperationsRequestBuilder(string rawUrl, IRequestAdapter requestAdapter) : base(requestAdapter, "{+baseurl}/operations", rawUrl) + { + } + + /// + /// Performs multiple mutations in a linear and atomic manner. + /// + /// A + /// The request body + /// Cancellation token to use when cancelling requests + /// Configuration for the request such as headers, query parameters, and middleware options. + /// When receiving a 400 status code + /// When receiving a 403 status code + /// When receiving a 404 status code + /// When receiving a 409 status code + /// When receiving a 422 status code + public async Task PostAsync(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsRequestDocument body, Action>? requestConfiguration = default, CancellationToken cancellationToken = default) + { + _ = body ?? throw new ArgumentNullException(nameof(body)); + var requestInfo = ToPostRequestInformation(body, requestConfiguration); + var errorMapping = new Dictionary> + { + { "400", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "403", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "404", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "409", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + { "422", global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.ErrorResponseDocument.CreateFromDiscriminatorValue }, + }; + return await RequestAdapter.SendAsync(requestInfo, global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsResponseDocument.CreateFromDiscriminatorValue, errorMapping, cancellationToken).ConfigureAwait(false); + } + + /// + /// Performs multiple mutations in a linear and atomic manner. + /// + /// A + /// The request body + /// Configuration for the request such as headers, query parameters, and middleware options. + public RequestInformation ToPostRequestInformation(global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models.OperationsRequestDocument body, Action>? requestConfiguration = default) + { + _ = 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;ext=atomic;ext=openapi"); + requestInfo.SetContentFromParsable(RequestAdapter, "application/vnd.api+json;ext=atomic;ext=openapi", body); + return requestInfo; + } + + /// + /// Returns a request builder with the provided arbitrary URL. Using this method means any other path or query parameters are ignored. + /// + /// A + /// The raw URL to use for the request builder. + public global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Operations.OperationsRequestBuilder WithUrl(string rawUrl) + { + return new global::OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Operations.OperationsRequestBuilder(rawUrl, RequestAdapter); + } + } +} +#pragma warning restore CS0618 diff --git a/test/OpenApiKiotaEndToEndTests/IdObfuscation/IdObfuscationTests.cs b/test/OpenApiKiotaEndToEndTests/IdObfuscation/IdObfuscationTests.cs new file mode 100644 index 0000000000..9c0164e2bc --- /dev/null +++ b/test/OpenApiKiotaEndToEndTests/IdObfuscation/IdObfuscationTests.cs @@ -0,0 +1,555 @@ +using System.Net; +using FluentAssertions; +using Microsoft.EntityFrameworkCore; +using Microsoft.Kiota.Http.HttpClientLibrary; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode; +using OpenApiKiotaEndToEndTests.IdObfuscation.GeneratedCode.Models; +using OpenApiTests.IdObfuscation; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiKiotaEndToEndTests.IdObfuscation; + +public sealed class IdObfuscationTests : IClassFixture>, IDisposable +{ + private readonly IntegrationTestContext _testContext; + private readonly TestableHttpClientRequestAdapterFactory _requestAdapterFactory; + private readonly ObfuscationFakers _fakers = new(); + + public IdObfuscationTests(IntegrationTestContext testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _requestAdapterFactory = new TestableHttpClientRequestAdapterFactory(testOutputHelper); + + testContext.UseController(); + testContext.UseController(); + testContext.UseController(); + } + + [Fact] + public async Task Can_get_primary_resources() + { + // Arrange + List accounts = _fakers.BankAccount.GenerateList(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.BankAccounts.AddRange(accounts); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + BankAccountCollectionResponseDocument? response = await apiClient.BankAccounts.GetAsync(); + + // Assert + response.Should().NotBeNull(); + response.Data.Should().HaveCount(2); + + response.Data.Should().ContainSingle(data => data.Id == accounts[0].StringId); + response.Data.Should().ContainSingle(data => data.Id == accounts[1].StringId); + } + + [Fact] + public async Task Cannot_get_primary_resource_for_invalid_ID() + { + // Arrange + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + Func action = async () => _ = await apiClient.BankAccounts["not-a-hex-value"].GetAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("400"); + error.Title.Should().Be("Invalid ID value."); + error.Detail.Should().Be("The value 'not-a-hex-value' is not a valid hexadecimal value."); + } + + [Fact] + public async Task Can_get_primary_resource_by_ID() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + PrimaryBankAccountResponseDocument? response = await apiClient.BankAccounts[account.StringId!].GetAsync(); + + // Assert + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); + response.Data.Id.Should().Be(account.StringId); + } + + [Fact] + public async Task Can_get_secondary_resources() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Cards = _fakers.DebitCard.GenerateList(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + DebitCardCollectionResponseDocument? response = await apiClient.BankAccounts[account.StringId!].Cards.GetAsync(); + + // Assert + response.Should().NotBeNull(); + response.Data.Should().HaveCount(2); + + response.Data.Should().ContainSingle(data => data.Id == account.Cards[0].StringId); + response.Data.Should().ContainSingle(data => data.Id == account.Cards[1].StringId); + } + + [Fact] + public async Task Can_include_resource_with_sparse_fieldset() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Cards = _fakers.DebitCard.GenerateList(1); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + using IDisposable scope = _requestAdapterFactory.WithQueryString(new Dictionary + { + ["include"] = "cards", + ["fields[debitCards]"] = "ownerName" + }); + + // Act + PrimaryBankAccountResponseDocument? response = await apiClient.BankAccounts[account.StringId!].GetAsync(); + + // Assert + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); + response.Data.Id.Should().Be(account.StringId); + + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.Cards.Should().NotBeNull(); + response.Data.Relationships.Cards.Data.Should().ContainSingle().Which.Id.Should().Be(account.Cards[0].StringId); + + response.Included.Should().HaveCount(1); + + response.Included.OfType().Should().ContainSingle().Which.With(include => + { + include.Id.Should().Be(account.Cards[0].StringId); + include.Attributes.Should().NotBeNull(); + include.Attributes.OwnerName.Should().Be(account.Cards[0].OwnerName); + include.Attributes.PinCode.Should().BeNull(); + }); + } + + [Fact] + public async Task Can_get_relationship() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Cards = _fakers.DebitCard.GenerateList(1); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + DebitCardIdentifierCollectionResponseDocument? response = await apiClient.BankAccounts[account.StringId!].Relationships.Cards.GetAsync(); + + // Assert + response.Should().NotBeNull(); + response.Data.Should().ContainSingle().Which.Id.Should().Be(account.Cards[0].StringId); + } + + [Fact] + public async Task Can_create_resource_with_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + DebitCard newCard = _fakers.DebitCard.GenerateOne(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(existingAccount); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + var requestBody = new CreateDebitCardRequestDocument + { + Data = new DataInCreateDebitCardRequest + { + Type = ResourceType.DebitCards, + Attributes = new AttributesInCreateDebitCardRequest + { + OwnerName = newCard.OwnerName, + PinCode = newCard.PinCode + }, + Relationships = new RelationshipsInCreateDebitCardRequest + { + Account = new ToOneBankAccountInRequest + { + Data = new BankAccountIdentifierInRequest + { + Type = ResourceType.BankAccounts, + Id = existingAccount.StringId + } + } + } + } + }; + + // Act + PrimaryDebitCardResponseDocument? response = await apiClient.DebitCards.PostAsync(requestBody); + + // Assert + response.Should().NotBeNull(); + response.Data.Should().NotBeNull(); + response.Data.Attributes.Should().NotBeNull(); + response.Data.Attributes.OwnerName.Should().Be(newCard.OwnerName); + response.Data.Attributes.PinCode.Should().Be(newCard.PinCode); + + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.Account.Should().NotBeNull(); + + long newCardId = HexadecimalCodec.Instance.Decode(response.Data.Id); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + DebitCard cardInDatabase = await dbContext.DebitCards.Include(card => card.Account).FirstWithIdAsync(newCardId); + + cardInDatabase.OwnerName.Should().Be(newCard.OwnerName); + cardInDatabase.PinCode.Should().Be(newCard.PinCode); + + cardInDatabase.Account.Should().NotBeNull(); + cardInDatabase.Account.Id.Should().Be(existingAccount.Id); + cardInDatabase.Account.StringId.Should().Be(existingAccount.StringId); + }); + } + + [Fact] + public async Task Can_update_resource_with_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(1); + + DebitCard existingCard = _fakers.DebitCard.GenerateOne(); + existingCard.Account = _fakers.BankAccount.GenerateOne(); + + string newIban = _fakers.BankAccount.GenerateOne().Iban; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.AddInRange(existingAccount, existingCard); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + var requestBody = new UpdateBankAccountRequestDocument + { + Data = new DataInUpdateBankAccountRequest + { + Type = ResourceType.BankAccounts, + Id = existingAccount.StringId, + Attributes = new AttributesInUpdateBankAccountRequest + { + Iban = newIban + }, + Relationships = new RelationshipsInUpdateBankAccountRequest + { + Cards = new ToManyDebitCardInRequest + { + Data = + [ + new DebitCardIdentifierInRequest + { + Type = ResourceType.DebitCards, + Id = existingCard.StringId + } + ] + } + } + } + }; + + // Act + PrimaryBankAccountResponseDocument? response = await apiClient.BankAccounts[existingAccount.StringId!].PatchAsync(requestBody); + + // Assert + response.Should().BeNull(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); + + accountInDatabase.Iban.Should().Be(newIban); + + accountInDatabase.Cards.Should().HaveCount(1); + accountInDatabase.Cards[0].Id.Should().Be(existingCard.Id); + accountInDatabase.Cards[0].StringId.Should().Be(existingCard.StringId); + }); + } + + [Fact] + public async Task Can_add_to_ToMany_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(1); + + DebitCard existingDebitCard = _fakers.DebitCard.GenerateOne(); + existingDebitCard.Account = _fakers.BankAccount.GenerateOne(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.AddInRange(existingAccount, existingDebitCard); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + var requestBody = new ToManyDebitCardInRequest + { + Data = + [ + new DebitCardIdentifierInRequest + { + Type = ResourceType.DebitCards, + Id = existingDebitCard.StringId + } + ] + }; + + // Act + await apiClient.BankAccounts[existingAccount.StringId!].Relationships.Cards.PostAsync(requestBody); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); + + accountInDatabase.Cards.Should().HaveCount(2); + }); + } + + [Fact] + public async Task Can_remove_from_ToMany_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(existingAccount); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + var requestBody = new ToManyDebitCardInRequest + { + Data = + [ + new DebitCardIdentifierInRequest + { + Type = ResourceType.DebitCards, + Id = existingAccount.Cards[0].StringId + } + ] + }; + + // Act + await apiClient.BankAccounts[existingAccount.StringId!].Relationships.Cards.DeleteAsync(requestBody); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); + + accountInDatabase.Cards.Should().HaveCount(1); + }); + } + + [Fact] + public async Task Can_delete_resource() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(1); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(existingAccount); + await dbContext.SaveChangesAsync(); + }); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + await apiClient.BankAccounts[existingAccount.StringId!].DeleteAsync(); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount? accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdOrDefaultAsync(existingAccount.Id); + + accountInDatabase.Should().BeNull(); + }); + } + + [Fact] + public async Task Cannot_delete_unknown_resource() + { + // Arrange + string stringId = HexadecimalCodec.Instance.Encode(Unknown.TypedId.Int64)!; + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + // Act + Func action = async () => await apiClient.BankAccounts[stringId].DeleteAsync(); + + // Assert + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'bankAccounts' with ID '{stringId}' does not exist."); + } + + [Fact] + public async Task Can_use_operations() + { + // Arrange + BankAccount newAccount = _fakers.BankAccount.GenerateOne(); + DebitCard newCard = _fakers.DebitCard.GenerateOne(); + + using HttpClientRequestAdapter requestAdapter = _requestAdapterFactory.CreateAdapter(_testContext.Factory); + var apiClient = new IdObfuscationClient(requestAdapter); + + const string accountLocalId = "new-bank-account"; + + var requestBody = new OperationsRequestDocument + { + AtomicOperations = + [ + new CreateBankAccountOperation + { + Data = new DataInCreateBankAccountRequest + { + Type = ResourceType.BankAccounts, + Lid = accountLocalId, + Attributes = new AttributesInCreateBankAccountRequest + { + Iban = newAccount.Iban + } + } + }, + new CreateDebitCardOperation + { + Data = new DataInCreateDebitCardRequest + { + Type = ResourceType.DebitCards, + Attributes = new AttributesInCreateDebitCardRequest + { + OwnerName = newCard.OwnerName, + PinCode = newCard.PinCode + }, + Relationships = new RelationshipsInCreateDebitCardRequest + { + Account = new ToOneBankAccountInRequest + { + Data = new BankAccountIdentifierInRequest + { + Type = ResourceType.BankAccounts, + Lid = accountLocalId + } + } + } + } + } + ] + }; + + // Act + OperationsResponseDocument? response = await apiClient.Operations.PostAsync(requestBody); + + // Assert + response.Should().NotBeNull(); + response.AtomicResults.Should().HaveCount(2); + + DataInBankAccountResponse accountData = response.AtomicResults.ElementAt(0).Data.Should().BeOfType().Subject!; + accountData.Relationships.Should().NotBeNull(); + accountData.Relationships.Cards.Should().NotBeNull(); + + DataInDebitCardResponse cardData = response.AtomicResults.ElementAt(1).Data.Should().BeOfType().Subject!; + cardData.Relationships.Should().NotBeNull(); + cardData.Relationships.Account.Should().NotBeNull(); + + long newAccountId = HexadecimalCodec.Instance.Decode(accountData.Id); + long newCardId = HexadecimalCodec.Instance.Decode(cardData.Id); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + DebitCard cardInDatabase = await dbContext.DebitCards.Include(card => card.Account).FirstWithIdAsync(newCardId); + + cardInDatabase.OwnerName.Should().Be(newCard.OwnerName); + cardInDatabase.PinCode.Should().Be(newCard.PinCode); + + cardInDatabase.Account.Should().NotBeNull(); + cardInDatabase.Account.Id.Should().Be(newAccountId); + cardInDatabase.Account.Iban.Should().Be(newAccount.Iban); + }); + } + + public void Dispose() + { + _requestAdapterFactory.Dispose(); + } +} diff --git a/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs b/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs index 5a6022df63..01d58871f9 100644 --- a/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/OpenApiKiotaEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs @@ -1,3 +1,4 @@ +using System.Net; using FluentAssertions; using Microsoft.Extensions.DependencyInjection; using Microsoft.Kiota.Http.HttpClientLibrary; @@ -59,14 +60,17 @@ public async Task Cannot_exceed_length_constraint(string firstName) Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/firstName"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/firstName"); } [Theory] @@ -97,14 +101,17 @@ public async Task Cannot_exceed_string_length_constraint(string userName) Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/userName"); } [Fact] @@ -133,14 +140,17 @@ public async Task Cannot_violate_regular_expression_constraint() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("Only letters are allowed."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("Only letters are allowed."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/userName"); } [Fact] @@ -169,14 +179,17 @@ public async Task Cannot_use_invalid_credit_card_number() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The CreditCard field is not a valid credit card number."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/creditCard"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The CreditCard field is not a valid credit card number."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/creditCard"); } [Fact] @@ -205,14 +218,17 @@ public async Task Cannot_use_invalid_email_address() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The Email field is not a valid e-mail address."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/email"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The Email field is not a valid e-mail address."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/email"); } [Fact] @@ -242,16 +258,19 @@ public async Task Cannot_exceed_min_length_constraint() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); const int minCharsInBase64 = SocialMediaAccount.MinPasswordCharsInBase64; - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/password"); + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/password"); } [Fact] @@ -280,16 +299,19 @@ public async Task Cannot_exceed_max_length_constraint() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); const int maxCharsInBase64 = SocialMediaAccount.MaxPasswordCharsInBase64; - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/password"); + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/password"); } [Theory] @@ -322,14 +344,17 @@ public async Task Cannot_use_double_outside_of_valid_range(double age) Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/age"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/age"); } [Fact] @@ -358,14 +383,17 @@ public async Task Cannot_use_relative_url() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/backgroundPicture"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/backgroundPicture"); } [Theory] @@ -396,14 +424,17 @@ public async Task Cannot_exceed_collection_length_constraint(int length) Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/tags"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/tags"); } [Fact] @@ -432,14 +463,17 @@ public async Task Cannot_use_non_allowed_value() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/countryCode"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/countryCode"); } [Fact] @@ -468,14 +502,17 @@ public async Task Cannot_use_denied_value() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/planet"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/planet"); } [Fact] @@ -504,14 +541,17 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range() Func action = () => apiClient.SocialMediaAccounts.PostAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync()).Which; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/nextRevalidation"); + ErrorResponseDocument exception = (await action.Should().ThrowExactlyAsync()).Which; + exception.ResponseStatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be($"Exception of type '{typeof(ErrorResponseDocument).FullName}' was thrown."); + exception.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Errors[0]; + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/nextRevalidation"); } [Fact] diff --git a/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj b/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj index 04e8e209d5..06ee9925e8 100644 --- a/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj +++ b/test/OpenApiKiotaEndToEndTests/OpenApiKiotaEndToEndTests.csproj @@ -44,6 +44,13 @@ ./%(Name)/GeneratedCode $(JsonApiExtraArguments) + + IdObfuscation + $(MSBuildProjectName).%(Name).GeneratedCode + %(Name)Client + ./%(Name)/GeneratedCode + $(JsonApiExtraArguments) + Links $(MSBuildProjectName).%(Name).GeneratedCode diff --git a/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs b/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs index 0ce536d479..40082ea7ee 100644 --- a/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs +++ b/test/OpenApiKiotaEndToEndTests/TestableHttpClientRequestAdapterFactory.cs @@ -2,6 +2,7 @@ using Microsoft.AspNetCore.Mvc.Testing; using Microsoft.Kiota.Abstractions.Authentication; using Microsoft.Kiota.Http.HttpClientLibrary; +using Microsoft.Kiota.Http.HttpClientLibrary.Middleware; using TestBuildingBlocks; using Xunit.Abstractions; @@ -9,8 +10,9 @@ namespace OpenApiKiotaEndToEndTests; internal sealed class TestableHttpClientRequestAdapterFactory : IDisposable { - private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly HeadersInspectionHandler _headersInspectionHandler = new(); private readonly SetQueryStringHttpMessageHandler _queryStringMessageHandler = new(); + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; public TestableHttpClientRequestAdapterFactory(ITestOutputHelper testOutputHelper) { @@ -24,11 +26,14 @@ public HttpClientRequestAdapter CreateAdapter(WebApplicationFactory delegatingHandlers = KiotaClientFactory.CreateDefaultHandlers(); - delegatingHandlers.Add(_queryStringMessageHandler); - delegatingHandlers.Add(_logHttpMessageHandler); - HttpClient httpClient = webApplicationFactory.CreateDefaultClient(delegatingHandlers.ToArray()); + DelegatingHandler[] handlers = + [ + _headersInspectionHandler, + _queryStringMessageHandler, + _logHttpMessageHandler + ]; + HttpClient httpClient = webApplicationFactory.CreateDefaultClient(handlers); return new HttpClientRequestAdapter(new AnonymousAuthenticationProvider(), httpClient: httpClient); } diff --git a/test/OpenApiNSwagEndToEndTests/IdObfuscation/IdObfuscationTests.cs b/test/OpenApiNSwagEndToEndTests/IdObfuscation/IdObfuscationTests.cs new file mode 100644 index 0000000000..7f1639691a --- /dev/null +++ b/test/OpenApiNSwagEndToEndTests/IdObfuscation/IdObfuscationTests.cs @@ -0,0 +1,539 @@ +using System.Net; +using FluentAssertions; +using JsonApiDotNetCore.OpenApi.Client.NSwag; +using Microsoft.EntityFrameworkCore; +using OpenApiNSwagEndToEndTests.IdObfuscation.GeneratedCode; +using OpenApiTests.IdObfuscation; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiNSwagEndToEndTests.IdObfuscation; + +public sealed class IdObfuscationTests : IClassFixture>, IDisposable +{ + private readonly IntegrationTestContext _testContext; + private readonly XUnitLogHttpMessageHandler _logHttpMessageHandler; + private readonly ObfuscationFakers _fakers = new(); + + public IdObfuscationTests(IntegrationTestContext testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + _logHttpMessageHandler = new XUnitLogHttpMessageHandler(testOutputHelper); + + testContext.UseController(); + testContext.UseController(); + testContext.UseController(); + } + + [Fact] + public async Task Can_get_primary_resources() + { + // Arrange + List accounts = _fakers.BankAccount.GenerateList(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + await dbContext.ClearTableAsync(); + dbContext.BankAccounts.AddRange(accounts); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + BankAccountCollectionResponseDocument response = await apiClient.GetBankAccountCollectionAsync(); + + // Assert + response.Data.Should().HaveCount(2); + + response.Data.Should().ContainSingle(data => data.Id == accounts[0].StringId); + response.Data.Should().ContainSingle(data => data.Id == accounts[1].StringId); + } + + [Fact] + public async Task Cannot_get_primary_resource_for_invalid_ID() + { + // Arrange + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + Func action = async () => _ = await apiClient.GetBankAccountAsync("not-a-hex-value"); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.BadRequest); + exception.Message.Should().Be("HTTP 400: The query string is invalid."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("400"); + error.Title.Should().Be("Invalid ID value."); + error.Detail.Should().Be("The value 'not-a-hex-value' is not a valid hexadecimal value."); + } + + [Fact] + public async Task Can_get_primary_resource_by_ID() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + PrimaryBankAccountResponseDocument response = await apiClient.GetBankAccountAsync(account.StringId!); + + // Assert + response.Data.Id.Should().Be(account.StringId); + } + + [Fact] + public async Task Can_get_secondary_resources() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Cards = _fakers.DebitCard.GenerateList(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + DebitCardCollectionResponseDocument response = await apiClient.GetBankAccountCardsAsync(account.StringId!); + + // Assert + response.Data.Should().HaveCount(2); + + response.Data.Should().ContainSingle(data => data.Id == account.Cards[0].StringId); + response.Data.Should().ContainSingle(data => data.Id == account.Cards[1].StringId); + } + + [Fact] + public async Task Can_include_resource_with_sparse_fieldset() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Cards = _fakers.DebitCard.GenerateList(1); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + var queryString = new Dictionary + { + ["include"] = "cards", + ["fields[debitCards]"] = "ownerName" + }; + + // Act + PrimaryBankAccountResponseDocument response = await apiClient.GetBankAccountAsync(account.StringId!, queryString); + + // Assert + response.Data.Id.Should().Be(account.StringId); + + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.Cards.Should().NotBeNull(); + response.Data.Relationships.Cards.Data.Should().ContainSingle().Which.Id.Should().Be(account.Cards[0].StringId); + + response.Included.Should().HaveCount(1); + + response.Included.OfType().Should().ContainSingle().Which.With(include => + { + include.Id.Should().Be(account.Cards[0].StringId); + include.Attributes.Should().NotBeNull(); + include.Attributes.OwnerName.Should().Be(account.Cards[0].OwnerName); + include.Attributes.PinCode.Should().BeNull(); + }); + } + + [Fact] + public async Task Can_get_relationship() + { + // Arrange + BankAccount account = _fakers.BankAccount.GenerateOne(); + account.Cards = _fakers.DebitCard.GenerateList(1); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(account); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + DebitCardIdentifierCollectionResponseDocument response = await apiClient.GetBankAccountCardsRelationshipAsync(account.StringId!); + + // Assert + response.Data.Should().ContainSingle().Which.Id.Should().Be(account.Cards[0].StringId); + } + + [Fact] + public async Task Can_create_resource_with_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + DebitCard newCard = _fakers.DebitCard.GenerateOne(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(existingAccount); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + var requestBody = new CreateDebitCardRequestDocument + { + Data = new DataInCreateDebitCardRequest + { + Attributes = new AttributesInCreateDebitCardRequest + { + OwnerName = newCard.OwnerName, + PinCode = newCard.PinCode + }, + Relationships = new RelationshipsInCreateDebitCardRequest + { + Account = new ToOneBankAccountInRequest + { + Data = new BankAccountIdentifierInRequest + { + Id = existingAccount.StringId + } + } + } + } + }; + + // Act + PrimaryDebitCardResponseDocument response = await apiClient.PostDebitCardAsync(requestBody); + + // Assert + response.Data.Attributes.Should().NotBeNull(); + response.Data.Attributes.OwnerName.Should().Be(newCard.OwnerName); + response.Data.Attributes.PinCode.Should().Be(newCard.PinCode); + + response.Data.Relationships.Should().NotBeNull(); + response.Data.Relationships.Account.Should().NotBeNull(); + + long newCardId = HexadecimalCodec.Instance.Decode(response.Data.Id); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + DebitCard cardInDatabase = await dbContext.DebitCards.Include(card => card.Account).FirstWithIdAsync(newCardId); + + cardInDatabase.OwnerName.Should().Be(newCard.OwnerName); + cardInDatabase.PinCode.Should().Be(newCard.PinCode); + + cardInDatabase.Account.Should().NotBeNull(); + cardInDatabase.Account.Id.Should().Be(existingAccount.Id); + cardInDatabase.Account.StringId.Should().Be(existingAccount.StringId); + }); + } + + [Fact] + public async Task Can_update_resource_with_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(1); + + DebitCard existingCard = _fakers.DebitCard.GenerateOne(); + existingCard.Account = _fakers.BankAccount.GenerateOne(); + + string newIban = _fakers.BankAccount.GenerateOne().Iban; + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.AddInRange(existingAccount, existingCard); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + var requestBody = new UpdateBankAccountRequestDocument + { + Data = new DataInUpdateBankAccountRequest + { + Id = existingAccount.StringId, + Attributes = new AttributesInUpdateBankAccountRequest + { + Iban = newIban + }, + Relationships = new RelationshipsInUpdateBankAccountRequest + { + Cards = new ToManyDebitCardInRequest + { + Data = new[] + { + new DebitCardIdentifierInRequest + { + Id = existingCard.StringId + } + } + } + } + } + }; + + // Act + PrimaryBankAccountResponseDocument? response = + await ApiResponse.TranslateAsync(async () => await apiClient.PatchBankAccountAsync(existingAccount.StringId!, requestBody)); + + // Assert + response.Should().BeNull(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); + + accountInDatabase.Iban.Should().Be(newIban); + + accountInDatabase.Cards.Should().HaveCount(1); + accountInDatabase.Cards[0].Id.Should().Be(existingCard.Id); + accountInDatabase.Cards[0].StringId.Should().Be(existingCard.StringId); + }); + } + + [Fact] + public async Task Can_add_to_ToMany_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(1); + + DebitCard existingDebitCard = _fakers.DebitCard.GenerateOne(); + existingDebitCard.Account = _fakers.BankAccount.GenerateOne(); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.AddInRange(existingAccount, existingDebitCard); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + var requestBody = new ToManyDebitCardInRequest + { + Data = new[] + { + new DebitCardIdentifierInRequest + { + Id = existingDebitCard.StringId + } + } + }; + + // Act + await apiClient.PostBankAccountCardsRelationshipAsync(existingAccount.StringId!, requestBody); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); + + accountInDatabase.Cards.Should().HaveCount(2); + }); + } + + [Fact] + public async Task Can_remove_from_ToMany_relationship() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(2); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(existingAccount); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + var requestBody = new ToManyDebitCardInRequest + { + Data = new[] + { + new DebitCardIdentifierInRequest + { + Id = existingAccount.Cards[0].StringId + } + } + }; + + // Act + await apiClient.DeleteBankAccountCardsRelationshipAsync(existingAccount.StringId!, requestBody); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdAsync(existingAccount.Id); + + accountInDatabase.Cards.Should().HaveCount(1); + }); + } + + [Fact] + public async Task Can_delete_resource() + { + // Arrange + BankAccount existingAccount = _fakers.BankAccount.GenerateOne(); + existingAccount.Cards = _fakers.DebitCard.GenerateList(1); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + dbContext.BankAccounts.Add(existingAccount); + await dbContext.SaveChangesAsync(); + }); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + await apiClient.DeleteBankAccountAsync(existingAccount.StringId!); + + // Assert + await _testContext.RunOnDatabaseAsync(async dbContext => + { + BankAccount? accountInDatabase = await dbContext.BankAccounts.Include(account => account.Cards).FirstWithIdOrDefaultAsync(existingAccount.Id); + + accountInDatabase.Should().BeNull(); + }); + } + + [Fact] + public async Task Cannot_delete_unknown_resource() + { + // Arrange + string stringId = HexadecimalCodec.Instance.Encode(Unknown.TypedId.Int64)!; + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + // Act + Func action = async () => await apiClient.DeleteBankAccountAsync(stringId); + + // Assert + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.NotFound); + exception.Message.Should().Be("HTTP 404: The bankAccount does not exist."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("404"); + error.Title.Should().Be("The requested resource does not exist."); + error.Detail.Should().Be($"Resource of type 'bankAccounts' with ID '{stringId}' does not exist."); + } + + [Fact] + public async Task Can_use_operations() + { + // Arrange + BankAccount newAccount = _fakers.BankAccount.GenerateOne(); + DebitCard newCard = _fakers.DebitCard.GenerateOne(); + + using HttpClient httpClient = _testContext.Factory.CreateDefaultClient(_logHttpMessageHandler); + var apiClient = new IdObfuscationClient(httpClient); + + const string accountLocalId = "new-bank-account"; + + var requestBody = new OperationsRequestDocument + { + Atomic_operations = new AtomicOperation[] + { + new CreateBankAccountOperation + { + Data = new DataInCreateBankAccountRequest + { + Lid = accountLocalId, + Attributes = new AttributesInCreateBankAccountRequest + { + Iban = newAccount.Iban + } + } + }, + new CreateDebitCardOperation + { + Data = new DataInCreateDebitCardRequest + { + Attributes = new AttributesInCreateDebitCardRequest + { + OwnerName = newCard.OwnerName, + PinCode = newCard.PinCode + }, + Relationships = new RelationshipsInCreateDebitCardRequest + { + Account = new ToOneBankAccountInRequest + { + Data = new BankAccountIdentifierInRequest + { + Lid = accountLocalId + } + } + } + } + } + } + }; + + // Act + OperationsResponseDocument? response = await ApiResponse.TranslateAsync(async () => await apiClient.PostOperationsAsync(requestBody)); + + // Assert + response.Should().NotBeNull(); + response.Atomic_results.Should().HaveCount(2); + + DataInBankAccountResponse accountData = response.Atomic_results.ElementAt(0).Data.Should().BeOfType().Subject!; + accountData.Relationships.Should().NotBeNull(); + accountData.Relationships.Cards.Should().NotBeNull(); + + DataInDebitCardResponse cardData = response.Atomic_results.ElementAt(1).Data.Should().BeOfType().Subject!; + cardData.Relationships.Should().NotBeNull(); + cardData.Relationships.Account.Should().NotBeNull(); + + long newAccountId = HexadecimalCodec.Instance.Decode(accountData.Id); + long newCardId = HexadecimalCodec.Instance.Decode(cardData.Id); + + await _testContext.RunOnDatabaseAsync(async dbContext => + { + DebitCard cardInDatabase = await dbContext.DebitCards.Include(card => card.Account).FirstWithIdAsync(newCardId); + + cardInDatabase.OwnerName.Should().Be(newCard.OwnerName); + cardInDatabase.PinCode.Should().Be(newCard.PinCode); + + cardInDatabase.Account.Should().NotBeNull(); + cardInDatabase.Account.Id.Should().Be(newAccountId); + cardInDatabase.Account.Iban.Should().Be(newAccount.Iban); + }); + } + + public void Dispose() + { + _logHttpMessageHandler.Dispose(); + } +} diff --git a/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs b/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs index bc15e6ee62..3280a443c7 100644 --- a/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ModelStateValidation/ModelStateValidationTests.cs @@ -1,3 +1,4 @@ +using System.Net; using FluentAssertions; using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.OpenApi.Client.NSwag; @@ -57,14 +58,17 @@ public async Task Cannot_exceed_length_constraint(string firstName) Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/firstName"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field FirstName must be a string or collection type with a minimum length of '2' and maximum length of '20'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/firstName"); } [Theory] @@ -94,14 +98,17 @@ public async Task Cannot_exceed_string_length_constraint(string userName) Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field UserName must be a string with a minimum length of 3 and a maximum length of 18."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/userName"); } [Fact] @@ -129,14 +136,17 @@ public async Task Cannot_violate_regular_expression_constraint() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("Only letters are allowed."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/userName"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("Only letters are allowed."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/userName"); } [Fact] @@ -164,14 +174,17 @@ public async Task Cannot_use_invalid_credit_card_number() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The CreditCard field is not a valid credit card number."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/creditCard"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The CreditCard field is not a valid credit card number."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/creditCard"); } [Fact] @@ -199,14 +212,17 @@ public async Task Cannot_use_invalid_email_address() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The Email field is not a valid e-mail address."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/email"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The Email field is not a valid e-mail address."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/email"); } [Fact] @@ -235,16 +251,19 @@ public async Task Cannot_exceed_min_length_constraint() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); const int minCharsInBase64 = SocialMediaAccount.MinPasswordCharsInBase64; - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/password"); + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be($"The field Password must be a string or array type with a minimum length of '{minCharsInBase64}'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/password"); } [Fact] @@ -272,16 +291,19 @@ public async Task Cannot_exceed_max_length_constraint() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); const int maxCharsInBase64 = SocialMediaAccount.MaxPasswordCharsInBase64; - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/password"); + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be($"The field Password must be a string or array type with a maximum length of '{maxCharsInBase64}'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/password"); } [Theory] @@ -313,14 +335,17 @@ public async Task Cannot_use_double_outside_of_valid_range(double age) Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/age"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be($"The field Age must be between {0.1} exclusive and {122.9} exclusive."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/age"); } [Fact] @@ -348,14 +373,17 @@ public async Task Cannot_use_relative_url() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/backgroundPicture"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The BackgroundPicture field is not a valid fully-qualified http, https, or ftp URL."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/backgroundPicture"); } [Theory] @@ -385,14 +413,17 @@ public async Task Cannot_exceed_collection_length_constraint(int length) Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/tags"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field Tags must be a string or collection type with a minimum length of '1' and maximum length of '10'."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/tags"); } [Fact] @@ -420,14 +451,17 @@ public async Task Cannot_use_non_allowed_value() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/countryCode"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The CountryCode field does not equal any of the values specified in AllowedValuesAttribute."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/countryCode"); } [Fact] @@ -455,14 +489,17 @@ public async Task Cannot_use_denied_value() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/planet"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The Planet field equals one of the values specified in DeniedValuesAttribute."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/planet"); } [Fact] @@ -490,14 +527,17 @@ public async Task Cannot_use_TimeSpan_outside_of_valid_range() Func action = () => apiClient.PostSocialMediaAccountAsync(requestBody); // Assert - ErrorResponseDocument response = (await action.Should().ThrowExactlyAsync>()).Which.Result; - response.Errors.Should().HaveCount(1); - - ErrorObject errorObject = response.Errors.First(); - errorObject.Title.Should().Be("Input validation failed."); - errorObject.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00."); - errorObject.Source.Should().NotBeNull(); - errorObject.Source.Pointer.Should().Be("/data/attributes/nextRevalidation"); + ApiException exception = (await action.Should().ThrowExactlyAsync>()).Which; + exception.StatusCode.Should().Be((int)HttpStatusCode.UnprocessableEntity); + exception.Message.Should().Be("HTTP 422: Validation of the request body failed."); + exception.Result.Errors.Should().HaveCount(1); + + ErrorObject error = exception.Result.Errors.ElementAt(0); + error.Status.Should().Be("422"); + error.Title.Should().Be("Input validation failed."); + error.Detail.Should().Be("The field NextRevalidation must be between 01:00:00 and 05:00:00."); + error.Source.Should().NotBeNull(); + error.Source.Pointer.Should().Be("/data/attributes/nextRevalidation"); } [Fact] diff --git a/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj index 74bde91b8e..debd635876 100644 --- a/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj +++ b/test/OpenApiNSwagEndToEndTests/OpenApiNSwagEndToEndTests.csproj @@ -1,4 +1,4 @@ - + net9.0 @@ -47,6 +47,12 @@ %(ClassName).cs true + + IdObfuscation + $(MSBuildProjectName).%(Name).GeneratedCode + %(Name)Client + %(ClassName).cs + QueryStrings $(MSBuildProjectName).%(Name).GeneratedCode diff --git a/test/OpenApiNSwagEndToEndTests/ResourceInheritance/NoOperations/ResourceInheritanceTests.cs b/test/OpenApiNSwagEndToEndTests/ResourceInheritance/NoOperations/ResourceInheritanceTests.cs index 7f6dcbbaaf..97288e4de4 100644 --- a/test/OpenApiNSwagEndToEndTests/ResourceInheritance/NoOperations/ResourceInheritanceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ResourceInheritance/NoOperations/ResourceInheritanceTests.cs @@ -933,7 +933,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => var apiClient = new NoOperationsInheritanceClient(httpClient); // Act - await ApiResponse.TranslateAsync(async () => await apiClient.DeleteBuildingAsync(existingMansion.StringId!)); + await apiClient.DeleteBuildingAsync(existingMansion.StringId!); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => diff --git a/test/OpenApiNSwagEndToEndTests/ResourceInheritance/OnlyRelationships/RelationshipInheritanceTests.cs b/test/OpenApiNSwagEndToEndTests/ResourceInheritance/OnlyRelationships/RelationshipInheritanceTests.cs index 9ad2ff8c41..5faad8f7b1 100644 --- a/test/OpenApiNSwagEndToEndTests/ResourceInheritance/OnlyRelationships/RelationshipInheritanceTests.cs +++ b/test/OpenApiNSwagEndToEndTests/ResourceInheritance/OnlyRelationships/RelationshipInheritanceTests.cs @@ -1,7 +1,6 @@ using FluentAssertions; using JsonApiDotNetCore.AtomicOperations; using JsonApiDotNetCore.Middleware; -using JsonApiDotNetCore.OpenApi.Client.NSwag; using Microsoft.EntityFrameworkCore; using Microsoft.Extensions.DependencyInjection; using OpenApiNSwagEndToEndTests.OnlyRelationshipsInheritance.GeneratedCode; @@ -182,7 +181,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchRoomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody)); + await apiClient.PatchRoomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -225,7 +224,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchRoomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody)); + await apiClient.PatchRoomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -268,7 +267,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchBathroomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody)); + await apiClient.PatchBathroomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -311,7 +310,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchBathroomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody)); + await apiClient.PatchBathroomResidenceRelationshipAsync(existingBathroom.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -359,7 +358,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PatchResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -407,7 +406,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PatchResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -455,7 +454,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PatchMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -503,7 +502,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PatchMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PatchMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -552,7 +551,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PostResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PostResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -602,7 +601,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PostResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PostResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -652,7 +651,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PostMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PostMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -702,7 +701,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PostMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.PostMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -747,7 +746,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.DeleteResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.DeleteResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -790,7 +789,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.DeleteResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.DeleteResidenceRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -833,7 +832,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.DeleteMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.DeleteMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => @@ -876,7 +875,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.DeleteMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody)); + await apiClient.DeleteMansionRoomsRelationshipAsync(existingMansion.StringId!, requestBody); // Assert await _testContext.RunOnDatabaseAsync(async dbContext => diff --git a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs index 60d20f3281..6c7dbdef59 100644 --- a/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs +++ b/test/OpenApiNSwagEndToEndTests/RestrictedControllers/UpdateRelationshipTests.cs @@ -55,8 +55,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => - await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody)); + await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -98,8 +97,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => - await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody)); + await apiClient.PatchWriteOnlyChannelUltraHighDefinitionVideoStreamRelationshipAsync(existingChannel.StringId!, requestBody); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -149,8 +147,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => - await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -192,8 +189,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => - await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + await apiClient.PatchWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -243,7 +239,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => await apiClient.PostWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + await apiClient.PostWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody); await _testContext.RunOnDatabaseAsync(async dbContext => { @@ -296,8 +292,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - await ApiResponse.TranslateAsync(async () => - await apiClient.DeleteWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody)); + await apiClient.DeleteWriteOnlyChannelAudioStreamsRelationshipAsync(existingChannel.StringId!, requestBody); await _testContext.RunOnDatabaseAsync(async dbContext => { diff --git a/test/OpenApiTests/IdObfuscation/BankAccount.cs b/test/OpenApiTests/IdObfuscation/BankAccount.cs new file mode 100644 index 0000000000..319b025856 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/BankAccount.cs @@ -0,0 +1,16 @@ +using JetBrains.Annotations; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Resources.Annotations; + +namespace OpenApiTests.IdObfuscation; + +[UsedImplicitly(ImplicitUseTargetFlags.Members)] +[Resource(GenerateControllerEndpoints = JsonApiEndpoints.None)] +public sealed class BankAccount : ObfuscatedIdentifiable +{ + [Attr] + public string Iban { get; set; } = null!; + + [HasMany] + public IList Cards { get; set; } = new List(); +} diff --git a/test/OpenApiTests/IdObfuscation/BankAccountsController.cs b/test/OpenApiTests/IdObfuscation/BankAccountsController.cs new file mode 100644 index 0000000000..b4093bc649 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/BankAccountsController.cs @@ -0,0 +1,9 @@ +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Services; +using Microsoft.Extensions.Logging; + +namespace OpenApiTests.IdObfuscation; + +public sealed class BankAccountsController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + : ObfuscatedIdentifiableController(options, resourceGraph, loggerFactory, resourceService); diff --git a/test/OpenApiTests/IdObfuscation/DebitCard.cs b/test/OpenApiTests/IdObfuscation/DebitCard.cs new file mode 100644 index 0000000000..7bbdb26a8e --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/DebitCard.cs @@ -0,0 +1,19 @@ +using JetBrains.Annotations; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Resources.Annotations; + +namespace OpenApiTests.IdObfuscation; + +[UsedImplicitly(ImplicitUseTargetFlags.Members)] +[Resource(GenerateControllerEndpoints = JsonApiEndpoints.None)] +public sealed class DebitCard : ObfuscatedIdentifiable +{ + [Attr] + public string OwnerName { get; set; } = null!; + + [Attr] + public short PinCode { get; set; } + + [HasOne] + public BankAccount Account { get; set; } = null!; +} diff --git a/test/OpenApiTests/IdObfuscation/DebitCardsController.cs b/test/OpenApiTests/IdObfuscation/DebitCardsController.cs new file mode 100644 index 0000000000..03a65ce626 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/DebitCardsController.cs @@ -0,0 +1,9 @@ +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Services; +using Microsoft.Extensions.Logging; + +namespace OpenApiTests.IdObfuscation; + +public sealed class DebitCardsController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + : ObfuscatedIdentifiableController(options, resourceGraph, loggerFactory, resourceService); diff --git a/test/OpenApiTests/IdObfuscation/GeneratedSwagger/swagger.g.json b/test/OpenApiTests/IdObfuscation/GeneratedSwagger/swagger.g.json new file mode 100644 index 0000000000..d635e607c9 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/GeneratedSwagger/swagger.g.json @@ -0,0 +1,4320 @@ +{ + "openapi": "3.0.4", + "info": { + "title": "OpenApiTests", + "version": "1.0" + }, + "servers": [ + { + "url": "http://localhost" + } + ], + "paths": { + "/bankAccounts": { + "get": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves a collection of bankAccounts.", + "operationId": "getBankAccountCollection", + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found bankAccounts, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/bankAccountCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves a collection of bankAccounts 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": "headBankAccountCollection", + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + } + } + }, + "post": { + "tags": [ + "bankAccounts" + ], + "summary": "Creates a new bankAccount.", + "operationId": "postBankAccount", + "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": "" + } + } + ], + "requestBody": { + "description": "The attributes and relationships of the bankAccount to create.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/createBankAccountRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "The bankAccount was successfully created, which resulted in additional changes. The newly created bankAccount is returned.", + "headers": { + "Location": { + "description": "The URL at which the newly created bankAccount can be retrieved.", + "required": true, + "schema": { + "type": "string", + "format": "uri" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/primaryBankAccountResponseDocument" + } + } + } + }, + "204": { + "description": "The bankAccount 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.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "403": { + "description": "Client-generated IDs cannot be used at this endpoint.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/bankAccounts/{id}": { + "get": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves an individual bankAccount by its identifier.", + "operationId": "getBankAccount", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found bankAccount.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/primaryBankAccountResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves an individual bankAccount 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": "headBankAccount", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The bankAccount does not exist." + } + } + }, + "patch": { + "tags": [ + "bankAccounts" + ], + "summary": "Updates an existing bankAccount.", + "operationId": "patchBankAccount", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount to update.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + } + ], + "requestBody": { + "description": "The attributes and relationships of the bankAccount to update. Omitted fields are left unchanged.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/updateBankAccountRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "The bankAccount was successfully updated, which resulted in additional changes. The updated bankAccount is returned.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/primaryBankAccountResponseDocument" + } + } + } + }, + "204": { + "description": "The bankAccount 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.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "A resource type or identifier in the request body is incompatible.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "delete": { + "tags": [ + "bankAccounts" + ], + "summary": "Deletes an existing bankAccount by its identifier.", + "operationId": "deleteBankAccount", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount to delete.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "The bankAccount was successfully deleted." + }, + "404": { + "description": "The bankAccount does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/bankAccounts/{id}/cards": { + "get": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves the related debitCards of an individual bankAccount's cards relationship.", + "operationId": "getBankAccountCards", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount whose related debitCards to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found debitCards, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/debitCardCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves the related debitCards of an individual bankAccount's cards 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": "headBankAccountCards", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount whose related debitCards to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The bankAccount does not exist." + } + } + } + }, + "/bankAccounts/{id}/relationships/cards": { + "get": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves the related debitCard identities of an individual bankAccount's cards relationship.", + "operationId": "getBankAccountCardsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount whose related debitCard identities to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "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.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found debitCard identities, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/debitCardIdentifierCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "bankAccounts" + ], + "summary": "Retrieves the related debitCard identities of an individual bankAccount's cards 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": "headBankAccountCardsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount whose related debitCard identities to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "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.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The bankAccount does not exist." + } + } + }, + "post": { + "tags": [ + "bankAccounts" + ], + "summary": "Adds existing debitCards to the cards relationship of an individual bankAccount.", + "operationId": "postBankAccountCardsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount to add debitCards to.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the debitCards to add to the cards relationship.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDebitCardInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The debitCards were successfully added, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "patch": { + "tags": [ + "bankAccounts" + ], + "summary": "Assigns existing debitCards to the cards relationship of an individual bankAccount.", + "operationId": "patchBankAccountCardsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount whose cards relationship to assign.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the debitCards to assign to the cards relationship, or an empty array to clear the relationship.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDebitCardInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The cards relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "delete": { + "tags": [ + "bankAccounts" + ], + "summary": "Removes existing debitCards from the cards relationship of an individual bankAccount.", + "operationId": "deleteBankAccountCardsRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the bankAccount to remove debitCards from.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identities of the debitCards to remove from the cards relationship.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDebitCardInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The debitCards were successfully removed, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The bankAccount or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/debitCards": { + "get": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves a collection of debitCards.", + "operationId": "getDebitCardCollection", + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found debitCards, or an empty array if none were found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/debitCardCollectionResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves a collection of debitCards 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": "headDebitCardCollection", + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + } + } + }, + "post": { + "tags": [ + "debitCards" + ], + "summary": "Creates a new debitCard.", + "operationId": "postDebitCard", + "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": "" + } + } + ], + "requestBody": { + "description": "The attributes and relationships of the debitCard to create.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/createDebitCardRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "201": { + "description": "The debitCard was successfully created, which resulted in additional changes. The newly created debitCard is returned.", + "headers": { + "Location": { + "description": "The URL at which the newly created debitCard can be retrieved.", + "required": true, + "schema": { + "type": "string", + "format": "uri" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/primaryDebitCardResponseDocument" + } + } + } + }, + "204": { + "description": "The debitCard 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.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "403": { + "description": "Client-generated IDs cannot be used at this endpoint.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "A related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/debitCards/{id}": { + "get": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves an individual debitCard by its identifier.", + "operationId": "getDebitCard", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found debitCard.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/primaryDebitCardResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The debitCard does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves an individual debitCard 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": "headDebitCard", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The debitCard does not exist." + } + } + }, + "patch": { + "tags": [ + "debitCards" + ], + "summary": "Updates an existing debitCard.", + "operationId": "patchDebitCard", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard to update.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + } + ], + "requestBody": { + "description": "The attributes and relationships of the debitCard to update. Omitted fields are left unchanged.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/updateDebitCardRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "The debitCard was successfully updated, which resulted in additional changes. The updated debitCard is returned.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/primaryDebitCardResponseDocument" + } + } + } + }, + "204": { + "description": "The debitCard 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.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The debitCard or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "A resource type or identifier in the request body is incompatible.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "delete": { + "tags": [ + "debitCards" + ], + "summary": "Deletes an existing debitCard by its identifier.", + "operationId": "deleteDebitCard", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard to delete.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "responses": { + "204": { + "description": "The debitCard was successfully deleted." + }, + "404": { + "description": "The debitCard does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/debitCards/{id}/account": { + "get": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves the related bankAccount of an individual debitCard's account relationship.", + "operationId": "getDebitCardAccount", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard whose related bankAccount to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found bankAccount, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/secondaryBankAccountResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The debitCard does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves the related bankAccount of an individual debitCard's account 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": "headDebitCardAccount", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard whose related bankAccount to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "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": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The debitCard does not exist." + } + } + } + }, + "/debitCards/{id}/relationships/account": { + "get": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves the related bankAccount identity of an individual debitCard's account relationship.", + "operationId": "getDebitCardAccountRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard whose related bankAccount identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "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.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "Successfully returns the found bankAccount identity, or `null` if it was not found.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + }, + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/bankAccountIdentifierResponseDocument" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The debitCard does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + }, + "head": { + "tags": [ + "debitCards" + ], + "summary": "Retrieves the related bankAccount identity of an individual debitCard's account 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": "headDebitCardAccountRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard whose related bankAccount identity to retrieve.", + "required": true, + "schema": { + "type": "string" + } + }, + { + "name": "query", + "in": "query", + "description": "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.", + "schema": { + "type": "object", + "additionalProperties": { + "type": "string", + "nullable": true + }, + "example": "" + } + }, + { + "name": "If-None-Match", + "in": "header", + "description": "A list of ETags, resulting in HTTP status 304 without a body, if one of them matches the current fingerprint.", + "schema": { + "type": "string" + } + } + ], + "responses": { + "200": { + "description": "The operation completed successfully.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + }, + "Content-Length": { + "description": "Size of the HTTP response body, in bytes.", + "required": true, + "schema": { + "type": "integer", + "format": "int64" + } + } + } + }, + "304": { + "description": "The fingerprint of the HTTP response matches one of the ETags from the incoming If-None-Match header.", + "headers": { + "ETag": { + "description": "A fingerprint of the HTTP response, which can be used in an If-None-Match header to only fetch changes.", + "required": true, + "schema": { + "type": "string" + } + } + } + }, + "400": { + "description": "The query string is invalid." + }, + "404": { + "description": "The debitCard does not exist." + } + } + }, + "patch": { + "tags": [ + "debitCards" + ], + "summary": "Assigns an existing bankAccount to the account relationship of an individual debitCard.", + "operationId": "patchDebitCardAccountRelationship", + "parameters": [ + { + "name": "id", + "in": "path", + "description": "The identifier of the debitCard whose account relationship to assign.", + "required": true, + "schema": { + "type": "string" + } + } + ], + "requestBody": { + "description": "The identity of the bankAccount to assign to the account relationship.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneBankAccountInRequest" + } + ] + } + } + }, + "required": true + }, + "responses": { + "204": { + "description": "The account relationship was successfully updated, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "The debitCard or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + }, + "/operations": { + "post": { + "tags": [ + "operations" + ], + "summary": "Performs multiple mutations in a linear and atomic manner.", + "operationId": "postOperations", + "requestBody": { + "description": "An array of mutation operations. For syntax, see the [Atomic Operations documentation](https://jsonapi.org/ext/atomic/).", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "allOf": [ + { + "$ref": "#/components/schemas/operationsRequestDocument" + } + ] + } + } + }, + "required": true + }, + "responses": { + "200": { + "description": "All operations were successfully applied, which resulted in additional changes.", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/operationsResponseDocument" + } + } + } + }, + "204": { + "description": "All operations were successfully applied, which did not result in additional changes." + }, + "400": { + "description": "The request body is missing or malformed.", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "403": { + "description": "An operation is not accessible or a client-generated ID is used.", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "404": { + "description": "A resource or a related resource does not exist.", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "409": { + "description": "The request body contains conflicting information or another resource with the same ID already exists.", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + }, + "422": { + "description": "Validation of the request body failed.", + "content": { + "application/vnd.api+json; ext=atomic; ext=openapi": { + "schema": { + "$ref": "#/components/schemas/errorResponseDocument" + } + } + } + } + } + } + } + }, + "components": { + "schemas": { + "addOperationCode": { + "enum": [ + "add" + ], + "type": "string" + }, + "addToBankAccountCardsRelationshipOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op", + "ref" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/addOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountCardsRelationshipIdentifier" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/debitCardIdentifierInRequest" + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "atomicOperation": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "type": "string" + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "addBankAccount": "#/components/schemas/createBankAccountOperation", + "addDebitCard": "#/components/schemas/createDebitCardOperation", + "addToBankAccountCards": "#/components/schemas/addToBankAccountCardsRelationshipOperation", + "removeBankAccount": "#/components/schemas/deleteBankAccountOperation", + "removeDebitCard": "#/components/schemas/deleteDebitCardOperation", + "removeFromBankAccountCards": "#/components/schemas/removeFromBankAccountCardsRelationshipOperation", + "updateBankAccount": "#/components/schemas/updateBankAccountOperation", + "updateBankAccountCards": "#/components/schemas/updateBankAccountCardsRelationshipOperation", + "updateDebitCard": "#/components/schemas/updateDebitCardOperation", + "updateDebitCardAccount": "#/components/schemas/updateDebitCardAccountRelationshipOperation" + } + }, + "x-abstract": true + }, + "atomicResult": { + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceInResponse" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "attributesInBankAccountResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInResponse" + }, + { + "type": "object", + "properties": { + "iban": { + "type": "string" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "attributesInCreateBankAccountRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInCreateRequest" + }, + { + "required": [ + "iban" + ], + "type": "object", + "properties": { + "iban": { + "type": "string" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "attributesInCreateDebitCardRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInCreateRequest" + }, + { + "required": [ + "ownerName" + ], + "type": "object", + "properties": { + "ownerName": { + "type": "string" + }, + "pinCode": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "attributesInCreateRequest": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "bankAccounts": "#/components/schemas/attributesInCreateBankAccountRequest", + "debitCards": "#/components/schemas/attributesInCreateDebitCardRequest" + } + }, + "x-abstract": true + }, + "attributesInDebitCardResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInResponse" + }, + { + "type": "object", + "properties": { + "ownerName": { + "type": "string" + }, + "pinCode": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "attributesInResponse": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "bankAccounts": "#/components/schemas/attributesInBankAccountResponse", + "debitCards": "#/components/schemas/attributesInDebitCardResponse" + } + }, + "x-abstract": true + }, + "attributesInUpdateBankAccountRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInUpdateRequest" + }, + { + "type": "object", + "properties": { + "iban": { + "type": "string" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "attributesInUpdateDebitCardRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInUpdateRequest" + }, + { + "type": "object", + "properties": { + "ownerName": { + "type": "string" + }, + "pinCode": { + "type": "integer", + "format": "int32" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "attributesInUpdateRequest": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "bankAccounts": "#/components/schemas/attributesInUpdateBankAccountRequest", + "debitCards": "#/components/schemas/attributesInUpdateDebitCardRequest" + } + }, + "x-abstract": true + }, + "bankAccountCardsRelationshipIdentifier": { + "required": [ + "relationship", + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountResourceType" + } + ] + }, + "id": { + "type": "string" + }, + "lid": { + "minLength": 1, + "type": "string" + }, + "relationship": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountCardsRelationshipName" + } + ] + } + }, + "additionalProperties": false + }, + "bankAccountCardsRelationshipName": { + "enum": [ + "cards" + ], + "type": "string" + }, + "bankAccountCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceCollectionTopLevelLinks" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInBankAccountResponse" + } + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/resourceInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "bankAccountIdentifierInRequest": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/identifierInRequest" + }, + { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "lid": { + "minLength": 1, + "type": "string" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "bankAccountIdentifierInResponse": { + "required": [ + "id", + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountResourceType" + } + ] + }, + "id": { + "type": "string" + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "bankAccountIdentifierResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceIdentifierTopLevelLinks" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountIdentifierInResponse" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "bankAccountResourceType": { + "enum": [ + "bankAccounts" + ], + "type": "string" + }, + "createBankAccountOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/addOperationCode" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInCreateBankAccountRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "createBankAccountRequestDocument": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInCreateBankAccountRequest" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "createDebitCardOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/addOperationCode" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInCreateDebitCardRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "createDebitCardRequestDocument": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInCreateDebitCardRequest" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "dataInBankAccountResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceInResponse" + }, + { + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInBankAccountResponse" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInBankAccountResponse" + } + ] + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceLinks" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "dataInCreateBankAccountRequest": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/resourceInCreateRequest" + }, + { + "type": "object", + "properties": { + "lid": { + "minLength": 1, + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInCreateBankAccountRequest" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInCreateBankAccountRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "dataInCreateDebitCardRequest": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/resourceInCreateRequest" + }, + { + "type": "object", + "properties": { + "lid": { + "minLength": 1, + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInCreateDebitCardRequest" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInCreateDebitCardRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "dataInDebitCardResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceInResponse" + }, + { + "required": [ + "id" + ], + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInDebitCardResponse" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInDebitCardResponse" + } + ] + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceLinks" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "dataInUpdateBankAccountRequest": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/resourceInUpdateRequest" + }, + { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "lid": { + "minLength": 1, + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInUpdateBankAccountRequest" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInUpdateBankAccountRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "dataInUpdateDebitCardRequest": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/resourceInUpdateRequest" + }, + { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "lid": { + "minLength": 1, + "type": "string" + }, + "attributes": { + "allOf": [ + { + "$ref": "#/components/schemas/attributesInUpdateDebitCardRequest" + } + ] + }, + "relationships": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInUpdateDebitCardRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "debitCardAccountRelationshipIdentifier": { + "required": [ + "relationship", + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/debitCardResourceType" + } + ] + }, + "id": { + "type": "string" + }, + "lid": { + "minLength": 1, + "type": "string" + }, + "relationship": { + "allOf": [ + { + "$ref": "#/components/schemas/debitCardAccountRelationshipName" + } + ] + } + }, + "additionalProperties": false + }, + "debitCardAccountRelationshipName": { + "enum": [ + "account" + ], + "type": "string" + }, + "debitCardCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceCollectionTopLevelLinks" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/dataInDebitCardResponse" + } + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/resourceInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "debitCardIdentifierCollectionResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceIdentifierCollectionTopLevelLinks" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/debitCardIdentifierInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "debitCardIdentifierInRequest": { + "type": "object", + "allOf": [ + { + "$ref": "#/components/schemas/identifierInRequest" + }, + { + "type": "object", + "properties": { + "id": { + "type": "string" + }, + "lid": { + "minLength": 1, + "type": "string" + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "debitCardIdentifierInResponse": { + "required": [ + "id", + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/debitCardResourceType" + } + ] + }, + "id": { + "type": "string" + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "debitCardResourceType": { + "enum": [ + "debitCards" + ], + "type": "string" + }, + "deleteBankAccountOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "op", + "ref" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/removeOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountIdentifierInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "deleteDebitCardOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "op", + "ref" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/removeOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/debitCardIdentifierInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "errorLinks": { + "type": "object", + "properties": { + "about": { + "type": "string", + "nullable": true + }, + "type": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "errorObject": { + "type": "object", + "properties": { + "id": { + "type": "string", + "nullable": true + }, + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/errorLinks" + } + ], + "nullable": true + }, + "status": { + "type": "string" + }, + "code": { + "type": "string", + "nullable": true + }, + "title": { + "type": "string", + "nullable": true + }, + "detail": { + "type": "string", + "nullable": true + }, + "source": { + "allOf": [ + { + "$ref": "#/components/schemas/errorSource" + } + ], + "nullable": true + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "errorResponseDocument": { + "required": [ + "errors", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/errorTopLevelLinks" + } + ] + }, + "errors": { + "type": "array", + "items": { + "$ref": "#/components/schemas/errorObject" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "errorSource": { + "type": "object", + "properties": { + "pointer": { + "type": "string", + "nullable": true + }, + "parameter": { + "type": "string", + "nullable": true + }, + "header": { + "type": "string", + "nullable": true + } + }, + "additionalProperties": false + }, + "errorTopLevelLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + }, + "describedby": { + "type": "string" + } + }, + "additionalProperties": false + }, + "identifierInRequest": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "type", + "mapping": { + "bankAccounts": "#/components/schemas/bankAccountIdentifierInRequest", + "debitCards": "#/components/schemas/debitCardIdentifierInRequest" + } + }, + "x-abstract": true + }, + "meta": { + "type": "object", + "additionalProperties": { + "nullable": true + } + }, + "operationsRequestDocument": { + "required": [ + "atomic:operations" + ], + "type": "object", + "properties": { + "atomic:operations": { + "minItems": 1, + "type": "array", + "items": { + "$ref": "#/components/schemas/atomicOperation" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "operationsResponseDocument": { + "required": [ + "atomic:results", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceTopLevelLinks" + } + ] + }, + "atomic:results": { + "minItems": 1, + "type": "array", + "items": { + "$ref": "#/components/schemas/atomicResult" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "primaryBankAccountResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceTopLevelLinks" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInBankAccountResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/resourceInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "primaryDebitCardResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceTopLevelLinks" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInDebitCardResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/resourceInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "relationshipLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + }, + "related": { + "type": "string" + } + }, + "additionalProperties": false + }, + "relationshipsInBankAccountResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInResponse" + }, + { + "type": "object", + "properties": { + "cards": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDebitCardInResponse" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "relationshipsInCreateBankAccountRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInCreateRequest" + }, + { + "type": "object", + "properties": { + "cards": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDebitCardInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "relationshipsInCreateDebitCardRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInCreateRequest" + }, + { + "required": [ + "account" + ], + "type": "object", + "properties": { + "account": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneBankAccountInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "relationshipsInCreateRequest": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "bankAccounts": "#/components/schemas/relationshipsInCreateBankAccountRequest", + "debitCards": "#/components/schemas/relationshipsInCreateDebitCardRequest" + } + }, + "x-abstract": true + }, + "relationshipsInDebitCardResponse": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInResponse" + }, + { + "type": "object", + "properties": { + "account": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneBankAccountInResponse" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "relationshipsInResponse": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "bankAccounts": "#/components/schemas/relationshipsInBankAccountResponse", + "debitCards": "#/components/schemas/relationshipsInDebitCardResponse" + } + }, + "x-abstract": true + }, + "relationshipsInUpdateBankAccountRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInUpdateRequest" + }, + { + "type": "object", + "properties": { + "cards": { + "allOf": [ + { + "$ref": "#/components/schemas/toManyDebitCardInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "relationshipsInUpdateDebitCardRequest": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipsInUpdateRequest" + }, + { + "type": "object", + "properties": { + "account": { + "allOf": [ + { + "$ref": "#/components/schemas/toOneBankAccountInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "relationshipsInUpdateRequest": { + "required": [ + "openapi:discriminator" + ], + "type": "object", + "properties": { + "openapi:discriminator": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "openapi:discriminator", + "mapping": { + "bankAccounts": "#/components/schemas/relationshipsInUpdateBankAccountRequest", + "debitCards": "#/components/schemas/relationshipsInUpdateDebitCardRequest" + } + }, + "x-abstract": true + }, + "removeFromBankAccountCardsRelationshipOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op", + "ref" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/removeOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountCardsRelationshipIdentifier" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/debitCardIdentifierInRequest" + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "removeOperationCode": { + "enum": [ + "remove" + ], + "type": "string" + }, + "resourceCollectionTopLevelLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + }, + "describedby": { + "type": "string" + }, + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "prev": { + "type": "string" + }, + "next": { + "type": "string" + } + }, + "additionalProperties": false + }, + "resourceIdentifierCollectionTopLevelLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + }, + "related": { + "type": "string" + }, + "describedby": { + "type": "string" + }, + "first": { + "type": "string" + }, + "last": { + "type": "string" + }, + "prev": { + "type": "string" + }, + "next": { + "type": "string" + } + }, + "additionalProperties": false + }, + "resourceIdentifierTopLevelLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + }, + "related": { + "type": "string" + }, + "describedby": { + "type": "string" + } + }, + "additionalProperties": false + }, + "resourceInCreateRequest": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "type", + "mapping": { + "bankAccounts": "#/components/schemas/dataInCreateBankAccountRequest", + "debitCards": "#/components/schemas/dataInCreateDebitCardRequest" + } + }, + "x-abstract": true + }, + "resourceInResponse": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "type", + "mapping": { + "bankAccounts": "#/components/schemas/dataInBankAccountResponse", + "debitCards": "#/components/schemas/dataInDebitCardResponse" + } + }, + "x-abstract": true + }, + "resourceInUpdateRequest": { + "required": [ + "type" + ], + "type": "object", + "properties": { + "type": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceType" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false, + "discriminator": { + "propertyName": "type", + "mapping": { + "bankAccounts": "#/components/schemas/dataInUpdateBankAccountRequest", + "debitCards": "#/components/schemas/dataInUpdateDebitCardRequest" + } + }, + "x-abstract": true + }, + "resourceLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + } + }, + "additionalProperties": false + }, + "resourceTopLevelLinks": { + "type": "object", + "properties": { + "self": { + "type": "string" + }, + "describedby": { + "type": "string" + } + }, + "additionalProperties": false + }, + "resourceType": { + "enum": [ + "bankAccounts", + "debitCards" + ], + "type": "string" + }, + "secondaryBankAccountResponseDocument": { + "required": [ + "data", + "links" + ], + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/resourceTopLevelLinks" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInBankAccountResponse" + } + ] + }, + "included": { + "type": "array", + "items": { + "$ref": "#/components/schemas/resourceInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "toManyDebitCardInRequest": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/debitCardIdentifierInRequest" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "toManyDebitCardInResponse": { + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipLinks" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/debitCardIdentifierInResponse" + } + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "toOneBankAccountInRequest": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountIdentifierInRequest" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "toOneBankAccountInResponse": { + "type": "object", + "properties": { + "links": { + "allOf": [ + { + "$ref": "#/components/schemas/relationshipLinks" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountIdentifierInResponse" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "updateBankAccountCardsRelationshipOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op", + "ref" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/updateOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountCardsRelationshipIdentifier" + } + ] + }, + "data": { + "type": "array", + "items": { + "$ref": "#/components/schemas/debitCardIdentifierInRequest" + } + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "updateBankAccountOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/updateOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountIdentifierInRequest" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInUpdateBankAccountRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "updateBankAccountRequestDocument": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInUpdateBankAccountRequest" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "updateDebitCardAccountRelationshipOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op", + "ref" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/updateOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/debitCardAccountRelationshipIdentifier" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/bankAccountIdentifierInRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "updateDebitCardOperation": { + "allOf": [ + { + "$ref": "#/components/schemas/atomicOperation" + }, + { + "required": [ + "data", + "op" + ], + "type": "object", + "properties": { + "op": { + "allOf": [ + { + "$ref": "#/components/schemas/updateOperationCode" + } + ] + }, + "ref": { + "allOf": [ + { + "$ref": "#/components/schemas/debitCardIdentifierInRequest" + } + ] + }, + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInUpdateDebitCardRequest" + } + ] + } + }, + "additionalProperties": false + } + ], + "additionalProperties": false + }, + "updateDebitCardRequestDocument": { + "required": [ + "data" + ], + "type": "object", + "properties": { + "data": { + "allOf": [ + { + "$ref": "#/components/schemas/dataInUpdateDebitCardRequest" + } + ] + }, + "meta": { + "allOf": [ + { + "$ref": "#/components/schemas/meta" + } + ] + } + }, + "additionalProperties": false + }, + "updateOperationCode": { + "enum": [ + "update" + ], + "type": "string" + } + } + } +} \ No newline at end of file diff --git a/test/OpenApiTests/IdObfuscation/HexadecimalCodec.cs b/test/OpenApiTests/IdObfuscation/HexadecimalCodec.cs new file mode 100644 index 0000000000..d5436297a8 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/HexadecimalCodec.cs @@ -0,0 +1,76 @@ +using System.Globalization; +using System.Net; +using System.Text; +using JsonApiDotNetCore.Errors; +using JsonApiDotNetCore.Serialization.Objects; + +namespace OpenApiTests.IdObfuscation; + +public sealed class HexadecimalCodec +{ + // This implementation is deliberately simple for demonstration purposes. + // Consider using something more robust, such as https://github.com/sqids/sqids-dotnet. + public static HexadecimalCodec Instance { get; } = new(); + + private HexadecimalCodec() + { + } + + public long Decode(string? value) + { + if (value == null) + { + return 0; + } + + if (!value.StartsWith('x')) + { + throw new JsonApiException(new ErrorObject(HttpStatusCode.BadRequest) + { + Title = "Invalid ID value.", + Detail = $"The value '{value}' is not a valid hexadecimal value." + }); + } + + string stringValue = FromHexString(value[1..]); + return long.Parse(stringValue, CultureInfo.InvariantCulture); + } + + private static string FromHexString(string hexString) + { + var bytes = new List(hexString.Length / 2); + + for (int index = 0; index < hexString.Length; index += 2) + { + string hexChar = hexString.Substring(index, 2); + byte bt = byte.Parse(hexChar, NumberStyles.HexNumber, CultureInfo.InvariantCulture); + bytes.Add(bt); + } + + char[] chars = Encoding.ASCII.GetChars([.. bytes]); + return new string(chars); + } + + public string? Encode(long value) + { + if (value == 0) + { + return null; + } + + string stringValue = value.ToString(CultureInfo.InvariantCulture); + return $"x{ToHexString(stringValue)}"; + } + + private static string ToHexString(string value) + { + var builder = new StringBuilder(); + + foreach (byte bt in Encoding.ASCII.GetBytes(value)) + { + builder.Append(bt.ToString("X2", CultureInfo.InvariantCulture)); + } + + return builder.ToString(); + } +} diff --git a/test/OpenApiTests/IdObfuscation/IdObfuscationTests.cs b/test/OpenApiTests/IdObfuscation/IdObfuscationTests.cs new file mode 100644 index 0000000000..f37eed8cf7 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/IdObfuscationTests.cs @@ -0,0 +1,96 @@ +using System.Text.Json; +using FluentAssertions; +using TestBuildingBlocks; +using Xunit; +using Xunit.Abstractions; + +namespace OpenApiTests.IdObfuscation; + +public sealed class IdObfuscationTests : IClassFixture> +{ + private readonly OpenApiTestContext _testContext; + + public IdObfuscationTests(OpenApiTestContext testContext, ITestOutputHelper testOutputHelper) + { + _testContext = testContext; + + testContext.UseController(); + testContext.UseController(); + testContext.UseController(); + + testContext.SetTestOutputHelper(testOutputHelper); + testContext.SwaggerDocumentOutputDirectory = $"{GetType().Namespace!.Replace('.', '/')}/GeneratedSwagger"; + } + + [Theory] + [InlineData("/bankAccounts/{id}.get")] + [InlineData("/bankAccounts/{id}.head")] + [InlineData("/bankAccounts/{id}.patch")] + [InlineData("/bankAccounts/{id}.delete")] + [InlineData("/bankAccounts/{id}/cards.get")] + [InlineData("/bankAccounts/{id}/cards.head")] + [InlineData("/bankAccounts/{id}/relationships/cards.get")] + [InlineData("/bankAccounts/{id}/relationships/cards.head")] + [InlineData("/bankAccounts/{id}/relationships/cards.post")] + [InlineData("/bankAccounts/{id}/relationships/cards.patch")] + [InlineData("/bankAccounts/{id}/relationships/cards.delete")] + [InlineData("/debitCards/{id}.get")] + [InlineData("/debitCards/{id}.head")] + [InlineData("/debitCards/{id}.patch")] + [InlineData("/debitCards/{id}.delete")] + [InlineData("/debitCards/{id}/account.get")] + [InlineData("/debitCards/{id}/account.head")] + [InlineData("/debitCards/{id}/relationships/account.get")] + [InlineData("/debitCards/{id}/relationships/account.head")] + [InlineData("/debitCards/{id}/relationships/account.patch")] + public async Task Hides_underlying_ID_type_in_path_parameter(string endpointPath) + { + // Act + JsonElement document = await _testContext.GetSwaggerDocumentAsync(); + + // Assert + document.Should().ContainPath($"paths.{endpointPath}.parameters").With(parametersElement => + { + parametersElement.EnumerateArray().Should().ContainSingle(parameterElement => parameterElement.GetProperty("name").ValueEquals("id")).Subject + .With(parameterElement => + { + JsonElement schemaElement = parameterElement.Should().ContainPath("schema"); + + schemaElement.ToString().Should().BeJson(""" + { + "type": "string" + } + """); + }); + }); + } + + [Theory] + [InlineData("bankAccountCardsRelationshipIdentifier", false)] + [InlineData("bankAccountIdentifierInRequest", true)] + [InlineData("bankAccountIdentifierInResponse", false)] + [InlineData("dataInBankAccountResponse", true)] + [InlineData("dataInDebitCardResponse", true)] + [InlineData("dataInUpdateBankAccountRequest", true)] + [InlineData("dataInUpdateDebitCardRequest", true)] + [InlineData("debitCardAccountRelationshipIdentifier", false)] + [InlineData("debitCardIdentifierInRequest", true)] + [InlineData("debitCardIdentifierInResponse", false)] + public async Task Hides_underlying_ID_type_in_component_schema(string schemaId, bool isWrapped) + { + // Act + JsonElement document = await _testContext.GetSwaggerDocumentAsync(); + + // Assert + string path = isWrapped ? $"components.schemas.{schemaId}.allOf[1].properties.id" : $"components.schemas.{schemaId}.properties.id"; + + document.Should().ContainPath(path).With(propertiesElement => + { + propertiesElement.ToString().Should().BeJson(""" + { + "type": "string" + } + """); + }); + } +} diff --git a/test/OpenApiTests/IdObfuscation/ObfuscatedIdentifiable.cs b/test/OpenApiTests/IdObfuscation/ObfuscatedIdentifiable.cs new file mode 100644 index 0000000000..00ef4e20ee --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/ObfuscatedIdentifiable.cs @@ -0,0 +1,18 @@ +using JsonApiDotNetCore.OpenApi.Swashbuckle.Annotations; +using JsonApiDotNetCore.Resources; + +namespace OpenApiTests.IdObfuscation; + +[HideResourceIdTypeInOpenApi] +public abstract class ObfuscatedIdentifiable : Identifiable +{ + protected override string? GetStringId(long value) + { + return value == 0 ? null : HexadecimalCodec.Instance.Encode(value); + } + + protected override long GetTypedId(string? value) + { + return value == null ? 0 : HexadecimalCodec.Instance.Decode(value); + } +} diff --git a/test/OpenApiTests/IdObfuscation/ObfuscatedIdentifiableController.cs b/test/OpenApiTests/IdObfuscation/ObfuscatedIdentifiableController.cs new file mode 100644 index 0000000000..ec7c1d78a0 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/ObfuscatedIdentifiableController.cs @@ -0,0 +1,95 @@ +using System.ComponentModel.DataAnnotations; +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Resources; +using JsonApiDotNetCore.Services; +using Microsoft.AspNetCore.Mvc; +using Microsoft.Extensions.Logging; + +#pragma warning disable format + +namespace OpenApiTests.IdObfuscation; + +public abstract class ObfuscatedIdentifiableController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IResourceService resourceService) + : BaseJsonApiController(options, resourceGraph, loggerFactory, resourceService) + where TResource : class, IIdentifiable +{ + [HttpGet] + [HttpHead] + public override Task GetAsync(CancellationToken cancellationToken) + { + return base.GetAsync(cancellationToken); + } + + [HttpGet("{id}")] + [HttpHead("{id}")] + public Task GetAsync([Required] string id, CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.GetAsync(idValue, cancellationToken); + } + + [HttpGet("{id}/{relationshipName}")] + [HttpHead("{id}/{relationshipName}")] + public Task GetSecondaryAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, + CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.GetSecondaryAsync(idValue, relationshipName, cancellationToken); + } + + [HttpGet("{id}/relationships/{relationshipName}")] + [HttpHead("{id}/relationships/{relationshipName}")] + public Task GetRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, + CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.GetRelationshipAsync(idValue, relationshipName, cancellationToken); + } + + [HttpPost] + public override Task PostAsync([FromBody] [Required] TResource resource, CancellationToken cancellationToken) + { + return base.PostAsync(resource, cancellationToken); + } + + [HttpPost("{id}/relationships/{relationshipName}")] + public Task PostRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, + [FromBody] [Required] ISet rightResourceIds, CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.PostRelationshipAsync(idValue, relationshipName, rightResourceIds, cancellationToken); + } + + [HttpPatch("{id}")] + public Task PatchAsync([Required] string id, [FromBody] [Required] TResource resource, CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.PatchAsync(idValue, resource, cancellationToken); + } + + [HttpPatch("{id}/relationships/{relationshipName}")] + // Parameter `[Required] object? rightValue` makes Swashbuckle generate the OpenAPI request body as required. We don't actually validate ModelState, so it doesn't hurt. + public Task PatchRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, + [FromBody] [Required] object? rightValue, CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.PatchRelationshipAsync(idValue, relationshipName, rightValue, cancellationToken); + } + + [HttpDelete("{id}")] + public Task DeleteAsync([Required] string id, CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.DeleteAsync(idValue, cancellationToken); + } + + [HttpDelete("{id}/relationships/{relationshipName}")] + public Task DeleteRelationshipAsync([Required] string id, [Required] [PreserveEmptyString] string relationshipName, + [FromBody] [Required] ISet rightResourceIds, CancellationToken cancellationToken) + { + long idValue = HexadecimalCodec.Instance.Decode(id); + return base.DeleteRelationshipAsync(idValue, relationshipName, rightResourceIds, cancellationToken); + } +} diff --git a/test/OpenApiTests/IdObfuscation/ObfuscationDbContext.cs b/test/OpenApiTests/IdObfuscation/ObfuscationDbContext.cs new file mode 100644 index 0000000000..2bf30ba912 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/ObfuscationDbContext.cs @@ -0,0 +1,13 @@ +using JetBrains.Annotations; +using Microsoft.EntityFrameworkCore; +using TestBuildingBlocks; + +namespace OpenApiTests.IdObfuscation; + +[UsedImplicitly(ImplicitUseTargetFlags.Members)] +public sealed class ObfuscationDbContext(DbContextOptions options) + : TestableDbContext(options) +{ + public DbSet BankAccounts => Set(); + public DbSet DebitCards => Set(); +} diff --git a/test/OpenApiTests/IdObfuscation/ObfuscationFakers.cs b/test/OpenApiTests/IdObfuscation/ObfuscationFakers.cs new file mode 100644 index 0000000000..157a3b7734 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/ObfuscationFakers.cs @@ -0,0 +1,22 @@ +using Bogus; +using TestBuildingBlocks; + +// @formatter:wrap_chained_method_calls chop_if_long +// @formatter:wrap_before_first_method_call true + +namespace OpenApiTests.IdObfuscation; + +public sealed class ObfuscationFakers +{ + private readonly Lazy> _lazyBankAccountFaker = new(() => new Faker() + .MakeDeterministic() + .RuleFor(bankAccount => bankAccount.Iban, faker => faker.Finance.Iban())); + + private readonly Lazy> _lazyDebitCardFaker = new(() => new Faker() + .MakeDeterministic() + .RuleFor(debitCard => debitCard.OwnerName, faker => faker.Name.FullName()) + .RuleFor(debitCard => debitCard.PinCode, faker => (short)faker.Random.Number(1000, 9999))); + + public Faker BankAccount => _lazyBankAccountFaker.Value; + public Faker DebitCard => _lazyDebitCardFaker.Value; +} diff --git a/test/OpenApiTests/IdObfuscation/ObfuscationOperationFilter.cs b/test/OpenApiTests/IdObfuscation/ObfuscationOperationFilter.cs new file mode 100644 index 0000000000..e9e62cdd9b --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/ObfuscationOperationFilter.cs @@ -0,0 +1,13 @@ +using JsonApiDotNetCore.AtomicOperations; +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; + +namespace OpenApiTests.IdObfuscation; + +internal sealed class ObfuscationOperationFilter : DefaultOperationFilter +{ + protected override JsonApiEndpoints? GetJsonApiEndpoints(ResourceType resourceType) + { + return resourceType.ClrType.Name == nameof(ObfuscatedIdentifiable) ? JsonApiEndpoints.None : JsonApiEndpoints.All; + } +} diff --git a/test/OpenApiTests/IdObfuscation/ObfuscationStartup.cs b/test/OpenApiTests/IdObfuscation/ObfuscationStartup.cs new file mode 100644 index 0000000000..2cfc2272c1 --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/ObfuscationStartup.cs @@ -0,0 +1,19 @@ +using JsonApiDotNetCore.AtomicOperations; +using JsonApiDotNetCore.Configuration; +using Microsoft.Extensions.DependencyInjection; + +namespace OpenApiTests.IdObfuscation; + +public sealed class ObfuscationStartup : OpenApiStartup +{ + public override void ConfigureServices(IServiceCollection services) + { + services.AddSingleton(); + base.ConfigureServices(services); + } + + protected override void AddJsonApi(IServiceCollection services) + { + services.AddJsonApi(ConfigureJsonApiOptions, resources: builder => builder.Remove()); + } +} diff --git a/test/OpenApiTests/IdObfuscation/OperationsController.cs b/test/OpenApiTests/IdObfuscation/OperationsController.cs new file mode 100644 index 0000000000..6fc8ca791a --- /dev/null +++ b/test/OpenApiTests/IdObfuscation/OperationsController.cs @@ -0,0 +1,13 @@ +using JsonApiDotNetCore.AtomicOperations; +using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; +using JsonApiDotNetCore.Middleware; +using JsonApiDotNetCore.Resources; +using Microsoft.Extensions.Logging; + +namespace OpenApiTests.IdObfuscation; + +public sealed class OperationsController( + IJsonApiOptions options, IResourceGraph resourceGraph, ILoggerFactory loggerFactory, IOperationsProcessor processor, IJsonApiRequest request, + ITargetedFields targetedFields, IAtomicOperationFilter operationFilter) + : JsonApiOperationsController(options, resourceGraph, loggerFactory, processor, request, targetedFields, operationFilter);