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

I'm getting a weird error, and I can't seem to google the right things, as I'm finding no help online. I am writing a script that converts swagger files to typescript. The error message is the one in the title, and sadly that's all the information I have. I will post the code below, and the part where (I believe) the message is coming from:

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)')
    }
}

I think the error is coming from the try block, the very last argument (-i ${response}). Am I able to use the parameter of the function in this way, or can I only use strings in cli commands? I'm at a loss



Solution 1:[1]

After multiple days of trying, here is the full code that works for anyone who may need it:

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");
    }
}

This pulls the json from the desired url, and writes it to a file. This file is then used as the destination for -i, and once the conversion is complete, the json is deleted in the finally block.

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 TraktorJack