Swagger UI nested expandable groupings

瘦欲@ 提交于 2019-12-24 06:34:48

问题


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?


回答1:


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 (e.g. version) and IApiExplorer. You should have a good understanding of the Swagger 2.0 spec. before using this option.



来源:https://stackoverflow.com/questions/37703251/swagger-ui-nested-expandable-groupings

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!