完善保险端前后端和养殖端小程序

This commit is contained in:
xuqiuyun
2025-09-22 19:09:45 +08:00
parent 02a25515a9
commit 325c114c38
256 changed files with 48348 additions and 4444 deletions

View File

@@ -0,0 +1,38 @@
/**
* API文档路由
* @file api-docs.js
* @description 提供Swagger API文档访问
*/
const express = require('express');
const swaggerUi = require('swagger-ui-express');
const swaggerSpecs = require('../swagger-config');
const router = express.Router();
// Swagger UI配置
const swaggerUiOptions = {
customCss: '.swagger-ui .topbar { display: none }',
customSiteTitle: '智能预警系统 API 文档',
swaggerOptions: {
docExpansion: 'none',
defaultModelsExpandDepth: 2,
defaultModelExpandDepth: 2,
displayRequestDuration: true,
filter: true,
showExtensions: true,
showCommonExtensions: true
}
};
// 提供JSON格式的API规范
router.get('/swagger.json', (req, res) => {
res.setHeader('Content-Type', 'application/json');
res.send(swaggerSpecs);
});
// 提供Swagger UI界面
router.use('/', swaggerUi.serve);
router.get('/', swaggerUi.setup(swaggerSpecs, swaggerUiOptions));
module.exports = router;