Swagger-codegen: error: ignored arguments: 'Object'

Swagger-codegen: error: ignored arguments: 'Object'

我遇到了一个奇怪的错误,而且我似乎无法 google 正确的事情,因为我在网上找不到任何帮助。我正在编写一个脚本,将 swagger 文件转换为打字稿。错误信息就是标题中的那个,遗憾的是我只有这些信息。我将 post 下面的代码,以及(我相信)消息来自的部分:

async function getJson(){
    const agent = new https.Agent({  
        rejectUnauthorized: false
      });
      return axios.get('https://common-customer-bpms.dev.havida.net/v3/api-docs', { httpsAgent: agent })
        .then(response => generateSwagger(response))
}
getJson();

async function generateSwagger(response) {
    try {
        execSync(`java -jar ..\swagger-codegen-cli.jar generate -l typescript-angular -o .\projects\common\src -i ${response}`);
    } catch (error){
        console.log(error);
        console.log('You must have Java installed! You may have to change JAVA_HOME location & path (Ex: set JAVA_HOME=`C:\Programme\Java\jre1.8.0_321`), (set PATH=${JAVA_HOME}/bin:$PATH)')
    }
}

我认为错误来自 try 块,即最后一个参数 (-i ${response})。我能以这种方式使用函数的参数,还是只能在 cli 命令中使用字符串?我很茫然

经过多天的尝试,这里是适用于可能需要它的任何人的完整代码:

import axios from 'axios';
import https from 'node:https';
import {execSync} from 'child_process';
import fs from 'fs/promises';

async function getJson(){
    const agent = new https.Agent({  
        rejectUnauthorized: false
      });
      return axios.get('https://common-customer-bpms.dev.havida.net/v3/api-docs', { httpsAgent: agent })
        .then(response => fs.writeFile("temp.json", JSON.stringify(response.data), (error)=>{console.log(error)}))
        .then(() => generateSwagger())
}
getJson();

async function generateSwagger() {
    try {
        execSync(`java -jar ..\swagger-codegen-cli.jar generate -l typescript-angular -i temp.json -o .\projects\common\src\lib`);
    } catch (error){
        console.log(error);
        console.log('You must have Java installed! You may have to change JAVA_HOME location & path (Ex: set JAVA_HOME=`C:\Programme\Java\jre1.8.0_321`), (set PATH=${JAVA_HOME}/bin:$PATH)')
    } finally {
        fs.unlink("temp.json");
    }
}

这会从所需的 url 中提取 json,并将其写入文件。该文件然后用作 -i 的目标,一旦转换完成,json 将在 finally 块中删除。