0

please assist with the attribute/startup config needed to display an endpoint under a different controller....

Swagger UI example

For example, I want to modify my Swagger UI page to have all the endpoints under the Home controller, even though in code they are in separate controllers. (I want to keep it this way).

In code looks as follows:

[Route("api/v{v:apiVersion}/[controller]")]
HomeController


[HttpPost]
[Route("ActionMethod3")]
public async Task ActionMethod3()

Then

[Route("api/v{v:apiVersion}/[controller]")]
FirstController


[HttpGet]
[Route("ActionMethod1")]
public async Task ActionMethod1()

Lastly

[Route("api/v{v:apiVersion}/[controller]")]
SecondController

[HttpPost]
[Route("ActionMethod2")]
public async Task ActionMethod2()

So my question again is how to move an endpoint and path so the UI can display them all under "Home" even though they are in separate controllers in the code base.

Home

/api/v1/home/actionmethod1

/api/v1/home/actionmethod2

/api/v1/home/actionmethod3


I'm using .Net Core 2.2 and Swashbuckle.AspNetCore v5.5 Thanks in advance for any assistance.

Helen
  • 87,344
  • 17
  • 243
  • 314
  • 1
    You can decorate the controller methods using `SwaggerOperation` or create custom attribute or even make use of `ApiExplorerSettings` attribute to group them and show them in swagger. Please refer https://stackoverflow.com/a/43490002 – Govind Aug 12 '20 at 17:59
  • Thank you - this was exactly what I was looking for – Ryan McCartney Aug 18 '20 at 13:35

0 Answers0