2

Building out an API layer in C#, and using both Swagger and Swashbuckle for the documentation. So far, I'm loving it! Just one question.

By default, the layering of API's is two deep. Example... these are the currently available API's, with Access Integration: Integration Settings expanded:

enter image description here

What I'm trying to figure out is how to have a single grouping of Access Integration, which when clicked, would reveal these controllers:

  • Integration
  • Sync Users
  • Sync Doors
  • Access Events

And then you could drill into any one of the controllers to see the methods within them. So, basically, three layers instead of two.

Is this possible? I've been looking at this question: Grouping of API methods in documentation - is there some custom attribute, but it's not getting me there. And I've been trying to figure out how to use this:

c.GroupActionsBy(apiDesc => apiDesc.HttpMethod.ToString());

But I'm not finding any examples of how to use it.

I tried this:

[SwaggerOperation(Tags = new[] { "Access Integration", "Sync Doors" })]

and

[SwaggerOperation(Tags = new[] { "Access Integration", "Sync Users" })]

But that just listed each controller twice, once under "Access Integration" and again under "Sync Users".

Casey Crookston
  • 13,016
  • 24
  • 107
  • 193
  • Possible duplicate of [Adding Nested Grouping Sections in the UI for Actions within a Controller](https://stackoverflow.com/questions/45154322/adding-nested-grouping-sections-in-the-ui-for-actions-within-a-controller) and [Swagger UI Multi level tagging](https://stackoverflow.com/questions/41800330/swagger-ui-multi-level-tagging) – Helen Mar 06 '18 at 18:18
  • The standard Swagger UI does not support nested groups (tags). If you need this, you'll need to modify the Swagger UI source code to implement your custom grouping logic. – Helen Mar 06 '18 at 18:20

1 Answers1

0

Just like @Helen pointed out in the comments:

Swagger UI does not support nested groups (tags). If you need this, you'll need to modify the source code to implement your custom grouping logic.

In theory the customization is possible (Swagger UI is Open Source) but you will start diverging from the main branch, also there is the integration with swashbuckle. It can get very messy!



But if you Upgrade to the latest UI (3.x) you will get filters, here are some examples:

...and there are many more hidden gems that can help you:
https://github.com/swagger-api/swagger-ui/blob/master/docs/usage/configuration.md#display

Helder Sepulveda
  • 15,500
  • 4
  • 29
  • 56