Unchase.Swashbuckle.AspNetCore.Extensions icon indicating copy to clipboard operation
Unchase.Swashbuckle.AspNetCore.Extensions copied to clipboard

Multiple Enum Labels with the Same Value Results in Unusable Output

Open Lazzaretti opened this issue 3 years ago • 0 comments

I have an enum with multiple labels pointing to the same value.

public enum SomeFields
{
   Field1 = 1,
   AnotherNameForField1 = Field1,
   Field2 = 2,
}

Unfortunately, that results in a non-matchable list of values and names:

"SomeFields": {
 "enum": [
   1,
   2
 ],
 "type": "integer",
 "format": "int32",
 "x-enumNames": [
   "Field1",
   "AnotherNameForField1",
   "Field2"
 ]
},

Can that be fixed by eighter: duplicate the enum values (enum), or remove the duplicate labels from the labels list (x-enumNames)?

Lazzaretti avatar Mar 07 '22 10:03 Lazzaretti