diff --git a/hooks/05_fixModelFileNames.js b/hooks/05_fixModelFileNames.js index e412db254..0c915794f 100644 --- a/hooks/05_fixModelFileNames.js +++ b/hooks/05_fixModelFileNames.js @@ -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)); + } }; \ No newline at end of file diff --git a/template/src/main/java/com/asyncapi/model/$$schema$$.java b/template/src/main/java/com/asyncapi/model/$$objectSchema$$.java similarity index 100% rename from template/src/main/java/com/asyncapi/model/$$schema$$.java rename to template/src/main/java/com/asyncapi/model/$$objectSchema$$.java