Skip to content

Commit f3b3a1d

Browse files
authored
feat: migrate to latest generator enabling usage of reusable hooks (#34)
1 parent b1b592a commit f3b3a1d

File tree

2 files changed

+7
-8
lines changed

2 files changed

+7
-8
lines changed

.tp-config.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
{
2-
"generator": ">=0.41.0 <2.0.0",
2+
"generator": ">=0.46.0 <2.0.0",
33
"parameters": {
44
"actuator": {
55
"description": "If present, it adds the dependencies for spring-boot-starter-web, spring-boot-starter-actuator and micrometer-registry-prometheus.",

hooks/post-process.js

+6-7
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@ const ScsLib = require('../lib/scsLib.js');
66

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

9-
module.exports = register => {
10-
register('generate:after', generator => {
9+
module.exports = {
10+
'generate:after': generator => {
1111
const scsLib = new ScsLib();
1212
const asyncapi = generator.asyncapi;
1313
let sourcePath = generator.targetDir + sourceHead;
@@ -76,19 +76,18 @@ module.exports = register => {
7676
const schemas = asyncapi.components().schemas();
7777
//console.log("schemas: " + JSON.stringify(schemas));
7878

79-
for (let schema in schemas) {
79+
for (const schema in schemas) {
8080
let javaName = _.camelCase(schema);
8181
javaName = _.upperFirst(javaName);
8282

8383
if (javaName !== schema) {
84-
let oldPath = path.resolve(sourcePath, schema + ".java");
85-
let newPath = path.resolve(sourcePath, javaName + ".java");
84+
const oldPath = path.resolve(sourcePath, `${schema }.java`);
85+
const newPath = path.resolve(sourcePath, `${javaName }.java`);
8686
fs.renameSync(oldPath, newPath);
8787
// console.log("Renamed class file " + schema + " to " + javaName);
8888
}
8989
}
9090

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

9493
//const schemas = asyncapi.components().schemas();
@@ -109,6 +108,6 @@ module.exports = register => {
109108
}
110109
}
111110
*/
112-
});
111+
}
113112
};
114113

0 commit comments

Comments
 (0)