Skip to content

Commit

Permalink
feat: migrate to latest generator enabling usage of reusable hooks (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
derberg authored May 14, 2020
1 parent b1b592a commit f3b3a1d
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 8 deletions.
2 changes: 1 addition & 1 deletion .tp-config.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"generator": ">=0.41.0 <2.0.0",
"generator": ">=0.46.0 <2.0.0",
"parameters": {
"actuator": {
"description": "If present, it adds the dependencies for spring-boot-starter-web, spring-boot-starter-actuator and micrometer-registry-prometheus.",
Expand Down
13 changes: 6 additions & 7 deletions hooks/post-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,8 @@ const ScsLib = require('../lib/scsLib.js');

const sourceHead = '/src/main/java/';

module.exports = register => {
register('generate:after', generator => {
module.exports = {
'generate:after': generator => {
const scsLib = new ScsLib();
const asyncapi = generator.asyncapi;
let sourcePath = generator.targetDir + sourceHead;
Expand Down Expand Up @@ -76,19 +76,18 @@ module.exports = register => {
const schemas = asyncapi.components().schemas();
//console.log("schemas: " + JSON.stringify(schemas));

for (let schema in schemas) {
for (const schema in schemas) {
let javaName = _.camelCase(schema);
javaName = _.upperFirst(javaName);

if (javaName !== schema) {
let oldPath = path.resolve(sourcePath, schema + ".java");
let newPath = path.resolve(sourcePath, javaName + ".java");
const oldPath = path.resolve(sourcePath, `${schema }.java`);
const newPath = path.resolve(sourcePath, `${javaName }.java`);
fs.renameSync(oldPath, newPath);
// console.log("Renamed class file " + schema + " to " + javaName);
}
}


// This renames schema objects according to the title field. By default we won't do this, we might add this as an option.

//const schemas = asyncapi.components().schemas();
Expand All @@ -109,6 +108,6 @@ module.exports = register => {
}
}
*/
});
}
};

0 comments on commit f3b3a1d

Please sign in to comment.