Files
jiebanke/backend/test-swagger.js
mapleaf 0cad74b06f feat(backend): 添加 Swagger 文档并优化认证接口
- 在 .env 文件中添加 ENABLE_SWAGGER 环境变量
- 在 app.js 中集成 Swagger UI
- 重构 auth 路由,添加请求参数验证
- 更新 API 文档,遵循 OpenAPI 3.0 规范
-优化认证接口的错误处理和响应格式
2025-08-30 15:29:51 +08:00

30 lines
765 B
JavaScript
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

const http = require('http');
// 发送请求到Swagger UI
const options = {
hostname: 'localhost',
port: 3001,
path: '/api-docs/',
method: 'GET'
};
const req = http.request(options, (res) => {
console.log(`状态码: ${res.statusCode}`);
res.on('data', (chunk) => {
// 检查响应中是否包含Swagger UI的关键字
if (chunk.toString().includes('Swagger UI')) {
console.log('Swagger UI 已成功启动并运行');
} else {
console.log('收到响应但可能不是Swagger UI页面');
}
// 只输出前200个字符来检查内容
console.log('响应前200字符:', chunk.toString().substring(0, 200));
});
});
req.on('error', (error) => {
console.error('请求出错:', error.message);
});
req.end();