Skip to content

[release/10.0] Handle DescriptionAttribute for nullable value types in OpenAPI generation - #67051

Merged
wtgodbe merged 4 commits into
release/10.0from
backport/pr-65245-to-release/10.0
Jun 9, 2026
Merged

[release/10.0] Handle DescriptionAttribute for nullable value types in OpenAPI generation#67051
wtgodbe merged 4 commits into
release/10.0from
backport/pr-65245-to-release/10.0

Conversation

@github-actions

@github-actions github-actions Bot commented Jun 6, 2026

Copy link
Copy Markdown
Contributor

Backport of #65245 to release/10.0

/cc @Youssef1313 @rdeveen

Handle DescriptionAttribute for nullable value types in OpenAPI generation

Fixes missing description in OpenAPI document for nullable enums.

Description

This PR handles DescriptionAttribute correctly when generating OpenAPI documents when processing Nullable<T> where T is an enum that has DescriptionAttribute, which was previously ignored.

Fixes #65067

Customer Impact

Customer reported in #65067. While this appears to have been broken since the beginning, there are certain scenarios where it could have worked by chance (when two APIs are declared, and one uses Nullable<Enum> while the other uses Enum). For those scenarios that worked by chance, this is seen by users as a regression (and user report is reporting it as a regression).

Regression?

Technically no, but from user perspective, it could be if they fall in the "worked by chance" scenario. The working version in this case is Microsoft.AspNetCore.OpenApi 10.0.1 and the broken version is 10.0.2

Risk

Low. The change is very well-scoped and simply unwraps nullable value types before retrieving DescriptionAttribute.

Verification

Test is added

Packaging changes reviewed?

N/A

rdeveen and others added 4 commits June 6, 2026 06:39
Improve OpenApiSchemaService to retrieve DescriptionAttribute from underlying types, enabling correct descriptions for enums and nullable enums. Expand tests to cover these scenarios and verify schema descriptions. Standardize HelixContent formatting in project files.
Co-authored-by: Youssef Fahmy <youssefvictor00@gmail.com>
Co-authored-by: Youssef Fahmy <youssefvictor00@gmail.com>
@github-actions
github-actions Bot requested a review from a team as a code owner June 6, 2026 06:39
@Youssef1313

Youssef1313 commented Jun 6, 2026

Copy link
Copy Markdown
Member

Thanks to whoever made the backport bot add the servicing template as part of the PR description automatically :)

Drafting for now until I fill the template later on Monday.

@Youssef1313 Youssef1313 self-assigned this Jun 6, 2026
@Youssef1313
Youssef1313 marked this pull request as draft June 6, 2026 06:48
@github-actions github-actions Bot added the area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates label Jun 6, 2026
@Youssef1313 Youssef1313 added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed area-mvc Includes: MVC, Actions and Controllers, Localization, CORS, most templates labels Jun 8, 2026
@Youssef1313
Youssef1313 marked this pull request as ready for review June 8, 2026 10:39
Copilot AI review requested due to automatic review settings June 8, 2026 10:39
@Youssef1313 Youssef1313 added the Servicing-consider Shiproom approval is required for the issue label Jun 8, 2026
@dotnet-policy-service

Copy link
Copy Markdown
Contributor

Hi @github-actions[bot]. Please make sure you've updated the PR description to use the Shiproom Template. Also, make sure this PR is not marked as a draft and is ready-to-merge.

To learn more about how to prepare a servicing PR click here.

@Youssef1313 Youssef1313 changed the title [release/10.0] feat(openapi): support Description Attribute on Nullable enums [release/10.0] Handle DescriptionAttribute for nullable value types in OpenAPI generation Jun 8, 2026

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

This backport fixes OpenAPI schema generation so DescriptionAttribute applied to enum types is honored even when the enum is used via Nullable<T> (e.g., MyEnum?), restoring missing description fields in generated OpenAPI documents.

Changes:

  • Unwrap nullable value types before reading DescriptionAttribute when generating schema descriptions.
  • Expand request body schema tests to cover enum/property/type description scenarios, including nullable enums.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 3 comments.

File Description
src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs Updates schema generation to read DescriptionAttribute from the underlying type for nullable value types.
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.RequestBodySchemas.cs Adds/extends tests asserting enum/type/property descriptions, including nullable enum coverage.

@Youssef1313 Youssef1313 added Servicing-approved Shiproom has approved the issue and removed Servicing-consider Shiproom approval is required for the issue labels Jun 9, 2026
@Youssef1313

Copy link
Copy Markdown
Member

Approved via email.

@wtgodbe
wtgodbe merged commit 526b054 into release/10.0 Jun 9, 2026
29 checks passed
@wtgodbe
wtgodbe deleted the backport/pr-65245-to-release/10.0 branch June 9, 2026 14:23
@Youssef1313 Youssef1313 added this to the 10.0.10 milestone Jun 9, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc feature-openapi Servicing-approved Shiproom has approved the issue

Projects

None yet

Development

Successfully merging this pull request may close these issues.

5 participants