Skip to content

Commit

Permalink
enhance nodejs-openapi action
Browse files Browse the repository at this point in the history
  • Loading branch information
TimurRin committed Sep 21, 2024
1 parent 860a8cf commit 159ee15
Showing 1 changed file with 17 additions and 5 deletions.
22 changes: 17 additions & 5 deletions src/actions/nodejs-openapi.ts
Original file line number Diff line number Diff line change
Expand Up @@ -477,13 +477,21 @@ function generateImportsCodePart(importsDict?: Record<string, ImportsData>) {
.sort()
.forEach((importPath) => {
const importData = importsDict[importPath];
let importCodePart = "";
if (importData.defaultImport) {
importsCodePart += `import ${importData.defaultImport} from "${importPath}";\n`;
importCodePart += importData.defaultImport;
}
if (importData.otherImports) {
importData.otherImports.forEach((importName) => {
importsCodePart += `import { ${importName} } from "${importPath}";\n`;
let importOtherCodePart = "";
importData.otherImports.sort().forEach((importName) => {
importOtherCodePart += `${importOtherCodePart ? ", " : ""}${importName}`;
});
if (importOtherCodePart) {
importCodePart += `${importCodePart ? ", " : ""}{ ${importOtherCodePart} }`;
}
}
if (importCodePart) {
importsCodePart += `import ${importCodePart} from "${importPath}";\n`;
}
});
return importsCodePart;
Expand Down Expand Up @@ -712,8 +720,12 @@ export async function generateNodejsOpenapiFiles(development: AncaDevelopment) {

let controllerContent = "";

addImport(responsesControllerImport, "express", "Request");
addImport(responsesControllerImport, "express", "Response");
addImport(responsesControllerImport, "express", "Request", {
isModule: true,
});
addImport(responsesControllerImport, "express", "Response", {
isModule: true,
});
addImport(
responsesControllerImport,
`../services/${fileName}.js`,
Expand Down

0 comments on commit 159ee15

Please sign in to comment.