Microsoft.AspNetCore.OpenApi does not generate a schema for an enum that is a key in a dictionary
- Dominant language
- C#
- Stars
- 38.4k
- Forks
- 10.9k
- Avg merge
- 2d 10h
- Merged PRs (30d)
- 281
Description
### Is there an existing issue for this?
- [x] I have searched the existing issues
### Describe the bug
WebAPI .NET 9
Nuget: Microsoft.AspNetCore.OpenApi 9.0.1
Hello, when I use attribute:
`[ProducesResponseType>(403)]`
the enum values are not generated in the OpenApi.json under the components/schemas section.
The enum is not generated even when using minimal API
`app.MapGet("/minimal-api-approach", () =>
{
return "Hello World!";
}).Produces>();`
`public class WeatherForecastController : ControllerBase
{
public WeatherForecastController() {
[HttpGet(Name = "controller-approach")]
[ProducesResponseType>(401)]
[ProducesResponseType>(403)]
public Task Get()
{
throw new NotImplementedException();
}
public record FailureResult(Dictionary Errors) where T : Enum;
public record ErrorDetail(string Description);
[JsonConverter(typeof(JsonStringEnumConverter))]
public enum AuthErrorType
{
InvalidCredentials,
InvalidLogin
}}`
### Expected Behavior
The expected result is a generated enum values in the components/schemas section.
With NSwag the result is below:
`
"components": {
"schemas": {
"AuthErrorType": {
"type": "integer",
"description": "",
"x-enumNames": [
"InvalidCredentials",
"InvalidLogin"
],
"enum": [
0,
1
]
}
}
}`
### Steps To Reproduce
https://github.com/PatrezDev/openapispec-net-nswag
### Exceptions (if any)
_No response_
### .NET Version
.NET 9
### Anything else?

Contributor guide
Assessment
This issue has not been assessed yet.