smoothgrips
smoothgrips

Reputation: 417

Swashbuckle: Swagger UI: Custom API Action

We're using Swashbuckle/Swagger for our API documentation, installed via Nuget. Our Web API 2 controllers have a search endpoint:

[HttpPost]
[AcceptVerbs("POST")]
[Route("api/v1/controllername/search")]
public IHttpActionResult Search([FromBody] SearchModel model)
{
    // Code here...
}

When I run the project and navigate to the Swagger UI, it picks up all of the other actions (e.g. Get, Put, Post, ect...) but the documentation for the search action is not there in the UI. I've been Googling and am coming up empty as to how to make it so that the search action shows up in the Swagger UI. Any thoughts?

Thanks!

Upvotes: 2

Views: 1136

Answers (1)

smoothgrips
smoothgrips

Reputation: 417

So, the issue here is the [HttpPost] attribute. Once I removed that attribute, the endpoint showed up perfect in Swagger.

Upvotes: 1

Related Questions