Skip to content

Commit

Permalink
Removed unneeded StringEnumConverter usage. Also removed it from the …
Browse files Browse the repository at this point in the history
…defaults for tests, because that hides the problem when we forget to put it on a member that needs it.
  • Loading branch information
Bart Koelman committed Sep 10, 2021
1 parent fd1437c commit 705bcd8
Show file tree
Hide file tree
Showing 6 changed files with 11 additions and 4 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
using System.Collections.Generic;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonApiDotNetCore.Serialization.Objects
{
Expand All @@ -13,7 +12,6 @@ public sealed class AtomicOperationObject : ExposableData<ResourceObject>
public IDictionary<string, object> Meta { get; set; }

[JsonProperty("op")]
[JsonConverter(typeof(StringEnumConverter))]
public AtomicOperationCode Code { get; set; }

[JsonProperty("ref", NullValueHandling = NullValueHandling.Ignore)]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
using JsonApiDotNetCore.Configuration;
using JsonApiDotNetCore.Serialization.Objects;
using Microsoft.Extensions.DependencyInjection;
using Newtonsoft.Json.Converters;
using TestBuildingBlocks;
using Xunit;

Expand All @@ -27,6 +28,7 @@ public FilterDataTypeTests(IntegrationTestContext<TestableStartup<FilterDbContex

var options = (JsonApiOptions)testContext.Factory.Services.GetRequiredService<IJsonApiOptions>();
options.EnableLegacyFilterNotation = false;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
}

[Theory]
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonApiDotNetCoreTests.IntegrationTests.QueryStrings
{
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
[JsonConverter(typeof(StringEnumConverter))]
public enum LabelColor
{
Red,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonApiDotNetCoreTests.IntegrationTests.ReadWrite
{
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
[JsonConverter(typeof(StringEnumConverter))]
public enum WorkItemPriority
{
Low,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
using JetBrains.Annotations;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace JsonApiDotNetCoreTests.IntegrationTests.ResourceDefinitions.Reading
{
[UsedImplicitly(ImplicitUseTargetFlags.Members)]
[JsonConverter(typeof(StringEnumConverter))]
public enum StarKind
{
Other,
Expand Down
2 changes: 0 additions & 2 deletions test/TestBuildingBlocks/TestableStartup.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;

namespace TestBuildingBlocks
{
Expand All @@ -21,7 +20,6 @@ protected virtual void SetJsonApiOptions(JsonApiOptions options)
{
options.IncludeExceptionStackTraceInErrors = true;
options.SerializerSettings.Formatting = Formatting.Indented;
options.SerializerSettings.Converters.Add(new StringEnumConverter());
}

public virtual void Configure(IApplicationBuilder app, IWebHostEnvironment environment, ILoggerFactory loggerFactory)
Expand Down

0 comments on commit 705bcd8

Please sign in to comment.