Description
Is there an existing issue for this?
- I have searched the existing issues
Describe the bug
I have two operations that uses enums; one has [Flags] applied to it, the other does not. The one without flags is handled correctly, the one with the attribute is not.
[Flags]
public enum EnumWithFlags
{
None = 0,
Value2 = 1,
Value3 = 2,
Value4 = 4,
Value5 = 8,
Value6 = 16
}
public enum EnumWithNoFlags
{
None = 0,
Value2 = 1,
Value3 = 2,
Value4 = 4,
Value5 = 8,
Value6 = 16
}
"EnumWithFlags": {
"type": "string"
},
"EnumWithNoFlags": {
"enum": [
"None",
"Value2",
"Value3",
"Value4",
"Value5",
"Value6"
]
Expected Behavior
Enums with flags should be handled the same as without flags.
[Flags] is a .NET specific thing and one could consider this an edge case since it doesn't have a counterpart in OpenApi. I work on a set of old apps that have been upgraded from asmx->WCF->WebApi. These use flag enums and we have .NET on both sides.
The STJ Enum converter has support for Flags
https://github.com/dotnet/runtime/blob/f96898084d7e4fadd8679f280daef979d60e10cf/src/libraries/System.Text.Json/src/System/Text/Json/Serialization/Converters/Value/EnumConverter.cs#L23
Steps To Reproduce
https://github.com/dnv-kimbell/openapi-inlineschema
Exceptions (if any)
No response
.NET Version
9.0 RC1
Anything else?
No response