Skip to content

Conversation

@rdeveen
Copy link
Contributor

@rdeveen rdeveen commented Jan 27, 2026

Support Nullable Description Attribute on enums.

  • You've read the Contributor Guide and Code of Conduct.
  • You've included unit or integration tests for your change, where applicable.
  • You've included inline docs for your change, where applicable.
  • There's an open issue for the PR that you are making. If you'd like to propose a new feature or change, please open an issue to discuss the change or find an existing issue.

Description

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.

Fixes #65067

@rdeveen rdeveen requested a review from a team as a code owner January 27, 2026 18:53
Copilot AI review requested due to automatic review settings January 27, 2026 18:53
@github-actions github-actions bot added the needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically label Jan 27, 2026
@rdeveen
Copy link
Contributor Author

rdeveen commented Jan 27, 2026

Thanks to @desjoerd for his support.

@desjoerd desjoerd added feature-openapi area-minimal Includes minimal APIs, endpoint filters, parameter binding, request delegate generator etc and removed needs-area-label Used by the dotnet-issue-labeler to label those issues which couldn't be triaged automatically labels Jan 27, 2026
@dotnet-policy-service dotnet-policy-service bot added the community-contribution Indicates that the PR has been added by a community member label Jan 27, 2026
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This pull request fixes a regression in Microsoft.AspNetCore.OpenApi 10.0.2 where DescriptionAttribute on enum types was not being reflected in the generated OpenAPI schemas. The fix ensures that descriptions are correctly retrieved from the underlying type when dealing with nullable enums.

Changes:

  • Modified description attribute retrieval logic to check the ElementType (for nullable value types) before falling back to the Type itself
  • Added comprehensive test coverage for nullable enum descriptions and enhanced existing tests to verify enum descriptions
  • Standardized HelixContent formatting in project files from multi-line to single-line format

Reviewed changes

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

File Description
src/OpenApi/src/Services/Schemas/OpenApiSchemaService.cs Fixed description attribute retrieval to check ElementType for nullable value types (including enums)
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Services/OpenApiSchemaService/OpenApiSchemaService.RequestBodySchemas.cs Added new test for nullable enum descriptions, enhanced existing test to verify enum schema descriptions, added SampleEnum definition with description, and applied formatting fixes to lambda expressions
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Microsoft.AspNetCore.OpenApi.Tests.csproj Standardized HelixContent formatting to single-line
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests.csproj Standardized HelixContent formatting to single-line

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.
@rdeveen rdeveen force-pushed the fix/enum-description branch from 2faed05 to 670cac7 Compare January 28, 2026 08:23
@rdeveen rdeveen requested a review from desjoerd January 28, 2026 08:26
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 community-contribution Indicates that the PR has been added by a community member feature-openapi

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Microsoft.AspNetCore.OpenApi 10.0.2: Missing Enum description

3 participants