Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Collapse/Expand Swagger Response Model Class

I'm using Swagger API documentation for my rest services. I have successfully integrated Swagger with my code and it works.

But I have a requirement to format the Swagger UI. Since the number of response classes are many in my project, the Swagger page looks very lengthy and the user has to scroll down a lot to view information.

So I want to collapse my response model classes and expand it when the user clicks the class. Is there a way to do it and if so where and what changes have to be made. I tried editing the Swagger-UI.js file but I could not achieve the needed output.

Please let me know and thanks in advance.

like image 834
user3350118 Avatar asked Feb 25 '14 08:02

user3350118


1 Answers

swagger-ui has the parameter docExpansion (see https://github.com/swagger-api/swagger-ui#parameters). Default is list, but if set it to none in the defaults section in src/core/index.js :

docExpansion: "none"

it will work and collapse everything when loading the site.

like image 128
user1981275 Avatar answered Oct 04 '22 16:10

user1981275