-
Notifications
You must be signed in to change notification settings - Fork 10.6k
feat(openapi): support Nullable Description Attribute on enums #65245
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
|
Thanks to @desjoerd for his support. |
There was a problem hiding this 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 |
...re.OpenApi.SourceGenerators.Tests/Microsoft.AspNetCore.OpenApi.SourceGenerators.Tests.csproj
Show resolved
Hide resolved
src/OpenApi/test/Microsoft.AspNetCore.OpenApi.Tests/Microsoft.AspNetCore.OpenApi.Tests.csproj
Show resolved
Hide resolved
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
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