Skip to content

Commit

Permalink
🔧 Enum values were not getting camelcased. (#33)
Browse files Browse the repository at this point in the history
  • Loading branch information
PureKrome authored Sep 22, 2020
1 parent f46a516 commit 8eb8e02
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@ public static IMvcBuilder AddDefaultJsonOptions(this IMvcBuilder builder,
options.JsonSerializerOptions.IgnoreNullValues = true;
options.JsonSerializerOptions.WriteIndented = isIndented;
options.JsonSerializerOptions.PropertyNamingPolicy = JsonNamingPolicy.CamelCase;
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter());
options.JsonSerializerOptions.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));

// If we have specified a custom date-time format, then use the specific custom converter.
if (!string.IsNullOrWhiteSpace(dateTimeFormat))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ public async Task GivenSomeModel_Get_ReturnsASyntaxCorrectJsonText(int id,
var responseBody = await response.Content.ReadAsStringAsync();
responseBody.ShouldContain("id", Case.Sensitive); // Camel case check.
responseBody.ShouldNotContain("vin", Case.Insensitive); // IgnoreNullValues check.
responseBody.ShouldContain("Grey", Case.Sensitive); // Enum converter check.
responseBody.ShouldContain("grey", Case.Sensitive); // Enum converter check.
responseBody.ShouldContain(expectedDateTime);

var startingJson = isIdented
Expand Down
4 changes: 2 additions & 2 deletions tests/Homely.AspNetCore.Mvc.Helpers.Tests/TestHelpers.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.Mvc;
using Shouldly;
using System;
using System.Net.Http;
Expand All @@ -19,7 +19,7 @@ public static class TestHelpers
PropertyNamingPolicy = JsonNamingPolicy.CamelCase
};

options.Converters.Add(new JsonStringEnumConverter());
options.Converters.Add(new JsonStringEnumConverter(JsonNamingPolicy.CamelCase));

return options;
});
Expand Down

0 comments on commit 8eb8e02

Please sign in to comment.