|
|
@ -145,17 +145,31 @@ public static class JsonSchemaExtensions |
|
|
|
var propertyName = defaultModelMetadata.Name; |
|
|
|
if (propertyName != null) |
|
|
|
{ |
|
|
|
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType() == typeof(SelectAttribute)) is SelectAttribute selectAttribute) |
|
|
|
{ |
|
|
|
schema.Add("input", "select"); |
|
|
|
schema.Add("mutiple", selectAttribute.Mutiple); |
|
|
|
schema.Add("url", $"{selectAttribute.Controller ?? propertyName.TrimEnd("Id").ToSlugify()}/{selectAttribute.Action ?? "index"}"); |
|
|
|
schema.Add("parentId", selectAttribute.ParentId ?? "parentId"); |
|
|
|
schema.AddNotNull("value", selectAttribute.Value ?? "id"); |
|
|
|
schema.AddNotNull("label", selectAttribute.Label ?? "name"); |
|
|
|
} |
|
|
|
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType() == typeof(DefaultValueAttribute)) is DefaultValueAttribute defaultValue) |
|
|
|
{ |
|
|
|
schema.AddNotNull("default", defaultValue.Value); |
|
|
|
} |
|
|
|
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType() == typeof(NavigationAttribute)) is NavigationAttribute navigationAttribute) |
|
|
|
//if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType() == typeof(NavigationAttribute)) is NavigationAttribute navigationAttribute)
|
|
|
|
//{
|
|
|
|
// var path = navigationAttribute.Property ?? $"{propertyName[..^2]}.Name";
|
|
|
|
// path = string.Join('.', path.Split('.').Select(o => o.ToCamelCase()));
|
|
|
|
// schema.Add("navigation", path);
|
|
|
|
// schema.Add("input", "select");
|
|
|
|
// schema.Add("url", defaultModelMetadata.ContainerType?.GetProperty(propertyName[..^2])?.PropertyType.Name.ToSlugify()!);
|
|
|
|
//}
|
|
|
|
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType().IsGenericType && o.GetType().GetGenericTypeDefinition() == typeof(ManyToOneAttribute<>)) is ITypeAttribute manyToOneAttribute) |
|
|
|
{ |
|
|
|
var path = navigationAttribute.Property ?? $"{propertyName[..^2]}.Name"; |
|
|
|
path = string.Join('.', path.Split('.').Select(o => o.ToCamelCase())); |
|
|
|
schema.Add("navigation", path); |
|
|
|
schema.Add("input", "select"); |
|
|
|
schema.Add("url", defaultModelMetadata.ContainerType?.GetProperty(propertyName[..^2])?.PropertyType.Name.ToSlugify()!); |
|
|
|
schema.Add("manyToOne", $"{manyToOneAttribute.Type.Name}.{manyToOneAttribute.GetType().GetProperty("Property")?.GetValue(manyToOneAttribute) ?? defaultModelMetadata.PropertyName}"); |
|
|
|
//schema.Add("url", manyToOneAttribute.Type.Name.ToSlugify());
|
|
|
|
} |
|
|
|
if (defaultModelMetadata.Attributes.Attributes.FirstOrDefault(o => o.GetType().IsGenericType && o.GetType().GetGenericTypeDefinition() == typeof(OneToManyAttribute<>)) is ITypeAttribute oneToManyAttribute) |
|
|
|
{ |
|
|
|