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 = ContextualTypeExtensions.ToCachedType(type).GetTypeAttribute<JsonSchemaAttribute>();
if (!string.IsNullOrEmpty(typeAttribute?.Name))
return typeAttribute.Name;
return TypeExtensions.GetDisplayName(type);
}
}
}