From 55b3e38bc793c7c4c6754f5847afc27adb832e09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 14:52:12 +0200 Subject: [PATCH 1/7] fix: map numeric scalar unions with a format to the numeric type ASP.NET Core's OpenAPI 3.1 generator emits numeric members as type ["integer"/"number", "string"] with a digit pattern under System.Text.Json's default JsonNumberHandling.AllowReadingFromString. GetPrimitiveType could not match the combined flags and returned null, so such properties degraded to UntypedNode. Prefer the numeric type by stripping the string flag when it is combined with integer or number. Scalar unions without a format keep being generated as composed type wrappers. Fixes #6541 Co-Authored-By: Claude Fable 5 --- CHANGELOG.md | 1 + src/Kiota.Builder/KiotaBuilder.cs | 10 ++- .../Kiota.Builder.Tests/KiotaBuilderTests.cs | 66 +++++++++++++++++++ 3 files changed, 76 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index a24e5cc50e..8325fb11fc 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -16,6 +16,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 ### Changed +- Numeric scalar unions with a format (e.g. `type: ["integer", "string"]` with `format: int32`, as emitted by ASP.NET Core's OpenAPI 3.1 generator under System.Text.Json's default `JsonNumberHandling.AllowReadingFromString`) now map to the numeric type instead of degrading to `UntypedNode`. [#6541](https://github.com/microsoft/kiota/issues/6541) - golang: generated code now always uses LF line endings, so `gofmt` no longer reports formatting differences when generating on Windows. - golang: make sure all generated code adheres to golangs coding standards - Fixed non-deterministic model class descriptions when a component schema is referenced from multiple properties with differing reference-level descriptions. [#7927](https://github.com/microsoft/kiota/issues/7927) diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 1045c042e0..372170096f 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -1297,7 +1297,15 @@ openApiExtension is OpenApiPrimaryErrorMessageExtension primaryErrorMessageExten var typeName = typeNames.Find(static x => x is not null && !typeNamesToSkip.Contains(x.Value)); var format = typeSchema?.Format ?? typeSchema?.Items?.Format; - return (typeName & ~JsonSchemaType.Null, format?.ToLowerInvariant()) switch + var schemaType = typeName & ~JsonSchemaType.Null; + if (schemaType is { } schemaTypeValue && + (schemaTypeValue & JsonSchemaType.String) is JsonSchemaType.String && + (schemaTypeValue & (JsonSchemaType.Integer | JsonSchemaType.Number)) != 0) + // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) + // advertises numeric members as type ["integer"/"number", "string"]. Prefer the numeric type + // over a scalar union that would otherwise not be mappable and fall back to untyped. + schemaType = schemaTypeValue & ~JsonSchemaType.String; + return (schemaType, format?.ToLowerInvariant()) switch { // byte and binary can apply to any type (_, "byte") => new CodeType { Name = "base64", IsExternal = true }, diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 16a52c8fa8..14af896a7f 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -1904,6 +1904,72 @@ public void Object_Arrays_are_supported() Assert.NotNull(unknownProp); Assert.Equal(KiotaBuilder.UntypedNodeName, unknownProp.Type.Name);// left out property is an UntypedNode } + [Theory] + [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, "int32", "integer")] + [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, "int64", "int64")] + [InlineData(JsonSchemaType.Integer | JsonSchemaType.String | JsonSchemaType.Null, "int32", "integer")] + [InlineData(JsonSchemaType.Number | JsonSchemaType.String, "double", "double")] + [InlineData(JsonSchemaType.Number | JsonSchemaType.String, "float", "float")] + [InlineData(JsonSchemaType.Number | JsonSchemaType.String | JsonSchemaType.Null, "double", "double")] + // without a format, the scalar union keeps being generated as a composed type wrapper + [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, null, "forecastGetResponse_temperature")] + [InlineData(JsonSchemaType.Number | JsonSchemaType.String, null, "forecastGetResponse_temperature")] + public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string format, string expectedTypeName) + { + // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) + // advertises numeric members as type ["integer"/"number", "string"] with a digit pattern. + // https://github.com/microsoft/kiota/issues/6541 + var document = new OpenApiDocument + { + Paths = new OpenApiPaths + { + ["forecast"] = new OpenApiPathItem + { + Operations = new() + { + [NetHttpMethod.Get] = new OpenApiOperation + { + Responses = new OpenApiResponses + { + ["200"] = new OpenApiResponse + { + Content = new Dictionary() + { + ["application/json"] = new OpenApiMediaType + { + Schema = new OpenApiSchema + { + Type = JsonSchemaType.Object, + Properties = new Dictionary { + { + "temperature", new OpenApiSchema { + Type = schemaType, + Format = format, + Pattern = "^-?(?:0|[1-9]\\d*)$" + } + } + } + } + } + } + } + } + } + } + }, + }, + }; + document.SetReferenceHostDocument(); + var mockLogger = new CountLogger(); + var builder = new KiotaBuilder(mockLogger, new GenerationConfiguration { ClientClassName = "Graph", ApiRootUrl = "https://localhost" }, _httpClient); + var node = builder.CreateUriSpace(document); + var codeModel = builder.CreateSourceModel(node); + var responseClass = codeModel.FindNamespaceByName("ApiSdk.forecast").FindChildByName("ForecastGetResponse", false); + Assert.NotNull(responseClass); + var temperatureProp = responseClass.FindChildByName("temperature", false); + Assert.NotNull(temperatureProp); + Assert.Equal(expectedTypeName, temperatureProp.Type.Name); + } [Fact] public void TextPlainEndpointsAreSupported() { From 0ee2f8af26f736c51b320e40be6935f05a74b940 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 15:04:52 +0200 Subject: [PATCH 2/7] fix: do not apply fix when format is not present Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@users.noreply.github.com> --- src/Kiota.Builder/KiotaBuilder.cs | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 372170096f..5586b8dcd5 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -1299,6 +1299,7 @@ openApiExtension is OpenApiPrimaryErrorMessageExtension primaryErrorMessageExten var format = typeSchema?.Format ?? typeSchema?.Items?.Format; var schemaType = typeName & ~JsonSchemaType.Null; if (schemaType is { } schemaTypeValue && + !string.IsNullOrEmpty(format) && (schemaTypeValue & JsonSchemaType.String) is JsonSchemaType.String && (schemaTypeValue & (JsonSchemaType.Integer | JsonSchemaType.Number)) != 0) // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) From c94ec186a62365112ccac66d539eb44e8bb4c815 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 15:07:25 +0200 Subject: [PATCH 3/7] fix: set `format` argument as "nullable" --- tests/Kiota.Builder.Tests/KiotaBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 14af896a7f..43fb8ba39b 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -1914,7 +1914,7 @@ public void Object_Arrays_are_supported() // without a format, the scalar union keeps being generated as a composed type wrapper [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, null, "forecastGetResponse_temperature")] [InlineData(JsonSchemaType.Number | JsonSchemaType.String, null, "forecastGetResponse_temperature")] - public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string format, string expectedTypeName) + public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string? format, string expectedTypeName) { // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) // advertises numeric members as type ["integer"/"number", "string"] with a digit pattern. From c02a7baf42f8ea93bf11cd90bce3cbdad206d1e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 15:17:00 +0200 Subject: [PATCH 4/7] fix: align InconsistentTypeFormatPair validator with numeric|string union mapping The validator warned that the string type would be used for integer|string and number|string schemas with a numeric format, which is no longer true now that GetPrimitiveType maps those unions to the numeric type. Co-Authored-By: Claude Fable 5 --- .../Validation/InconsistentTypeFormatPair.cs | 4 ++ .../InconsistentTypeFormatPairTests.cs | 52 +++++++++++++++++++ 2 files changed, 56 insertions(+) diff --git a/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs b/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs index 7249685fcd..31b8085034 100644 --- a/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs +++ b/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs @@ -51,6 +51,10 @@ public InconsistentTypeFormatPair() : base(nameof(InconsistentTypeFormatPair), s if (schema is null || !schema.Type.HasValue || string.IsNullOrEmpty(schema.Format) || KnownAndNotSupportedFormats.knownAndUnsupportedFormats.Contains(schema.Format) || escapedTypes.Contains(schema.Type.Value)) return; var sanitizedType = schema.Type.Value & ~JsonSchemaType.Null; + // mirrors KiotaBuilder.GetPrimitiveType: when a format is present, numeric|string unions map to the numeric type + if ((sanitizedType & JsonSchemaType.String) is JsonSchemaType.String && + (sanitizedType & (JsonSchemaType.Integer | JsonSchemaType.Number)) != 0) + sanitizedType &= ~JsonSchemaType.String; if (!validPairs.TryGetValue(sanitizedType, out var validFormats) || !validFormats.Contains(schema.Format)) context.CreateWarning(nameof(InconsistentTypeFormatPair), $"The format {schema.Format} is not supported by Kiota for the type {sanitizedType} and the string type will be used."); }) diff --git a/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs b/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs index ce4b49df95..c37286f6a9 100644 --- a/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs @@ -102,6 +102,58 @@ public async Task DoesntAddWarningOnNullable() var diagnostic = await GetDiagnosticFromDocumentAsync(documentTxt); Assert.Empty(diagnostic.Warnings); } + [Theory] + [InlineData("[integer, string]", "int32")] + [InlineData("[integer, string, 'null']", "int64")] + [InlineData("[number, string]", "float")] + [InlineData("[number, string, 'null']", "double")] + public async Task DoesntAddAWarningWhenNumericStringUnionWithNumericFormat(string type, string format) + { + var documentTxt = $""" +openapi: 3.1.1 +info: + title: OData Service for namespace microsoft.graph + description: This OData service is located at https://graph.microsoft.com/v1.0 + version: 1.0.1 +paths: + /enumeration: + get: + responses: + '200': + description: some description + content: + application/json: + schema: + type: {type} + format: {format} +"""; + var diagnostic = await GetDiagnosticFromDocumentAsync(documentTxt); + Assert.Empty(diagnostic.Warnings); + } + [Fact] + public async Task AddsAWarningWhenNumericStringUnionWithUnsupportedFormat() + { + var documentTxt = """ +openapi: 3.1.1 +info: + title: OData Service for namespace microsoft.graph + description: This OData service is located at https://graph.microsoft.com/v1.0 + version: 1.0.1 +paths: + /enumeration: + get: + responses: + '200': + description: some description + content: + application/json: + schema: + type: [integer, string] + format: date-time +"""; + var diagnostic = await GetDiagnosticFromDocumentAsync(documentTxt); + Assert.Single(diagnostic.Warnings); + } private static async Task GetDiagnosticFromDocumentAsync(string document) { var rule = new InconsistentTypeFormatPair(); From fbf56326a192c4e5534e40783be4e66fddc3b6e8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 15:17:39 +0200 Subject: [PATCH 5/7] fix: remove nullable annotation outside of a nullable context The test project does not enable nullable reference types, so the string? parameter produced a CS8632 build warning. Co-Authored-By: Claude Fable 5 --- tests/Kiota.Builder.Tests/KiotaBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 43fb8ba39b..14af896a7f 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -1914,7 +1914,7 @@ public void Object_Arrays_are_supported() // without a format, the scalar union keeps being generated as a composed type wrapper [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, null, "forecastGetResponse_temperature")] [InlineData(JsonSchemaType.Number | JsonSchemaType.String, null, "forecastGetResponse_temperature")] - public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string? format, string expectedTypeName) + public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string format, string expectedTypeName) { // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) // advertises numeric members as type ["integer"/"number", "string"] with a digit pattern. From 25b4bf3afdc4d3f64763f54983e10b74a78577e4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 15:19:10 +0200 Subject: [PATCH 6/7] Revert "fix: remove nullable annotation outside of a nullable context" This reverts commit fbf56326a192c4e5534e40783be4e66fddc3b6e8. --- tests/Kiota.Builder.Tests/KiotaBuilderTests.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 14af896a7f..43fb8ba39b 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -1914,7 +1914,7 @@ public void Object_Arrays_are_supported() // without a format, the scalar union keeps being generated as a composed type wrapper [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, null, "forecastGetResponse_temperature")] [InlineData(JsonSchemaType.Number | JsonSchemaType.String, null, "forecastGetResponse_temperature")] - public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string format, string expectedTypeName) + public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string? format, string expectedTypeName) { // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) // advertises numeric members as type ["integer"/"number", "string"] with a digit pattern. From 06578824083791eb9e64bdca16f76f4f3e634802 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Fabien=20Dehopr=C3=A9?= Date: Mon, 27 Jul 2026 20:58:23 +0200 Subject: [PATCH 7/7] fix: only strip the string flag for known numeric formats Gate the numeric|string union special-case on Kiota's supported numeric formats so unions with a non-numeric format (uuid, date-time, ...) keep the previous untyped fallback instead of silently mapping to a numeric type. Also reword the InconsistentTypeFormatPair warning since the fallback is no longer necessarily string. Co-Authored-By: Claude Fable 5 --- src/Kiota.Builder/KiotaBuilder.cs | 8 +++++--- .../Validation/InconsistentTypeFormatPair.cs | 7 ++++--- tests/Kiota.Builder.Tests/KiotaBuilderTests.cs | 4 ++++ .../Validation/InconsistentTypeFormatPairTests.cs | 7 +++++-- 4 files changed, 18 insertions(+), 8 deletions(-) diff --git a/src/Kiota.Builder/KiotaBuilder.cs b/src/Kiota.Builder/KiotaBuilder.cs index 5586b8dcd5..7eeb64e1c7 100644 --- a/src/Kiota.Builder/KiotaBuilder.cs +++ b/src/Kiota.Builder/KiotaBuilder.cs @@ -1284,6 +1284,7 @@ openApiExtension is OpenApiPrimaryErrorMessageExtension primaryErrorMessageExten return prop; } private static readonly HashSet typeNamesToSkip = [JsonSchemaType.Object, JsonSchemaType.Array, JsonSchemaType.Object | JsonSchemaType.Null, JsonSchemaType.Array | JsonSchemaType.Null]; + internal static readonly HashSet numericFormats = new(StringComparer.OrdinalIgnoreCase) { "int8", "uint8", "int16", "uint16", "int32", "int64", "float", "double", "decimal" }; private static CodeType? GetPrimitiveType(IOpenApiSchema? typeSchema, string? childType = default) { if (typeSchema?.Items?.IsEnum() ?? false) @@ -1299,12 +1300,13 @@ openApiExtension is OpenApiPrimaryErrorMessageExtension primaryErrorMessageExten var format = typeSchema?.Format ?? typeSchema?.Items?.Format; var schemaType = typeName & ~JsonSchemaType.Null; if (schemaType is { } schemaTypeValue && - !string.IsNullOrEmpty(format) && + format is not null && numericFormats.Contains(format) && (schemaTypeValue & JsonSchemaType.String) is JsonSchemaType.String && (schemaTypeValue & (JsonSchemaType.Integer | JsonSchemaType.Number)) != 0) // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) - // advertises numeric members as type ["integer"/"number", "string"]. Prefer the numeric type - // over a scalar union that would otherwise not be mappable and fall back to untyped. + // advertises numeric members as type ["integer"/"number", "string"] with a numeric format. + // Prefer the numeric type over a scalar union that would otherwise not be mappable and + // fall back to untyped. Unions with a non-numeric format keep the previous fallback. schemaType = schemaTypeValue & ~JsonSchemaType.String; return (schemaType, format?.ToLowerInvariant()) switch { diff --git a/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs b/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs index 31b8085034..a8eace6906 100644 --- a/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs +++ b/src/Kiota.Builder/Validation/InconsistentTypeFormatPair.cs @@ -51,12 +51,13 @@ public InconsistentTypeFormatPair() : base(nameof(InconsistentTypeFormatPair), s if (schema is null || !schema.Type.HasValue || string.IsNullOrEmpty(schema.Format) || KnownAndNotSupportedFormats.knownAndUnsupportedFormats.Contains(schema.Format) || escapedTypes.Contains(schema.Type.Value)) return; var sanitizedType = schema.Type.Value & ~JsonSchemaType.Null; - // mirrors KiotaBuilder.GetPrimitiveType: when a format is present, numeric|string unions map to the numeric type + // mirrors KiotaBuilder.GetPrimitiveType: numeric|string unions with a numeric format map to the numeric type if ((sanitizedType & JsonSchemaType.String) is JsonSchemaType.String && - (sanitizedType & (JsonSchemaType.Integer | JsonSchemaType.Number)) != 0) + (sanitizedType & (JsonSchemaType.Integer | JsonSchemaType.Number)) != 0 && + KiotaBuilder.numericFormats.Contains(schema.Format)) sanitizedType &= ~JsonSchemaType.String; if (!validPairs.TryGetValue(sanitizedType, out var validFormats) || !validFormats.Contains(schema.Format)) - context.CreateWarning(nameof(InconsistentTypeFormatPair), $"The format {schema.Format} is not supported by Kiota for the type {sanitizedType} and the string type will be used."); + context.CreateWarning(nameof(InconsistentTypeFormatPair), $"The format {schema.Format} is not supported by Kiota for the type {sanitizedType} and will be ignored."); }) { } diff --git a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs index 43fb8ba39b..37b4b36130 100644 --- a/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs +++ b/tests/Kiota.Builder.Tests/KiotaBuilderTests.cs @@ -1911,9 +1911,13 @@ public void Object_Arrays_are_supported() [InlineData(JsonSchemaType.Number | JsonSchemaType.String, "double", "double")] [InlineData(JsonSchemaType.Number | JsonSchemaType.String, "float", "float")] [InlineData(JsonSchemaType.Number | JsonSchemaType.String | JsonSchemaType.Null, "double", "double")] + [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, "uint16", "integer")] // without a format, the scalar union keeps being generated as a composed type wrapper [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, null, "forecastGetResponse_temperature")] [InlineData(JsonSchemaType.Number | JsonSchemaType.String, null, "forecastGetResponse_temperature")] + // with a non-numeric format, the union is not mappable and keeps falling back to untyped + [InlineData(JsonSchemaType.Integer | JsonSchemaType.String, "uuid", KiotaBuilder.UntypedNodeName)] + [InlineData(JsonSchemaType.Number | JsonSchemaType.String, "date-time", KiotaBuilder.UntypedNodeName)] public void NumericStringScalarUnionsMapToNumericTypes(JsonSchemaType schemaType, string? format, string expectedTypeName) { // System.Text.Json's JsonNumberHandling.AllowReadingFromString (the ASP.NET Core default) diff --git a/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs b/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs index c37286f6a9..443f50d665 100644 --- a/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs +++ b/tests/Kiota.Builder.Tests/Validation/InconsistentTypeFormatPairTests.cs @@ -1,4 +1,5 @@ -using System.IO; +using System; +using System.IO; using System.Text; using System.Threading.Tasks; using Kiota.Builder.Validation; @@ -107,6 +108,7 @@ public async Task DoesntAddWarningOnNullable() [InlineData("[integer, string, 'null']", "int64")] [InlineData("[number, string]", "float")] [InlineData("[number, string, 'null']", "double")] + [InlineData("[integer, string]", "uint16")] public async Task DoesntAddAWarningWhenNumericStringUnionWithNumericFormat(string type, string format) { var documentTxt = $""" @@ -152,7 +154,8 @@ public async Task AddsAWarningWhenNumericStringUnionWithUnsupportedFormat() format: date-time """; var diagnostic = await GetDiagnosticFromDocumentAsync(documentTxt); - Assert.Single(diagnostic.Warnings); + var warning = Assert.Single(diagnostic.Warnings); + Assert.EndsWith("will be ignored.", warning.Message, StringComparison.Ordinal); } private static async Task GetDiagnosticFromDocumentAsync(string document) {