-
-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: handling of anonymous objects (#88)
- Loading branch information
Showing
2 changed files
with
4 additions
and
20 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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)); | ||
} | ||
}; |
File renamed without changes.