private Schema CreateRefSchema(Type type)
{
if (!_referencedTypes.ContainsKey(type))
{
var schemaId = _schemaIdSelector(type);
if (_referencedTypes.Any(entry => entry.Value.SchemaId == schemaId))
{
var conflictingType = _referencedTypes.First(entry => entry.Value.SchemaId == schemaId).Key;
throw new InvalidOperationException(String.Format(
"Conflicting schemaIds: Duplicate schemaIds detected for types {0} and {1}. " +
"See the config setting - \"UseFullTypeNameInSchemaIds\" for a potential workaround",
type.FullName, conflictingType.FullName));
}
_referencedTypes.Add(type, new SchemaInfo { SchemaId = schemaId });
}
return new Schema { @ref = "#/definitions/" + _referencedTypes[type].SchemaId };
}