-Added GetSchema, CanRead, CanWrite to JsonConverter

-Fix CustomCreationConverter erroring when writing JSON
This commit is contained in:
JamesNK
2010-02-06 22:55:36 +00:00
parent 992985bd7b
commit c7facae789
17 changed files with 223 additions and 38 deletions
@@ -234,6 +234,15 @@ namespace Newtonsoft.Json.Schema
throw new Exception("Unresolved circular reference for type '{0}'. Explicitly define an Id for the type using a JsonObject/JsonArray attribute or automatically generate a type Id using the UndefinedSchemaIdHandling property.".FormatWith(CultureInfo.InvariantCulture, type));
}
JsonContract contract = ContractResolver.ResolveContract(type);
JsonConverter converter;
if ((converter = contract.Converter) != null || (converter = contract.InternalConverter) != null)
{
JsonSchema converterSchema = converter.GetSchema();
if (converterSchema != null)
return converterSchema;
}
Push(new TypeSchema(type, new JsonSchema()));
if (explicitId != null)
@@ -244,8 +253,7 @@ namespace Newtonsoft.Json.Schema
CurrentSchema.Title = GetTitle(type);
CurrentSchema.Description = GetDescription(type);
JsonContract contract = ContractResolver.ResolveContract(type);
if (contract.Converter != null || contract.InternalConverter != null)
if (converter != null)
{
// todo: Add GetSchema to JsonConverter and use here?
CurrentSchema.Type = JsonSchemaType.Any;