Skip to content

Commit

Permalink
fix: handling of anonymous objects (#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
Tenischev authored Oct 13, 2020
1 parent 43599eb commit 70ff6dc
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
24 changes: 4 additions & 20 deletions hooks/05_fixModelFileNames.js
Original file line number Diff line number Diff line change
@@ -1,24 +1,8 @@
const fs = require('fs');
const path = require('path');
const _ = require('lodash');

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

for (let [key, value] of messages) {
if (_.upperFirst(key) !== key) {
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`));
}
}
for (let [key, value] of schemas) {
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`));
}
}
}
'setFileTemplateName': (generator, hookArguments) => {
const currentFilename = hookArguments.originalFilename ;
return _.upperFirst(_.camelCase(currentFilename));
}
};

0 comments on commit 70ff6dc

Please sign in to comment.