NJsonSchema
NJsonSchema copied to clipboard
Add support for flag enums with more than 32 values
The generator has so far only generated enums with the implicit default type int. Also for enums declared with the base type long in C# and a "Format = int64" was specified in the OpenAPI document. Original C#
public enum Foo : long
{
_0 = 0L,
_1 = 1L << 1,
_2 = 1L << 2,
...
_31 = 1L << 31,
_32 = 1L << 32,
_33 = 1L << 33
}
Swagger Definition
"Foo": {
"type": "integer",
"format": "int64",
"description": "",
"x-enumNames": [
"_0",
"_1",
"_2",
...
"_31",
"_32",
"_33"
],
"enum": [
0,
2,
4,
...
2147483648,
4294967296,
8589934592
]
}
NSwag Output
public enum Foo
{
_0 = 0,
_1 = 2,
_2 = 4,
...
_31 = 2147483648,
_32 = 4294967296,
_33 = 8589934592
}
The nswag output does not compile because "long" is missing as base type. The values exceed the range of the implicit base type int.