Fix preview 5 regression for OpenApi nullable enums#67385
Draft
Youssef1313 wants to merge 1 commit into
Draft
Conversation
Contributor
There was a problem hiding this comment.
Pull request overview
Fixes a regression introduced by the enum naming-policy parameter schema rewrite (PR #66228) where nullable enums no longer included null in their generated OpenAPI enum arrays. This restores the prior behavior while preserving the naming-policy correction for non-body parameters.
Changes:
- Update parameter-schema enum rewriting to append
nullfor nullable enum parameters. - Add integration snapshot coverage for nullable enum behavior across OpenAPI 3.0/3.1/3.2 for both non-body parameters and JSON request bodies.
- Add new integration test fixture and corresponding snapshots for the nullable enum + global naming policy scenario.
Reviewed changes
Copilot reviewed 8 out of 8 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| src/OpenApi/src/Extensions/JsonNodeSchemaExtensions.cs | Restores null enum entry when rewriting non-body nullable enum parameter schemas. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/OpenApiDocumentEnumNamingPolicyIntegrationTests.cs | Adds integration tests to validate nullable enum behavior with a global naming policy. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_0/OpenApiDocumentEnumNamingPolicyIntegrationTests.GetOpenApiParameters_NullableEnumWithGlobalNamingPolicy_NonBodySchemaOmitsNullEnumEntry.verified.txt | Snapshot asserting nullable enum parameter schema includes null in enum. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_0/OpenApiDocumentEnumNamingPolicyIntegrationTests.GetOpenApiRequestBody_NullableEnumWithGlobalNamingPolicy_BodySchemaOmitsNullEnumEntry.verified.txt | Snapshot asserting nullable enum body schema retains null handling and enum entry. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_1/OpenApiDocumentEnumNamingPolicyIntegrationTests.GetOpenApiParameters_NullableEnumWithGlobalNamingPolicy_NonBodySchemaOmitsNullEnumEntry.verified.txt | Same as above for OpenAPI 3.1. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_1/OpenApiDocumentEnumNamingPolicyIntegrationTests.GetOpenApiRequestBody_NullableEnumWithGlobalNamingPolicy_BodySchemaOmitsNullEnumEntry.verified.txt | Same as above for OpenAPI 3.1. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_2/OpenApiDocumentEnumNamingPolicyIntegrationTests.GetOpenApiParameters_NullableEnumWithGlobalNamingPolicy_NonBodySchemaOmitsNullEnumEntry.verified.txt | Same as above for OpenAPI 3.2. |
| src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Integration/snapshots/OpenApi3_2/OpenApiDocumentEnumNamingPolicyIntegrationTests.GetOpenApiRequestBody_NullableEnumWithGlobalNamingPolicy_BodySchemaOmitsNullEnumEntry.verified.txt | Same as above for OpenAPI 3.2. |
javiercn
approved these changes
Jun 23, 2026
7439286 to
d7fa307
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This regressed in #66228
Previously, we were getting the "null" in the enum array, but in #66228 we started to write the array ourselves and we dropped the null for nullable enums. This makes sure that null is kept.