60 lines
2.2 KiB
C#
60 lines
2.2 KiB
C#
using Microsoft.OpenApi.Models;
|
|
using Swashbuckle.AspNetCore.SwaggerGen;
|
|
|
|
namespace OBSBoardsApi.Swagger
|
|
{
|
|
public class ParameterFilterSwagger : IParameterFilter
|
|
{
|
|
public void Apply(OpenApiParameter parameter, ParameterFilterContext context)
|
|
{
|
|
switch (parameter.Name)
|
|
{
|
|
case "Filters":
|
|
parameter.Name = "Filter";
|
|
parameter.Schema.Type = "string";
|
|
parameter.Examples = new Dictionary<string, OpenApiExample>
|
|
{
|
|
{
|
|
"One column",
|
|
new OpenApiExample()
|
|
{
|
|
Description = "" +
|
|
"[column]~[operator]~[value]" +
|
|
"<br /><br />" +
|
|
"e.g. name~contains~'test'"
|
|
}
|
|
},
|
|
{
|
|
"Many columns",
|
|
new OpenApiExample()
|
|
{
|
|
Description = "" +
|
|
"([column1]~[operator1]~[value1]~[logic]~[column2]~[operator2]~[value2]~...)" +
|
|
"<br /><br />" +
|
|
"e.g. (name1~contains~'test1'~and~name2~contains~'test2')"
|
|
}
|
|
}
|
|
};
|
|
break;
|
|
case "Sorts":
|
|
parameter.Name = "Sort";
|
|
parameter.Schema.Type = "string";
|
|
parameter.Examples = new Dictionary<string, OpenApiExample>
|
|
{
|
|
{
|
|
"One column",
|
|
new OpenApiExample()
|
|
{
|
|
Description = "" +
|
|
"[column]-[direction]" +
|
|
"<br /><br />" +
|
|
"e.g. name-asc"
|
|
}
|
|
}
|
|
};
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|