From 71a72fa1429cb5f86e1521e9bb595cfe42475e23 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Sun, 14 Jan 2024 12:53:07 +0100 Subject: [PATCH 1/4] Fixed: Force the "id" parameter type to be string on JSON:API controller action methods --- docs/usage/openapi-client.md | 2 +- .../Properties/launchSettings.json | 4 +- .../OpenAPIs/swagger.json | 150 ++++++------------ .../JsonApiDotNetCoreExampleClient/Program.cs | 2 +- .../JsonApiSchemaGenerator.cs | 16 ++ .../CamelCase/swagger.g.json | 63 +++----- .../KebabCase/swagger.g.json | 63 +++----- .../PascalCase/swagger.g.json | 63 +++----- .../UpdateResourceTests.cs | 10 +- .../ModelStateValidationOff/swagger.g.json | 84 ++++------ .../UpdateResourceTests.cs | 10 +- .../ModelStateValidationOn/swagger.g.json | 84 ++++------ .../UpdateResourceTests.cs | 10 +- .../ModelStateValidationOff/swagger.g.json | 114 +++++-------- .../UpdateResourceTests.cs | 10 +- .../ModelStateValidationOn/swagger.g.json | 114 +++++-------- .../QueryStrings/FilterTests.cs | 6 +- .../QueryStrings/PaginationTests.cs | 8 +- .../QueryStrings/SortTests.cs | 6 +- .../QueryStrings/SparseFieldSetTests.cs | 8 +- .../QueryStrings/swagger.g.json | 48 ++---- 21 files changed, 315 insertions(+), 560 deletions(-) diff --git a/docs/usage/openapi-client.md b/docs/usage/openapi-client.md index d21378826c..55d5bcb178 100644 --- a/docs/usage/openapi-client.md +++ b/docs/usage/openapi-client.md @@ -94,7 +94,7 @@ The next steps describe how to generate a JSON:API client library and use our pa person => person.FirstName)) { // Workaround for https://github.com/RicoSuter/NSwag/issues/2499. - await TranslateAsync(async () => await apiClient.PatchPersonAsync(1, null, patchRequest)); + await TranslateAsync(async () => await apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest)); // The sent request looks like this: // { diff --git a/src/Examples/JsonApiDotNetCoreExample/Properties/launchSettings.json b/src/Examples/JsonApiDotNetCoreExample/Properties/launchSettings.json index 54646922e1..82b89e1843 100644 --- a/src/Examples/JsonApiDotNetCoreExample/Properties/launchSettings.json +++ b/src/Examples/JsonApiDotNetCoreExample/Properties/launchSettings.json @@ -12,7 +12,7 @@ "IIS Express": { "commandName": "IISExpress", "launchBrowser": true, - "launchUrl": "api/todoItems?include=owner,assignee,tags&filter=equals(priority,'High')", + "launchUrl": "swagger", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" } @@ -20,7 +20,7 @@ "Kestrel": { "commandName": "Project", "launchBrowser": true, - "launchUrl": "api/todoItems?include=owner,assignee,tags&filter=equals(priority,'High')", + "launchUrl": "swagger", "applicationUrl": "https://localhost:44340;http://localhost:14140", "environmentVariables": { "ASPNETCORE_ENVIRONMENT": "Development" diff --git a/src/Examples/JsonApiDotNetCoreExampleClient/OpenAPIs/swagger.json b/src/Examples/JsonApiDotNetCoreExampleClient/OpenAPIs/swagger.json index fbefa04d0c..e1a8fa39b0 100644 --- a/src/Examples/JsonApiDotNetCoreExampleClient/OpenAPIs/swagger.json +++ b/src/Examples/JsonApiDotNetCoreExampleClient/OpenAPIs/swagger.json @@ -152,8 +152,7 @@ "description": "The identifier of the person to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the person to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the person to update.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the person to delete.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the person whose related todoItems to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the person whose related todoItems to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the person whose related todoItem identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the person whose related todoItem identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the person to add todoItems to.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -585,8 +576,7 @@ "description": "The identifier of the person whose assignedTodoItems relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -632,8 +622,7 @@ "description": "The identifier of the person to remove todoItems from.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -681,8 +670,7 @@ "description": "The identifier of the person whose related todoItems to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -732,8 +720,7 @@ "description": "The identifier of the person whose related todoItems to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the person whose related todoItem identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -828,8 +814,7 @@ "description": "The identifier of the person whose related todoItem identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -871,8 +856,7 @@ "description": "The identifier of the person to add todoItems to.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -918,8 +902,7 @@ "description": "The identifier of the person whose ownedTodoItems relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -965,8 +948,7 @@ "description": "The identifier of the person to remove todoItems from.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -1147,8 +1129,7 @@ "description": "The identifier of the tag to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1198,8 +1179,7 @@ "description": "The identifier of the tag to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1241,8 +1221,7 @@ "description": "The identifier of the tag to update.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1314,8 +1293,7 @@ "description": "The identifier of the tag to delete.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -1343,8 +1321,7 @@ "description": "The identifier of the tag whose related todoItems to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1394,8 +1371,7 @@ "description": "The identifier of the tag whose related todoItems to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1439,8 +1415,7 @@ "description": "The identifier of the tag whose related todoItem identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1490,8 +1465,7 @@ "description": "The identifier of the tag whose related todoItem identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1533,8 +1507,7 @@ "description": "The identifier of the tag to add todoItems to.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -1580,8 +1553,7 @@ "description": "The identifier of the tag whose todoItems relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -1627,8 +1599,7 @@ "description": "The identifier of the tag to remove todoItems from.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -1809,8 +1780,7 @@ "description": "The identifier of the todoItem to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1860,8 +1830,7 @@ "description": "The identifier of the todoItem to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1903,8 +1872,7 @@ "description": "The identifier of the todoItem to update.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -1976,8 +1944,7 @@ "description": "The identifier of the todoItem to delete.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -2005,8 +1972,7 @@ "description": "The identifier of the todoItem whose related person to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2056,8 +2022,7 @@ "description": "The identifier of the todoItem whose related person to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2101,8 +2066,7 @@ "description": "The identifier of the todoItem whose related person identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2152,8 +2116,7 @@ "description": "The identifier of the todoItem whose related person identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2195,8 +2158,7 @@ "description": "The identifier of the todoItem whose assignee relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -2244,8 +2206,7 @@ "description": "The identifier of the todoItem whose related person to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2295,8 +2256,7 @@ "description": "The identifier of the todoItem whose related person to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2340,8 +2300,7 @@ "description": "The identifier of the todoItem whose related person identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2391,8 +2350,7 @@ "description": "The identifier of the todoItem whose related person identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2434,8 +2392,7 @@ "description": "The identifier of the todoItem whose owner relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -2483,8 +2440,7 @@ "description": "The identifier of the todoItem whose related tags to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2534,8 +2490,7 @@ "description": "The identifier of the todoItem whose related tags to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2579,8 +2534,7 @@ "description": "The identifier of the todoItem whose related tag identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2630,8 +2584,7 @@ "description": "The identifier of the todoItem whose related tag identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -2673,8 +2626,7 @@ "description": "The identifier of the todoItem to add tags to.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -2720,8 +2672,7 @@ "description": "The identifier of the todoItem whose tags relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -2767,8 +2718,7 @@ "description": "The identifier of the todoItem to remove tags from.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], diff --git a/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs b/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs index 6f778b120e..b35f5723f2 100644 --- a/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs +++ b/src/Examples/JsonApiDotNetCoreExampleClient/Program.cs @@ -31,7 +31,7 @@ using (apiClient.WithPartialAttributeSerialization(patchRequest, person => person.FirstName)) { // Workaround for https://github.com/RicoSuter/NSwag/issues/2499. - await TranslateAsync(() => apiClient.PatchPersonAsync(1, null, patchRequest)); + await TranslateAsync(() => apiClient.PatchPersonAsync(patchRequest.Data.Id, null, patchRequest)); } Console.WriteLine("Press any key to close."); diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs index 6573d0ebff..0685295732 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs @@ -1,5 +1,6 @@ using System.Reflection; using JsonApiDotNetCore.Configuration; +using JsonApiDotNetCore.Controllers; using JsonApiDotNetCore.OpenApi.JsonApiObjects; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Documents; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; @@ -44,6 +45,11 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator JsonApiPropertyName.Meta ]; + private static readonly OpenApiSchema IdTypeSchema = new() + { + Type = "string" + }; + private readonly ISchemaGenerator _defaultSchemaGenerator; private readonly IJsonApiOptions _options; private readonly ResourceObjectSchemaGenerator _resourceObjectSchemaGenerator; @@ -72,6 +78,11 @@ public OpenApiSchema GenerateSchema(Type modelType, SchemaRepository schemaRepos _schemaRepositoryAccessor.Current = schemaRepository; + if (parameterInfo is { Name: "id" } && IsJsonApiParameter(parameterInfo)) + { + return IdTypeSchema; + } + if (schemaRepository.TryLookupByType(modelType, out OpenApiSchema jsonApiDocumentSchema)) { // For unknown reasons, Swashbuckle chooses to wrap root request bodies, but not response bodies. @@ -101,6 +112,11 @@ public OpenApiSchema GenerateSchema(Type modelType, SchemaRepository schemaRepos return _defaultSchemaGenerator.GenerateSchema(modelType, schemaRepository, memberInfo, parameterInfo, routeInfo); } + private static bool IsJsonApiParameter(ParameterInfo parameter) + { + return parameter.Member.DeclaringType != null && parameter.Member.DeclaringType.IsAssignableTo(typeof(CoreJsonApiController)); + } + private static bool IsJsonApiDocument(Type type) { return type.IsConstructedGenericType && JsonApiDocumentOpenTypes.Contains(type.GetGenericTypeDefinition()); diff --git a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json index 57e4d546ce..351671aefe 100644 --- a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the supermarket to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the supermarket to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the supermarket to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the supermarket to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the supermarket whose related staffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the supermarket whose related staffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the supermarket whose related staffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the supermarket whose related staffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the supermarket whose backupStoreManager relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -587,8 +578,7 @@ "description": "The identifier of the supermarket whose related staffMembers to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -638,8 +628,7 @@ "description": "The identifier of the supermarket whose related staffMembers to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -683,8 +672,7 @@ "description": "The identifier of the supermarket whose related staffMember identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -734,8 +722,7 @@ "description": "The identifier of the supermarket whose related staffMember identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the supermarket to add staffMembers to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -824,8 +810,7 @@ "description": "The identifier of the supermarket whose cashiers relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -871,8 +856,7 @@ "description": "The identifier of the supermarket to remove staffMembers from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -920,8 +904,7 @@ "description": "The identifier of the supermarket whose related staffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -971,8 +954,7 @@ "description": "The identifier of the supermarket whose related staffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the supermarket whose related staffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1067,8 +1048,7 @@ "description": "The identifier of the supermarket whose related staffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1110,8 +1090,7 @@ "description": "The identifier of the supermarket whose storeManager relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json index 97477c6b01..5b329c7072 100644 --- a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the supermarket to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the supermarket to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the supermarket to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the supermarket to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the supermarket whose related staff-member to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the supermarket whose related staff-member to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the supermarket whose related staff-member identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the supermarket whose related staff-member identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the supermarket whose backup-store-manager relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -587,8 +578,7 @@ "description": "The identifier of the supermarket whose related staff-members to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -638,8 +628,7 @@ "description": "The identifier of the supermarket whose related staff-members to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -683,8 +672,7 @@ "description": "The identifier of the supermarket whose related staff-member identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -734,8 +722,7 @@ "description": "The identifier of the supermarket whose related staff-member identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the supermarket to add staff-members to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -824,8 +810,7 @@ "description": "The identifier of the supermarket whose cashiers relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -871,8 +856,7 @@ "description": "The identifier of the supermarket to remove staff-members from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -920,8 +904,7 @@ "description": "The identifier of the supermarket whose related staff-member to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -971,8 +954,7 @@ "description": "The identifier of the supermarket whose related staff-member to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the supermarket whose related staff-member identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1067,8 +1048,7 @@ "description": "The identifier of the supermarket whose related staff-member identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1110,8 +1090,7 @@ "description": "The identifier of the supermarket whose store-manager relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json index 22d5a1b77c..a7dacb6446 100644 --- a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the Supermarket to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the Supermarket to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the Supermarket to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the Supermarket to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the Supermarket whose related StaffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the Supermarket whose related StaffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the Supermarket whose related StaffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the Supermarket whose related StaffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the Supermarket whose BackupStoreManager relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -587,8 +578,7 @@ "description": "The identifier of the Supermarket whose related StaffMembers to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -638,8 +628,7 @@ "description": "The identifier of the Supermarket whose related StaffMembers to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -683,8 +672,7 @@ "description": "The identifier of the Supermarket whose related StaffMember identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -734,8 +722,7 @@ "description": "The identifier of the Supermarket whose related StaffMember identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the Supermarket to add StaffMembers to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -824,8 +810,7 @@ "description": "The identifier of the Supermarket whose Cashiers relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -871,8 +856,7 @@ "description": "The identifier of the Supermarket to remove StaffMembers from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -920,8 +904,7 @@ "description": "The identifier of the Supermarket whose related StaffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -971,8 +954,7 @@ "description": "The identifier of the Supermarket whose related StaffMember to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the Supermarket whose related StaffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1067,8 +1048,7 @@ "description": "The identifier of the Supermarket whose related StaffMember identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1110,8 +1090,7 @@ "description": "The identifier of the Supermarket whose StoreManager relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs index 519af8180c..720a4821c5 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/UpdateResourceTests.cs @@ -37,7 +37,7 @@ public async Task Cannot_omit_Id() var apiClient = new NrtOffMsvOffClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.PatchResourceAsync(Unknown.TypedId.Int32, null, requestDocument); + Func action = async () => await apiClient.PatchResourceAsync(Unknown.StringId.Int32, null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -59,7 +59,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -79,7 +79,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -102,7 +102,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -120,7 +120,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json index 8f40cea0b0..936e34b856 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the resource to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the resource to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -585,8 +576,7 @@ "description": "The identifier of the resource whose requiredToMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -632,8 +622,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -681,8 +670,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -732,8 +720,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -828,8 +814,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -871,8 +856,7 @@ "description": "The identifier of the resource whose requiredToOne relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -920,8 +904,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -971,8 +954,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1067,8 +1048,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1110,8 +1090,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1157,8 +1136,7 @@ "description": "The identifier of the resource whose toMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1204,8 +1182,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1253,8 +1230,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1304,8 +1280,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1349,8 +1324,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1400,8 +1374,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1443,8 +1416,7 @@ "description": "The identifier of the resource whose toOne relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs index 585f212076..9c7689c509 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/UpdateResourceTests.cs @@ -37,7 +37,7 @@ public async Task Cannot_omit_Id() var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.PatchResourceAsync(Unknown.TypedId.Int32, null, requestDocument); + Func action = async () => await apiClient.PatchResourceAsync(Unknown.StringId.Int32, null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -59,7 +59,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -79,7 +79,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -102,7 +102,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -120,7 +120,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOffMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json index 1758ce7985..6ae2dedac5 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the resource to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the resource to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -585,8 +576,7 @@ "description": "The identifier of the resource whose requiredToMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -632,8 +622,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -681,8 +670,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -732,8 +720,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -828,8 +814,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -871,8 +856,7 @@ "description": "The identifier of the resource whose requiredToOne relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -920,8 +904,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -971,8 +954,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1067,8 +1048,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1110,8 +1090,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1157,8 +1136,7 @@ "description": "The identifier of the resource whose toMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1204,8 +1182,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1253,8 +1230,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1304,8 +1280,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1349,8 +1324,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1400,8 +1374,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1443,8 +1416,7 @@ "description": "The identifier of the resource whose toOne relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs index 3385a5f6b8..0e5b532aa2 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/UpdateResourceTests.cs @@ -39,7 +39,7 @@ public async Task Cannot_omit_Id() var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.PatchResourceAsync(Unknown.TypedId.Int32, null, requestDocument); + Func action = async () => await apiClient.PatchResourceAsync(Unknown.StringId.Int32, null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -63,7 +63,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -85,7 +85,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -110,7 +110,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -130,7 +130,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOffClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json index e870fc7560..4507cdcbac 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the resource to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the resource to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the resource whose nonNullableToOne relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -587,8 +578,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -638,8 +628,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -683,8 +672,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -734,8 +722,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the resource whose nullableToOne relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -826,8 +812,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -877,8 +862,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -922,8 +906,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -973,8 +956,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the resource whose requiredNonNullableToOne relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1065,8 +1046,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1116,8 +1096,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1161,8 +1140,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1212,8 +1190,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1255,8 +1232,7 @@ "description": "The identifier of the resource whose requiredNullableToOne relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1304,8 +1280,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1355,8 +1330,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1400,8 +1374,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1451,8 +1424,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1494,8 +1466,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1541,8 +1512,7 @@ "description": "The identifier of the resource whose requiredToMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1588,8 +1558,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1637,8 +1606,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1688,8 +1656,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1733,8 +1700,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1784,8 +1750,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1827,8 +1792,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1874,8 +1838,7 @@ "description": "The identifier of the resource whose toMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1921,8 +1884,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs index 24047fde69..153aadc426 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/UpdateResourceTests.cs @@ -39,7 +39,7 @@ public async Task Cannot_omit_Id() var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - Func action = async () => await apiClient.PatchResourceAsync(Unknown.TypedId.Int32, null, requestDocument); + Func action = async () => await apiClient.PatchResourceAsync(Unknown.StringId.Int32, null, requestDocument); // Assert ExceptionAssertions assertion = await action.Should().ThrowExactlyAsync(); @@ -63,7 +63,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -85,7 +85,7 @@ public async Task Can_omit_attribute(string attributePropertyName, string jsonPr using IDisposable _ = apiClient.WithPartialAttributeSerialization(requestDocument); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); @@ -110,7 +110,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string { Data = new ResourceDataInPatchRequest { - Id = "1", + Id = Unknown.StringId.Int32, Attributes = _fakers.PatchAttributes.Generate(), Relationships = new ResourceRelationshipsInPatchRequest { @@ -130,7 +130,7 @@ public async Task Can_omit_relationship(string relationshipPropertyName, string var apiClient = new NrtOnMsvOnClient(wrapper.HttpClient); // Act - await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(int.Parse(requestDocument.Data.Id), null, requestDocument)); + await ApiResponse.TranslateAsync(() => apiClient.PatchResourceAsync(requestDocument.Data.Id, null, requestDocument)); // Assert JsonElement document = wrapper.GetRequestBodyAsJson(); diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json index 15c8c4bbc7..86fc614766 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the resource to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the resource to update.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the resource to delete.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the resource whose nonNullableToOne relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -587,8 +578,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -638,8 +628,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -683,8 +672,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -734,8 +722,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the resource whose nullableToOne relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -826,8 +812,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -877,8 +862,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -922,8 +906,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -973,8 +956,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1016,8 +998,7 @@ "description": "The identifier of the resource whose requiredNonNullableToOne relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1065,8 +1046,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1116,8 +1096,7 @@ "description": "The identifier of the resource whose related empty to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1161,8 +1140,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1212,8 +1190,7 @@ "description": "The identifier of the resource whose related empty identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1255,8 +1232,7 @@ "description": "The identifier of the resource whose requiredNullableToOne relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1304,8 +1280,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1355,8 +1330,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1400,8 +1374,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1451,8 +1424,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1494,8 +1466,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1541,8 +1512,7 @@ "description": "The identifier of the resource whose requiredToMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1588,8 +1558,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1637,8 +1606,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1688,8 +1656,7 @@ "description": "The identifier of the resource whose related empties to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1733,8 +1700,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1784,8 +1750,7 @@ "description": "The identifier of the resource whose related empty identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } }, { @@ -1827,8 +1792,7 @@ "description": "The identifier of the resource to add empties to.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1874,8 +1838,7 @@ "description": "The identifier of the resource whose toMany relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], @@ -1921,8 +1884,7 @@ "description": "The identifier of the resource to remove empties from.", "required": true, "schema": { - "type": "integer", - "format": "int32" + "type": "string" } } ], diff --git a/test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs b/test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs index f4ea0e477b..fe7aefe747 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs +++ b/test/OpenApiEndToEndTests/QueryStrings/FilterTests.cs @@ -84,7 +84,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.Id, queryString); + NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(1); @@ -120,7 +120,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.Id, queryString); + NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(1); @@ -142,7 +142,7 @@ public async Task Cannot_use_empty_filter() }; // Act - Func action = async () => _ = await apiClient.GetNodeAsync(1, queryString); + Func action = async () => _ = await apiClient.GetNodeAsync(Unknown.StringId.Int64, queryString); // Assert ApiException exception = (await action.Should().ThrowExactlyAsync()).Which; diff --git a/test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs b/test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs index 43d2208e7b..f1e2ac9658 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs +++ b/test/OpenApiEndToEndTests/QueryStrings/PaginationTests.cs @@ -80,7 +80,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.Id, queryString); + NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(2); @@ -114,7 +114,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.Id, queryString); + NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(1); @@ -136,7 +136,7 @@ public async Task Cannot_use_empty_page_size() }; // Act - Func action = async () => _ = await apiClient.GetNodeAsync(1, queryString); + Func action = async () => _ = await apiClient.GetNodeAsync(Unknown.StringId.Int64, queryString); // Assert ApiException exception = (await action.Should().ThrowExactlyAsync()).Which; @@ -158,7 +158,7 @@ public async Task Cannot_use_empty_page_number() }; // Act - Func action = async () => _ = await apiClient.GetNodeAsync(1, queryString); + Func action = async () => _ = await apiClient.GetNodeAsync(Unknown.StringId.Int64, queryString); // Assert ApiException exception = (await action.Should().ThrowExactlyAsync()).Which; diff --git a/test/OpenApiEndToEndTests/QueryStrings/SortTests.cs b/test/OpenApiEndToEndTests/QueryStrings/SortTests.cs index 57380a7c33..e229b7859f 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/SortTests.cs +++ b/test/OpenApiEndToEndTests/QueryStrings/SortTests.cs @@ -81,7 +81,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.Id, queryString); + NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(2); @@ -114,7 +114,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.Id, queryString); + NodeIdentifierCollectionResponseDocument response = await apiClient.GetNodeChildrenRelationshipAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(2); @@ -135,7 +135,7 @@ public async Task Cannot_use_empty_sort() }; // Act - Func action = async () => _ = await apiClient.GetNodeAsync(1, queryString); + Func action = async () => _ = await apiClient.GetNodeAsync(Unknown.StringId.Int64, queryString); // Assert ApiException exception = (await action.Should().ThrowExactlyAsync()).Which; diff --git a/test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs b/test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs index 00d3962eeb..7172465408 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs +++ b/test/OpenApiEndToEndTests/QueryStrings/SparseFieldSetTests.cs @@ -76,7 +76,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodePrimaryResponseDocument response = await apiClient.GetNodeAsync(node.Id, queryString); + NodePrimaryResponseDocument response = await apiClient.GetNodeAsync(node.StringId!, queryString); // Assert response.Data.Id.Should().Be(node.StringId); @@ -109,7 +109,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.Id, queryString); + NodeCollectionResponseDocument response = await apiClient.GetNodeChildrenAsync(node.StringId!, queryString); // Assert response.Data.Should().HaveCount(1); @@ -142,7 +142,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NullableNodeSecondaryResponseDocument response = await apiClient.GetNodeParentAsync(node.Id, queryString); + NullableNodeSecondaryResponseDocument response = await apiClient.GetNodeParentAsync(node.StringId!, queryString); // Assert response.Data.ShouldNotBeNull(); @@ -174,7 +174,7 @@ await _testContext.RunOnDatabaseAsync(async dbContext => }; // Act - NodePrimaryResponseDocument response = await apiClient.GetNodeAsync(node.Id, queryString); + NodePrimaryResponseDocument response = await apiClient.GetNodeAsync(node.StringId!, queryString); // Assert response.Data.Id.Should().Be(node.StringId); diff --git a/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json b/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json index 94c4aab9b8..63ccf048e2 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json +++ b/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json @@ -152,8 +152,7 @@ "description": "The identifier of the node to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -203,8 +202,7 @@ "description": "The identifier of the node to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -246,8 +244,7 @@ "description": "The identifier of the node to update.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -319,8 +316,7 @@ "description": "The identifier of the node to delete.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -348,8 +344,7 @@ "description": "The identifier of the node whose related nodes to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -399,8 +394,7 @@ "description": "The identifier of the node whose related nodes to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -444,8 +438,7 @@ "description": "The identifier of the node whose related node identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -495,8 +488,7 @@ "description": "The identifier of the node whose related node identities to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -538,8 +530,7 @@ "description": "The identifier of the node to add nodes to.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -585,8 +576,7 @@ "description": "The identifier of the node whose children relationship to assign.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -632,8 +622,7 @@ "description": "The identifier of the node to remove nodes from.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], @@ -681,8 +670,7 @@ "description": "The identifier of the node whose related node to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -732,8 +720,7 @@ "description": "The identifier of the node whose related node to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -777,8 +764,7 @@ "description": "The identifier of the node whose related node identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -828,8 +814,7 @@ "description": "The identifier of the node whose related node identity to retrieve.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } }, { @@ -871,8 +856,7 @@ "description": "The identifier of the node whose parent relationship to assign or clear.", "required": true, "schema": { - "type": "integer", - "format": "int64" + "type": "string" } } ], From 2a42a299a70a3a726bfdb3a32a33ef17b11af943 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Thu, 2 Nov 2023 23:20:05 +0100 Subject: [PATCH 2/4] Fixed: no additional properties in resource type --- .../SwaggerComponents/ResourceTypeSchemaGenerator.cs | 3 ++- test/OpenApiClientTests/LegacyClient/swagger.g.json | 12 ++++++++---- .../NamingConventions/CamelCase/swagger.g.json | 6 ++++-- .../NamingConventions/KebabCase/swagger.g.json | 6 ++++-- .../NamingConventions/PascalCase/swagger.g.json | 6 ++++-- .../ModelStateValidationOff/swagger.g.json | 6 ++++-- .../ModelStateValidationOn/swagger.g.json | 6 ++++-- .../ModelStateValidationOff/swagger.g.json | 6 ++++-- .../ModelStateValidationOn/swagger.g.json | 6 ++++-- .../OpenApiEndToEndTests/QueryStrings/swagger.g.json | 3 ++- .../LegacyOpenApiIntegration/swagger.json | 12 ++++++++---- 11 files changed, 48 insertions(+), 24 deletions(-) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs index 20f8a836e5..89f2164a59 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs @@ -41,7 +41,8 @@ public OpenApiSchema Get(Type resourceClrType) Enum = new List { new OpenApiString(resourceType.PublicName) - } + }, + AdditionalPropertiesAllowed = false }; string schemaId = GetSchemaId(resourceType); diff --git a/test/OpenApiClientTests/LegacyClient/swagger.g.json b/test/OpenApiClientTests/LegacyClient/swagger.g.json index e014464a4c..644af8144f 100644 --- a/test/OpenApiClientTests/LegacyClient/swagger.g.json +++ b/test/OpenApiClientTests/LegacyClient/swagger.g.json @@ -3470,7 +3470,8 @@ "enum": [ "airplanes" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "cabin-area": { "enum": [ @@ -3929,7 +3930,8 @@ "enum": [ "flight-attendants" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "flight-attendant-secondary-response-document": { "required": [ @@ -4411,7 +4413,8 @@ "enum": [ "flights" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "jsonapi-object": { "type": "object", @@ -4855,7 +4858,8 @@ "enum": [ "passengers" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "to-many-flight-attendant-in-request": { "required": [ diff --git a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json index 351671aefe..da02747a29 100644 --- a/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/CamelCase/swagger.g.json @@ -1603,7 +1603,8 @@ "enum": [ "staffMembers" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "staffMemberSecondaryResponseDocument": { "required": [ @@ -2004,7 +2005,8 @@ "enum": [ "supermarkets" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "supermarketType": { "enum": [ diff --git a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json index 5b329c7072..f143415719 100644 --- a/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/KebabCase/swagger.g.json @@ -1603,7 +1603,8 @@ "enum": [ "staff-members" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "staff-member-secondary-response-document": { "required": [ @@ -2004,7 +2005,8 @@ "enum": [ "supermarkets" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "supermarket-type": { "enum": [ diff --git a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json index a7dacb6446..436bfe3c39 100644 --- a/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json +++ b/test/OpenApiClientTests/NamingConventions/PascalCase/swagger.g.json @@ -1603,7 +1603,8 @@ "enum": [ "StaffMembers" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "StaffMemberSecondaryResponseDocument": { "required": [ @@ -2004,7 +2005,8 @@ "enum": [ "Supermarkets" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "SupermarketType": { "enum": [ diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json index 936e34b856..20b6d88eea 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOff/swagger.g.json @@ -1574,7 +1574,8 @@ "enum": [ "empties" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "linksInRelationshipObject": { "required": [ @@ -2239,7 +2240,8 @@ "enum": [ "resources" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "toManyEmptyInRequest": { "required": [ diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json index 6ae2dedac5..0d276409e9 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOff/ModelStateValidationOn/swagger.g.json @@ -1605,7 +1605,8 @@ "enum": [ "empties" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "emptySecondaryResponseDocument": { "required": [ @@ -2293,7 +2294,8 @@ "enum": [ "resources" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "toManyEmptyInRequest": { "required": [ diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json index 4507cdcbac..fc50f639a4 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOff/swagger.g.json @@ -2073,7 +2073,8 @@ "enum": [ "empties" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "emptySecondaryResponseDocument": { "required": [ @@ -2834,7 +2835,8 @@ "enum": [ "resources" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "toManyEmptyInRequest": { "required": [ diff --git a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json index 86fc614766..5d4bd9a6c7 100644 --- a/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json +++ b/test/OpenApiClientTests/ResourceFieldValidation/NullableReferenceTypesOn/ModelStateValidationOn/swagger.g.json @@ -2073,7 +2073,8 @@ "enum": [ "empties" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "emptySecondaryResponseDocument": { "required": [ @@ -2828,7 +2829,8 @@ "enum": [ "resources" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "toManyEmptyInRequest": { "required": [ diff --git a/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json b/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json index 63ccf048e2..03457ce2a8 100644 --- a/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json +++ b/test/OpenApiEndToEndTests/QueryStrings/swagger.g.json @@ -1387,7 +1387,8 @@ "enum": [ "nodes" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "nullableNodeIdentifierResponseDocument": { "required": [ diff --git a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json index e014464a4c..644af8144f 100644 --- a/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json +++ b/test/OpenApiTests/LegacyOpenApiIntegration/swagger.json @@ -3470,7 +3470,8 @@ "enum": [ "airplanes" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "cabin-area": { "enum": [ @@ -3929,7 +3930,8 @@ "enum": [ "flight-attendants" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "flight-attendant-secondary-response-document": { "required": [ @@ -4411,7 +4413,8 @@ "enum": [ "flights" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "jsonapi-object": { "type": "object", @@ -4855,7 +4858,8 @@ "enum": [ "passengers" ], - "type": "string" + "type": "string", + "additionalProperties": false }, "to-many-flight-attendant-in-request": { "required": [ From 9ba5ec3efdd99e0b46aa65b08fce2e73332f3e93 Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Thu, 2 Nov 2023 23:25:52 +0100 Subject: [PATCH 3/4] Simplify dependencies: take ResourceType instead of ClrType --- .../ResourceFieldObjectSchemaBuilder.cs | 6 +++--- .../ResourceObjectSchemaGenerator.cs | 5 ++--- .../ResourceTypeSchemaGenerator.cs | 13 ++++--------- 3 files changed, 9 insertions(+), 15 deletions(-) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs index d064c2d5f7..41894a3682 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceFieldObjectSchemaBuilder.cs @@ -1,4 +1,5 @@ using System.Reflection; +using JsonApiDotNetCore.Configuration; using JsonApiDotNetCore.OpenApi.JsonApiMetadata; using JsonApiDotNetCore.OpenApi.JsonApiObjects.Relationships; using JsonApiDotNetCore.OpenApi.JsonApiObjects.ResourceObjects; @@ -171,7 +172,7 @@ private void EnsureResourceIdentifierObjectSchemaExists(RelationshipAttribute re if (!ResourceIdentifierObjectSchemaExists(resourceIdentifierObjectType)) { - GenerateResourceIdentifierObjectSchema(resourceIdentifierObjectType); + GenerateResourceIdentifierObjectSchema(resourceIdentifierObjectType, relationship.RightType); } } @@ -180,7 +181,7 @@ private bool ResourceIdentifierObjectSchemaExists(Type resourceIdentifierObjectT return _schemaRepositoryAccessor.Current.TryLookupByType(resourceIdentifierObjectType, out _); } - private void GenerateResourceIdentifierObjectSchema(Type resourceIdentifierObjectType) + private void GenerateResourceIdentifierObjectSchema(Type resourceIdentifierObjectType, ResourceType resourceType) { OpenApiSchema referenceSchemaForResourceIdentifierObject = _defaultSchemaGenerator.GenerateSchema(resourceIdentifierObjectType, _schemaRepositoryAccessor.Current); @@ -188,7 +189,6 @@ private void GenerateResourceIdentifierObjectSchema(Type resourceIdentifierObjec OpenApiSchema fullSchemaForResourceIdentifierObject = _schemaRepositoryAccessor.Current.Schemas[referenceSchemaForResourceIdentifierObject.Reference.Id]; - Type resourceType = resourceIdentifierObjectType.GetGenericArguments()[0]; fullSchemaForResourceIdentifierObject.Properties[JsonApiPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); } diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs index b0f715cdc7..8d30072aae 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceObjectSchemaGenerator.cs @@ -38,8 +38,7 @@ public ResourceObjectSchemaGenerator(SchemaGenerator defaultSchemaGenerator, IRe _resourceGraph = resourceGraph; _options = options; _schemaRepositoryAccessor = schemaRepositoryAccessor; - - _resourceTypeSchemaGenerator = new ResourceTypeSchemaGenerator(schemaRepositoryAccessor, resourceGraph, options.SerializerOptions.PropertyNamingPolicy); + _resourceTypeSchemaGenerator = new ResourceTypeSchemaGenerator(schemaRepositoryAccessor, options.SerializerOptions.PropertyNamingPolicy); _resourceFieldObjectSchemaBuilderFactory = resourceTypeInfo => new ResourceFieldObjectSchemaBuilder(resourceTypeInfo, schemaRepositoryAccessor, defaultSchemaGenerator, _resourceTypeSchemaGenerator, resourceFieldValidationMetadataProvider); @@ -102,7 +101,7 @@ private void RemoveResourceIdIfPostResourceObject(ResourceTypeInfo resourceTypeI private void SetResourceType(OpenApiSchema fullSchemaForResourceObject, ResourceType resourceType) { - fullSchemaForResourceObject.Properties[JsonApiPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType.ClrType); + fullSchemaForResourceObject.Properties[JsonApiPropertyName.Type] = _resourceTypeSchemaGenerator.Get(resourceType); fullSchemaForResourceObject.Description = _resourceObjectDocumentationReader.GetDocumentationForType(resourceType); } diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs index 89f2164a59..8069fbf898 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/ResourceTypeSchemaGenerator.cs @@ -10,31 +10,26 @@ internal sealed class ResourceTypeSchemaGenerator { private const string ResourceTypeSchemaIdTemplate = "[ResourceName] Resource Type"; private readonly ISchemaRepositoryAccessor _schemaRepositoryAccessor; - private readonly IResourceGraph _resourceGraph; private readonly JsonNamingPolicy? _namingPolicy; private readonly Dictionary _resourceClrTypeSchemaCache = []; - public ResourceTypeSchemaGenerator(ISchemaRepositoryAccessor schemaRepositoryAccessor, IResourceGraph resourceGraph, JsonNamingPolicy? namingPolicy) + public ResourceTypeSchemaGenerator(ISchemaRepositoryAccessor schemaRepositoryAccessor, JsonNamingPolicy? namingPolicy) { ArgumentGuard.NotNull(schemaRepositoryAccessor); - ArgumentGuard.NotNull(resourceGraph); _schemaRepositoryAccessor = schemaRepositoryAccessor; - _resourceGraph = resourceGraph; _namingPolicy = namingPolicy; } - public OpenApiSchema Get(Type resourceClrType) + public OpenApiSchema Get(ResourceType resourceType) { - ArgumentGuard.NotNull(resourceClrType); + ArgumentGuard.NotNull(resourceType); - if (_resourceClrTypeSchemaCache.TryGetValue(resourceClrType, out OpenApiSchema? extendedReferenceSchema)) + if (_resourceClrTypeSchemaCache.TryGetValue(resourceType.ClrType, out OpenApiSchema? extendedReferenceSchema)) { return extendedReferenceSchema; } - ResourceType resourceType = _resourceGraph.GetResourceType(resourceClrType); - var fullSchema = new OpenApiSchema { Type = "string", From b0fa68813b62a85c622ecc12990506c88801846d Mon Sep 17 00:00:00 2001 From: Bart Koelman <10324372+bkoelman@users.noreply.github.com> Date: Thu, 2 Nov 2023 23:31:16 +0100 Subject: [PATCH 4/4] Fixed: removed unused entries that are not top-level documents --- .../SwaggerComponents/JsonApiSchemaGenerator.cs | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs index 0685295732..4715762f8f 100644 --- a/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs +++ b/src/JsonApiDotNetCore.OpenApi/SwaggerComponents/JsonApiSchemaGenerator.cs @@ -22,10 +22,7 @@ internal sealed class JsonApiSchemaGenerator : ISchemaGenerator typeof(ResourcePatchRequestDocument<>), typeof(ResourceIdentifierCollectionResponseDocument<>), typeof(ResourceIdentifierResponseDocument<>), - typeof(NullableResourceIdentifierResponseDocument<>), - typeof(ToManyRelationshipInRequest<>), - typeof(ToOneRelationshipInRequest<>), - typeof(NullableToOneRelationshipInRequest<>) + typeof(NullableResourceIdentifierResponseDocument<>) ]; private static readonly Type[] JsonApiDocumentWithNullableDataOpenTypes =