I have the following route configured in my ASP.NET Web API 2 Project:
config.Routes.MapHttpRoute(
name: "1MandatoryStringParameter",
routeTemplate: "api/{controller}/{data}",
defaults: null,
constraints: new { data = @".+?" }
It is used with the following controller method (notice the ArrayInput attribute):
[ArrayInput("data",Separator = ',')]
public async Task<IHttpActionResult> Get(int[] data)
{
...
}
I would like to use Attribute routing instead.
I tried to replace the call to MapHttpRoute with the following attributes:
[HttpGet]
[Route("api/ActionsForItemTypesList/{data:regex(.+?)}", Name = "1MandatoryStringParameter")]
Out of the box it does not work. I can't reach my method with an URL like:
api/ActionsForItemTypesList/1,2
If get a 404 Method not found.
This is working fine with route configuration.
Any help appreciated.
EDIT : fixed the client URL.
EDIT 2 : This is an ApiExplorer Issue (Swashbuckle leverage ApiExplorer)
If I modify the Route attribute and remove the parameter (ie. {data}) the ApiDescription becomes available.