Ryan Vice
Ryan Vice

Reputation: 2181

Is there a way to have a ServiceStack metadata page show all the options for an enum request or response property

I'd like to be able to have the code below

    [Route("/Incidents", "Get")]
public class GetViewConfig
{
    public List<Filter> Filters { get; set; }
}

public class Filter
{
    public string Property { get; set; }
    public FilterType Type { get; set; }
    public string Value { get; set; }
}

public enum FilterType
{
    IsBetween,
    Is,
    IsNot
}

public class GetViewConfigResponse
{
    public List<Filter> Filters { get; set; }
}

public class ViewConfigService : Service
{
    public object Get(GetViewConfig request)
    {
        return null;
    }
}

Show all the values for the FilterType on the metadata page. Is there a way to do this?

Upvotes: 0

Views: 406

Answers (1)

mythz
mythz

Reputation: 143319

Not on the metadata pages, but you can view this using the Swagger API and the [ApiAllowableValues] attribute, e.g:

[Api("Service Description")]
[Route("/swagger/{Name}", "GET", Summary = @"GET Summary", Notes = "GET Notes")]
public class MyRequestDto
{
    [ApiMember(Name="Name", Description = "Name Description", 
               ParameterType = "path", DataType = "string", IsRequired = true)]
    [ApiAllowableValues("Name", typeof(Color))] //Enum
    public string Name { get; set; }
}

Upvotes: 3

Related Questions