简体   繁体   English

Swagger UI嵌套可扩展分组

[英]Swagger UI nested expandable groupings

I am using SwaggerUI for documenting API endpoints. 我使用SwaggerUI来记录API端点。 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. 因此,例如,您有一个Pet组,可以展开,以显示Cat和Dog控制器,然后可以扩展它们以显示其各自的操作。

I have tried using Tags to accomplish this, but the best I can get is all operations grouped under one expandable group. 我已经尝试使用Tags来实现这一目标,但我能得到的最好的是所有操作分组在一个可扩展组下。

Does anyone know if this is possible with the standard swaggerUI? 有谁知道标准的swaggerUI是否可行? Or would I need to create custom HTML to accomplish this? 或者我需要创建自定义HTML来实现这一目标吗?

I assume you are using Swashbuckle? 我假设你使用的是Swashbuckle? What you need is to implement IDocumentFilter. 你需要的是实现IDocumentFilter。 Look in to the tags om the Swagger 2.0 Spec . 查看Swagger 2.0 Spec的标签。

From the docs: 来自文档:

DocumentFilter 的DocumentFilter

Post-modify the entire Swagger document by wiring up one or more Document filters. 通过连接一个或多个Document过滤器来修改整个Swagger文档。

IDocumentFilter has the following interface: IDocumentFilter具有以下接口:

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

This gives full control to modify the final SwaggerDocument. 这提供了完全控制来修改最终的SwaggerDocument。 You can gain additional context from the provided SwaggerDocument (eg version) and IApiExplorer . 您可以从提供的SwaggerDocument (例如版本)和IApiExplorer获得额外的上下文。 You should have a good understanding of the Swagger 2.0 spec. 您应该对Swagger 2.0规范有一个很好的理解。 before using this option. 在使用此选项之前。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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