-Fixed incorrect XML documentation
-Fixed writing JValue with readonly JsonConverters
This commit is contained in:
@@ -758,6 +758,45 @@ namespace Newtonsoft.Json.Tests.Schema
|
||||
]
|
||||
}
|
||||
}
|
||||
}", json);
|
||||
}
|
||||
|
||||
[JsonConverter(typeof(StringEnumConverter))]
|
||||
public enum SortTypeFlagAsString
|
||||
{
|
||||
No = 0,
|
||||
Asc = 1,
|
||||
Desc = -1
|
||||
}
|
||||
|
||||
public class Y
|
||||
{
|
||||
public SortTypeFlagAsString y;
|
||||
}
|
||||
|
||||
[Test]
|
||||
public void GenerateSchemaWithStringEnum()
|
||||
{
|
||||
JsonSchemaGenerator jsonSchemaGenerator = new JsonSchemaGenerator();
|
||||
JsonSchema schema = jsonSchemaGenerator.Generate(typeof(Y));
|
||||
|
||||
string json = schema.ToString();
|
||||
|
||||
// NOTE: This fails because the enum is serialized as an integer and not a string.
|
||||
// NOTE: There should exist a way to serialize the enum as lowercase strings.
|
||||
Assert.AreEqual(@"{
|
||||
""type"": ""object"",
|
||||
""properties"": {
|
||||
""y"": {
|
||||
""required"": true,
|
||||
""type"": ""string"",
|
||||
""enum"": [
|
||||
""no"",
|
||||
""asc"",
|
||||
""desc""
|
||||
]
|
||||
}
|
||||
}
|
||||
}", json);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user