25 lines
895 B
JavaScript
25 lines
895 B
JavaScript
/**
|
||
* 导出Swagger文档到JSON文件,用于导入Apifox
|
||
*/
|
||
const fs = require('fs');
|
||
const path = require('path');
|
||
const swaggerSpecs = require('./swagger');
|
||
|
||
// 确保输出目录存在
|
||
const outputDir = path.join(__dirname, 'api-docs');
|
||
if (!fs.existsSync(outputDir)) {
|
||
fs.mkdirSync(outputDir, { recursive: true });
|
||
}
|
||
|
||
// 导出Swagger文档到JSON文件
|
||
const outputPath = path.join(outputDir, 'swagger.json');
|
||
fs.writeFileSync(outputPath, JSON.stringify(swaggerSpecs, null, 2));
|
||
|
||
console.log(`Swagger文档已导出到: ${outputPath}`);
|
||
console.log('现在您可以将此文件导入到Apifox中:');
|
||
console.log('1. 打开Apifox应用');
|
||
console.log('2. 选择您的项目');
|
||
console.log('3. 点击"导入"按钮');
|
||
console.log('4. 选择"导入OpenAPI(Swagger)"');
|
||
console.log('5. 选择刚才导出的swagger.json文件');
|
||
console.log('6. 按照Apifox的导入向导完成导入'); |