Skip to content

Commit

Permalink
Merge pull request #2367 from domaindrivendev/fix-enum-deduping
Browse files Browse the repository at this point in the history
Dedup enum values after serialization instead of before
  • Loading branch information
domaindrivendev authored Mar 7, 2022
2 parents bb118db + fdf8d9a commit c5094a3
Showing 1 changed file with 2 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -278,6 +278,7 @@ private OpenApiSchema CreatePrimitiveSchema(DataContract dataContract)
{
schema.Enum = dataContract.EnumValues
.Select(value => JsonSerializer.Serialize(value))
.Distinct()
.Select(valueAsJson => OpenApiAnyFactory.CreateFromJson(valueAsJson))
.ToList();

Expand All @@ -288,8 +289,8 @@ private OpenApiSchema CreatePrimitiveSchema(DataContract dataContract)
{
schema.Enum = dataContract.UnderlyingType.GetEnumValues()
.Cast<object>()
.Distinct()
.Select(value => dataContract.JsonConverter(value))
.Distinct()
.Select(valueAsJson => OpenApiAnyFactory.CreateFromJson(valueAsJson))
.ToList();
}
Expand Down

0 comments on commit c5094a3

Please sign in to comment.