admin管理员组文章数量:1277512
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.
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.
Share Improve this question asked Feb 25, 2014 at 8:27 user3350118user3350118 711 silver badge2 bronze badges4 Answers
Reset to default 4swagger-ui has the parameter docExpansion. 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.
To collapse swagger ui by default, you can use :
app = FastAPI(
swagger_ui_parameters = {"docExpansion":"none"},
...
)
for collapse all endpoints by default:
const express = require("express");
const app = express();
const swaggerUi = require('swagger-ui-express');
const swaggerDoc = require('./swagger-output.json');
app.use('/doc', swaggerUi.serve, swaggerUi.setup(swaggerDoc, false, { docExpansion: 'none' }));
Swagger-UI.js is generated it would be very hard to modify Swagger UI by modifying this file.
If you want to customize SwaggerUI you should clone the github repository https://github./swagger-api/swagger-ui/ then modify files and rebuild it (you will then get a modified Swagger-UI.js and all other files).
Swagger-UI is posed of different views, each view having a js file and a handlebars template. In your use case I'll try to modify these files:
- src/main/template/signature.handlebars
- src/main/javascript/view/SignatureView.js
本文标签: javascriptCollapseExpand Swagger Response Model ClassStack Overflow
版权声明:本文标题:javascript - CollapseExpand Swagger Response Model Class - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1741277847a2369835.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论