SchemaResolver
Manager which resolves types to schemas.
using System;
using System.Collections.Generic;
namespace NJsonSchema
{
public class SchemaResolver : ISchemaResolver
{
private readonly Dictionary<Type, JsonSchema4> _mappings = new Dictionary<Type, JsonSchema4>();
public IEnumerable<JsonSchema4> Schemes => _mappings.Values;
public bool HasSchema(Type type)
{
return _mappings.ContainsKey(type);
}
public JsonSchema4 GetSchema(Type type)
{
return _mappings[type];
}
public void AddSchema(Type type, JsonSchema4 schema)
{
_mappings.Add(type, schema);
}
}
}