-Fixed incorrect XML documentation

-Fixed writing JValue with readonly JsonConverters
This commit is contained in:
James Newton-King
2013-12-06 21:48:00 +13:00
parent 3e53808b1b
commit b96d9fb689
7 changed files with 91 additions and 16 deletions
@@ -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);
}
}