DefaultSchemaNameGenerator
The default schema name generator implementation.
using Namotion.Reflection;
using NJsonSchema.Annotations;
using System;
namespace NJsonSchema.Generation
{
public class DefaultSchemaNameGenerator : ISchemaNameGenerator
{
public virtual string Generate(Type type)
{
JsonSchemaAttribute typeAttribute = type.ToCachedType().GetTypeAttribute<JsonSchemaAttribute>();
if (!string.IsNullOrEmpty(typeAttribute?.Name))
return typeAttribute.Name;
return type.GetDisplayName();
}
}
}