Search code examples
swaggerswashbuckleazure-api-apps

Edit Swagger output for API App using Swashbuckler


I have created an API App and run it to see the Get, Put etc methods in my Controller are displayed correctly in my browser using Swagger.
These methods were created by the Visual Studio template.

When I add a new method to my controller; e.g.

    [SwaggerOperation("GoFish")]
    [SwaggerResponse(HttpStatusCode.OK)]
    [SwaggerResponse(HttpStatusCode.NotFound)]
    public string GoFish()
    {
        return "Flounder";
    }

And then rebuild/run I do not see this method on my Swagger page.

How do I add methods to the API that Swagger can display?


Solution

  • Changing the WebAppConfig gets the Controller methods to display in SwaggerUI.

    Change:

    routeTemplate: "api/{controller}/{id}",
    

    to:

    routeTemplate: "api/{controller}/{action}/{id}",