feat(openapi): support Description Attribute on Nullable enums#65245
Open
rdeveen wants to merge 1 commit intodotnet:mainfrom
Open
feat(openapi): support Description Attribute on Nullable enums#65245rdeveen wants to merge 1 commit intodotnet:mainfrom
rdeveen wants to merge 1 commit intodotnet:mainfrom
Conversation
Contributor
Author
|
Thanks to @desjoerd for his support. |
Contributor
There was a problem hiding this comment.
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 |
This was referenced Jan 27, 2026
Open
PovoleriP
approved these changes
Jan 28, 2026
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.
2faed05 to
670cac7
Compare
desjoerd
approved these changes
Jan 28, 2026
Contributor
|
I'm tripped by the the title on this PR. Is the goal of the PR to make a "description" field show up on nullable enums? Or all enums? Or ?? Would it be more accurate if the title was "support Description Attribute on nullable enums"? |
This was referenced Apr 19, 2026
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.
Support Nullable Description Attribute on enums.
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