WebApi documentation not recognizing endpoints

320 Views Asked by At

I have multiple controller endpoints with routes like this:

[Route("api/myobjects/action1/action2/{objectIds}")]

They all have method signatures like this (access modifier and return type omitted):

Post([ModelBinder(typeof(CommaDelimitedArrayModelBinder))] int[] objectIds)

The custom modelbinder allows me to post to the endpoint like so:

../api/myobjects/action1/action2/1,2,3

This works great! However, all these methods are ignored by the help pages documentation generating process.

If I remove the modelbinder attribute like so:

Post(int[] objectIds)

It still does not work. Only if I add [FromUri] to the parameter and delete {objectIds} from the route attribute it will work:

Post([FromUri] int[] objectIds)

But this generates a uri that is unwanted like so:

../api/myobjects/action1/action2?objectIds[0]={objectIds[0]}&objectIds[1]={objectIds[1]}

How can I get the help pages documentation process to recognise my endpoints?

1

There are 1 best solutions below

2
On

You need to update HelpPageConfig like config.SetActualResponseType(typeof(ObjectType), "Object", "MethodName");

using this you can enable help for respective URL in web api