Skip to content

Commit

Permalink
fix: remove non-object generated classes (#62)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenischev authored Jun 17, 2020
1 parent d98713c commit 53de017
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 1 deletion.
File renamed without changes.
File renamed without changes.
17 changes: 17 additions & 0 deletions hooks/03_removeNonObjectSchemas.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
const fs = require('fs');
const path = require('path');

module.exports = {
'generate:after': generator => {
const asyncapi = generator.asyncapi;
const schemas = asyncapi.allSchemas();

for (let [key, value] of schemas) {
if (value.type() !== 'object') {
try {
fs.unlinkSync(path.resolve(generator.targetDir, `src/main/java/com/asyncapi/model/${key}.java`));
} catch (e) {}
}
}
}
};
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ module.exports = {
}
}
for (let [key, value] of schemas) {
if (_.upperFirst(key) !== key) {
if (_.upperFirst(key) !== key && value.type() === 'object') {
fs.renameSync(path.resolve(generator.targetDir, `src/main/java/com/asyncapi/model/${key}.java`),
path.resolve(generator.targetDir, `src/main/java/com/asyncapi/model/${_.upperFirst(key)}.java`));
}
Expand Down
File renamed without changes.

0 comments on commit 53de017

Please sign in to comment.