简体   繁体   中英

Swagger UI nested expandable groupings

I am using SwaggerUI for documenting API endpoints. Currently they are grouped by controller name, in one long list. You can then expand each controller to view the operations. Everything standard.

What I would like to do, is group the controllers under common expandable groups.

So for example, you have a Pet group, which can be expanded, to reveal Cat and Dog controllers, which can then in turn be expanded to show their respective operations.

I have tried using Tags to accomplish this, but the best I can get is all operations grouped under one expandable group.

Does anyone know if this is possible with the standard swaggerUI? Or would I need to create custom HTML to accomplish this?

I assume you are using Swashbuckle? What you need is to implement IDocumentFilter. Look in to the tags om the Swagger 2.0 Spec .

From the docs:

DocumentFilter

Post-modify the entire Swagger document by wiring up one or more Document filters.

IDocumentFilter has the following interface:

void Apply(SwaggerDocument swaggerDoc, SchemaRegistry schemaRegistry, IApiExplorer apiExplorer);

This gives full control to modify the final SwaggerDocument. You can gain additional context from the provided SwaggerDocument (eg version) and IApiExplorer . You should have a good understanding of the Swagger 2.0 spec. before using this option.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM