Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Generate Enum-Dictionary-Keys (analogous to Newtonsoft) #2825

Merged
merged 8 commits into from
Apr 24, 2024
Prev Previous commit
Just compare enum names für Dictionary-Test
  • Loading branch information
angelaki committed Apr 24, 2024
commit 136aaecc823e5579bfce6e65dc2e2c51fe6613af
Original file line number Diff line number Diff line change
Expand Up @@ -770,22 +770,15 @@ public void GenerateSchema_HonorsSerializerOption_StringEnumConverter(
Assert.Equal(expectedDefaultAsJson, propertySchema.Default.ToJson());
}

[Theory]
[InlineData(false, new[] { "Value2", "Value4", "Value8" })]
[InlineData(true, new[] { "value2", "value4", "value8" })]
public void GenerateSchema_HonorsEnumDictionaryKeys_StringEnumConverter(
bool camelCaseText,
string[] expectedEnumAsJson
)
[Fact]
public void GenerateSchema_HonorsEnumDictionaryKeys_StringEnumConverter()
{
var subject = Subject(
configureSerializer: c => c.DictionaryKeyPolicy = camelCaseText ? JsonNamingPolicy.CamelCase : null
);
var subject = Subject();
var schemaRepository = new SchemaRepository();

var referenceSchema = subject.GenerateSchema(typeof(Dictionary<IntEnum, string>), schemaRepository);

Assert.Equal(expectedEnumAsJson, referenceSchema.Properties.Keys);
Assert.Equal(typeof(IntEnum).GetEnumNames(), referenceSchema.Properties.Keys);
}

[Fact]
Expand Down