API Explorer : default <input type=tag> for string[] property types

Hello,

Is there a way to automatically define the [Input(Type="tag")] attribute for all properties of type IEnumerable in API Explorer without having to manually set this attribute in each relevant DTO ?

Currently, if I don’t define this attribute for string[] properties, no control is displayed

Thank you

Here’s an example of using AddToAppMetadata to dynamically add [Input(Type="tag")] metadata to all Request DTO string[] properties in your AppHost:

public override void Configure()
{
    this.AddToAppMetadata(meta =>
    {
        foreach (var api in meta.Api.Operations)
        {
            foreach (var prop in api.Request.Properties
                ?.Where(x => x.Type == "String[]") ?? [])
            {
                prop.Input = new()
                {
                    Type = "tag"
                };
            }
        }
    });
}
1 Like