From 288e95aa743cb98dc69b44577ae78956f3f1c7c4 Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 10:16:07 +0000 Subject: [PATCH 1/5] fix(reader): preserve nullable Null flag when type appears after nullable in V3.1/V3.2 deserializers Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/40596ef1-e9f2-4d1b-b9e2-0650b96d73b4 Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --- .../Reader/V31/OpenApiSchemaDeserializer.cs | 15 +++++++-------- .../V31Tests/OpenApiSchemaTests.cs | 12 ++++++++++++ 2 files changed, 19 insertions(+), 8 deletions(-) diff --git a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs index 731cf45e5..296626a93 100644 --- a/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs +++ b/src/Microsoft.OpenApi/Reader/V31/OpenApiSchemaDeserializer.cs @@ -198,21 +198,20 @@ internal static partial class OpenApiV31Deserializer "type", (o, n, doc) => { + // Preserve any Null flag set by a preceding "nullable: true" handler + var preserveNull = o.Type.HasValue && o.Type.Value.HasFlag(JsonSchemaType.Null); if (n is ValueNode) { - o.Type = n.GetScalarValue()?.ToJsonSchemaType(); + var parsedType = n.GetScalarValue()?.ToJsonSchemaType(); + o.Type = preserveNull ? parsedType | JsonSchemaType.Null : parsedType; } else { var list = n.CreateSimpleList((n2, p) => n2.GetScalarValue(), doc); - JsonSchemaType combinedType = 0; - foreach(var type in list) + JsonSchemaType combinedType = preserveNull ? JsonSchemaType.Null : 0; + foreach(var type in list.Where(static t => t is not null).Select(static t => t!.ToJsonSchemaType())) { - if (type is not null) - { - var schemaType = type.ToJsonSchemaType(); - combinedType |= schemaType; - } + combinedType |= type; } o.Type = combinedType; } diff --git a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs index b65b2d8c3..ec66dcbb9 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V31Tests/OpenApiSchemaTests.cs @@ -132,6 +132,18 @@ public void ParseSchemaWithTypeArrayWorks() Assert.Equivalent(expected, actual); } + [Theory] + [InlineData(@"{ ""nullable"": true, ""type"": ""string"" }")] + [InlineData(@"{ ""type"": ""string"", ""nullable"": true }")] + public void ParseSchemaWithNullableBeforeOrAfterTypePreservesNullFlag(string schemaJson) + { + // Act + var schema = OpenApiModelFactory.Parse(schemaJson, OpenApiSpecVersion.OpenApi3_1, new(), out _, "json", SettingsFixture.ReaderSettings); + + // Assert + Assert.Equal(JsonSchemaType.String | JsonSchemaType.Null, schema.Type); + } + [Fact] public void TestSchemaCopyConstructorWithTypeArrayWorks() { From 05a4d8fe43249e6542094c60437db57d6130077e Mon Sep 17 00:00:00 2001 From: "copilot-swe-agent[bot]" <198982749+Copilot@users.noreply.github.com> Date: Tue, 26 May 2026 12:21:07 +0000 Subject: [PATCH 2/5] test(reader): add nullable-before-type tests for V3.0 and V3.2 Agent-Logs-Url: https://github.com/microsoft/OpenAPI.NET/sessions/6de5cea9-ff8f-4a95-804d-493007f279f3 Co-authored-by: baywet <7905502+baywet@users.noreply.github.com> --- .../V3Tests/OpenApiSchemaTests.cs | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs index e16e40594..8241e55ed 100644 --- a/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs +++ b/test/Microsoft.OpenApi.Readers.Tests/V3Tests/OpenApiSchemaTests.cs @@ -133,6 +133,18 @@ public void ParsePathFragmentShouldSucceed() }, openApiAny); } + [Theory] + [InlineData(@"{ ""nullable"": true, ""type"": ""string"" }")] + [InlineData(@"{ ""type"": ""string"", ""nullable"": true }")] + public void ParseSchemaWithNullableBeforeOrAfterTypePreservesNullFlag(string schemaJson) + { + // Act + var schema = OpenApiModelFactory.Parse(schemaJson, OpenApiSpecVersion.OpenApi3_0, new(), out _, "json", SettingsFixture.ReaderSettings); + + // Assert + Assert.Equal(JsonSchemaType.String | JsonSchemaType.Null, schema.Type); + } + [Fact] public void ParseDictionarySchemaShouldSucceed() { From edac88bb6a7c8a15f0c04b755fdecc17b0498f58 Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 28 May 2026 12:30:40 -0400 Subject: [PATCH 3/5] ci: integrate GitHub code coverage uploads (#2864) Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci-cd.yml | 36 +++++++++++++++++++++++++++++++++++- 1 file changed, 35 insertions(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index b9d453d2a..2e00ba347 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -9,6 +9,10 @@ jobs: ci: name: Continuous Integration runs-on: ubuntu-latest + permissions: + contents: read + code-quality: write + pull-requests: read env: ARTIFACTS_FOLDER: ${{ github.workspace }}/Artifacts GITHUB_RUN_NUMBER: ${{ github.run_number }} @@ -27,6 +31,7 @@ jobs: id: checkout_repo uses: actions/checkout@v6 with: + ref: ${{ github.event.pull_request.head.sha || github.sha }} token: ${{ secrets.GITHUB_TOKEN }} fetch-depth: 0 @@ -40,7 +45,36 @@ jobs: id: run_unit_tests shell: pwsh run: | - dotnet test Microsoft.OpenApi.slnx -c Release -v n + dotnet test Microsoft.OpenApi.slnx -c Release --no-build -v n --collect:"XPlat Code Coverage" + + - name: Install report generator + shell: pwsh + run: | + dotnet tool install --global dotnet-reportgenerator-globaltool + + - name: Generate coverage report + shell: pwsh + run: | + reportgenerator -reports:**/coverage.cobertura.xml -targetdir:./reports/coverage -reporttypes:"Html;MarkdownSummaryGithub;Cobertura" + + - name: Add coverage to job summary + shell: bash + run: | + cat ./reports/coverage/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY" + + - name: Upload coverage report + if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') + uses: actions/upload-code-coverage@v1 + with: + file: ./reports/coverage/Cobertura.xml + language: CSharp + label: code-coverage/dotnet + + - name: Upload coverage artifact + uses: actions/upload-artifact@v7 + with: + name: coverage + path: reports/coverage validate-trimming: name: Validate Project for Trimming From 6a3f4c729bd7ccca6f3fcebe9379dd865224048c Mon Sep 17 00:00:00 2001 From: "release-please-token-provider[bot]" <225477224+release-please-token-provider[bot]@users.noreply.github.com> Date: Thu, 28 May 2026 16:31:44 +0000 Subject: [PATCH 4/5] chore(support/v2): release 2.7.6 --- .release-please-manifest.json | 2 +- CHANGELOG.md | 7 +++++++ Directory.Build.props | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/.release-please-manifest.json b/.release-please-manifest.json index ca3f730c7..6f360c576 100644 --- a/.release-please-manifest.json +++ b/.release-please-manifest.json @@ -1,3 +1,3 @@ { - ".": "2.7.5" + ".": "2.7.6" } \ No newline at end of file diff --git a/CHANGELOG.md b/CHANGELOG.md index b22097196..9012ace57 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,12 @@ # Changelog +## [2.7.6](https://github.com/microsoft/OpenAPI.NET/compare/v2.7.5...v2.7.6) (2026-05-28) + + +### Bug Fixes + +* **reader:** preserve nullable Null flag when type appears after nullable in V3.1/V3.2 deserializers ([288e95a](https://github.com/microsoft/OpenAPI.NET/commit/288e95aa743cb98dc69b44577ae78956f3f1c7c4)) + ## [2.7.5](https://github.com/microsoft/OpenAPI.NET/compare/v2.7.4...v2.7.5) (2026-05-26) diff --git a/Directory.Build.props b/Directory.Build.props index f06b5bb92..72c92bace 100644 --- a/Directory.Build.props +++ b/Directory.Build.props @@ -12,7 +12,7 @@ https://github.com/Microsoft/OpenAPI.NET © Microsoft Corporation. All rights reserved. OpenAPI .NET - 2.7.5 + 2.7.6 From d36e9417b3dc6fc81d7b7f7ab48cb707a02b66fa Mon Sep 17 00:00:00 2001 From: Vincent Biret Date: Thu, 28 May 2026 12:46:50 -0400 Subject: [PATCH 5/5] ci: skip coverage uploads off default branch Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> --- .github/workflows/ci-cd.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci-cd.yml b/.github/workflows/ci-cd.yml index 2e00ba347..fb99868ee 100644 --- a/.github/workflows/ci-cd.yml +++ b/.github/workflows/ci-cd.yml @@ -63,7 +63,7 @@ jobs: cat ./reports/coverage/SummaryGithub.md >> "$GITHUB_STEP_SUMMARY" - name: Upload coverage report - if: github.event_name != 'pull_request' || (github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') + if: (github.event_name == 'pull_request' && github.event.pull_request.head.repo.full_name == github.repository && github.actor != 'dependabot[bot]') || (github.event_name != 'pull_request' && github.ref_name == github.event.repository.default_branch) uses: actions/upload-code-coverage@v1 with: file: ./reports/coverage/Cobertura.xml