2025-09-18
app后端搭建
This commit is contained in:
43
config/swagger.js
Normal file
43
config/swagger.js
Normal file
@@ -0,0 +1,43 @@
|
||||
const swaggerUi = require('swagger-ui-express');
|
||||
|
||||
const swaggerJsdoc = require('swagger-jsdoc');
|
||||
|
||||
// Swagger定义
|
||||
const options = {
|
||||
definition: {
|
||||
openapi: '3.0.0',
|
||||
info: {
|
||||
title: '融豆商城 API',
|
||||
version: '1.0.0',
|
||||
description: '融豆商城后端API文档',
|
||||
contact: {
|
||||
name: '技术支持',
|
||||
email: 'support@example.com'
|
||||
},
|
||||
},
|
||||
servers: [
|
||||
{
|
||||
url: '/api',
|
||||
description: 'API服务器'
|
||||
}
|
||||
],
|
||||
components: {
|
||||
securitySchemes: {
|
||||
bearerAuth: {
|
||||
type: 'http',
|
||||
scheme: 'bearer',
|
||||
bearerFormat: 'JWT'
|
||||
}
|
||||
}
|
||||
},
|
||||
security: [{
|
||||
bearerAuth: []
|
||||
}]
|
||||
},
|
||||
// API文档扫描路径
|
||||
apis: ['./docs/schemas/*.js', './docs/apis/*.js', './routes/*.js', './admin/routes/*.js'],
|
||||
};
|
||||
|
||||
const specs = swaggerJsdoc(options);
|
||||
|
||||
module.exports = {specs,swaggerUi};
|
||||
Reference in New Issue
Block a user