Skip to content

Fix preview 5 regression for OpenApi nullable enums#67385

Draft
Youssef1313 wants to merge 1 commit into
mainfrom
dev/ygerges/openapi-nullable-enum
Draft

Fix preview 5 regression for OpenApi nullable enums#67385
Youssef1313 wants to merge 1 commit into
mainfrom
dev/ygerges/openapi-nullable-enum

Conversation

@Youssef1313

Copy link
Copy Markdown
Member

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.

Copilot AI review requested due to automatic review settings June 23, 2026 13:25
@Youssef1313 Youssef1313 requested a review from a team as a code owner June 23, 2026 13:25

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 null for 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.

@Youssef1313 Youssef1313 force-pushed the dev/ygerges/openapi-nullable-enum branch from 7439286 to d7fa307 Compare June 23, 2026 13:47
@Youssef1313 Youssef1313 marked this pull request as draft June 23, 2026 14:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants