有没有办法让ServiceStack元数据页面显示枚举请求或响应属性的所有选项

时间:2014-02-27 14:54:38

标签: servicestack

我希望能够拥有以下代码

    [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;
    }
}

在元数据页面上显示FilterType的所有值。有没有办法做到这一点?

1 个答案:

答案 0 :(得分:3)

不在元数据页面上,但您可以使用Swagger API[ApiAllowableValues]属性查看此内容,例如:

[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; }
}