feat: 修改后端apiclient生成逻辑
fix: 修复debugger获取flag失败的问题 refactor: 重新编写debugger前后端逻辑
This commit is contained in:
@@ -279,10 +279,18 @@ async function postProcessApiClient(): Promise<void> {
|
||||
async function generateApiClient(): Promise<void> {
|
||||
console.log('Generating API client...');
|
||||
try {
|
||||
const npxCommand = getCommand('npx');
|
||||
await execAsync(`${npxCommand} nswag openapi2tsclient /input:http://localhost:5000/swagger/v1/swagger.json /output:src/APIClient.ts`);
|
||||
console.log('✓ API client generated successfully');
|
||||
|
||||
const url = 'http://127.0.0.1:5000/GetAPIClientCode';
|
||||
const response = await fetch(url);
|
||||
if (!response.ok) {
|
||||
throw new Error(`Failed to fetch API client code: ${response.status} ${response.statusText}`);
|
||||
}
|
||||
const code = await response.text();
|
||||
|
||||
// 写入 APIClient.ts
|
||||
const filePath = 'src/APIClient.ts';
|
||||
fs.writeFileSync(filePath, code, 'utf8');
|
||||
console.log('✓ API client code fetched and written successfully');
|
||||
|
||||
// 添加后处理步骤
|
||||
await postProcessApiClient();
|
||||
} catch (error) {
|
||||
|
Reference in New Issue
Block a user