DefaultSchemaNameGenerator
The default schema name generator implementation.
using NJsonSchema.Annotations;
using NJsonSchema.Infrastructure;
using System;
using System.Reflection;
namespace NJsonSchema
{
public class DefaultSchemaNameGenerator : ISchemaNameGenerator
{
public virtual string Generate(Type type)
{
JsonSchemaAttribute customAttribute = type.GetTypeInfo().GetCustomAttribute<JsonSchemaAttribute>();
if (!string.IsNullOrEmpty(customAttribute?.Name))
return customAttribute.Name;
return ReflectionExtensions.GetSafeTypeName(type);
}
}
}