I've encountered a strange error that I can't seem to troubleshoot through online searches. My current project involves converting swagger files to typescript using a script. The error message simply states what's in the title, and unfortunately, that's all the information I have at the moment. Below, I will provide the code snippet where I suspect the issue lies:
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)')
}
}
My suspicion is that the error arises from the try
block due to the usage of the parameter (${response}) in the command. Is it valid to use function parameters like this in CLI commands, or should I strictly stick to string inputs? Any advice would be appreciated as I'm stuck on this problem.