@novo-learning/novo-sdk
Version:
SDK for the Novolanguage Speech Analysis API
29 lines (26 loc) • 1.09 kB
JavaScript
// fix for error in swagger documentation: https://stackoverflow.com/questions/54803837/openapi-required-property-in-nested-objects-not-working
// eslint-disable-next-line @typescript-eslint/no-var-requires
const fs = require('fs');
const swaggerPath = './src/clients/data-api/generated/api.ts';
fs.readFile(swaggerPath, 'utf8', (err, fileContents) => {
if (err) {
console.log('File read failed:', err);
return;
}
const result = fileContents
.replace(
' ...options.headers}',
'...options.headers, ...localVarFormParams.getHeaders() /*added by postprocessor, see https://github.com/OpenAPITools/openapi-generator/issues/8002/ */ }',
)
.replace(
"localVarFormParams.append('audio', audio as any);",
"localVarFormParams.append('audio', audio as any, 'audio'); /*added by postprocessor, see https://maximorlov.com/send-a-file-with-axios-in-nodejs/ */",
);
fs.writeFile(swaggerPath, result, (err) => {
if (err) {
console.log('Error writing file', err);
} else {
console.log('Successfully wrote file');
}
});
});