diff --git a/hooks/inverseOperations.js b/hooks/01_inverseOperations.js similarity index 100% rename from hooks/inverseOperations.js rename to hooks/01_inverseOperations.js diff --git a/hooks/removeNotRelevantParts.js b/hooks/02_removeNotRelevantParts.js similarity index 100% rename from hooks/removeNotRelevantParts.js rename to hooks/02_removeNotRelevantParts.js diff --git a/hooks/03_removeNonObjectSchemas.js b/hooks/03_removeNonObjectSchemas.js new file mode 100644 index 000000000..52a4ff234 --- /dev/null +++ b/hooks/03_removeNonObjectSchemas.js @@ -0,0 +1,17 @@ +const fs = require('fs'); +const path = require('path'); + +module.exports = { + 'generate:after': generator => { + const asyncapi = generator.asyncapi; + const schemas = asyncapi.allSchemas(); + + for (let [key, value] of schemas) { + if (value.type() !== 'object') { + try { + fs.unlinkSync(path.resolve(generator.targetDir, `src/main/java/com/asyncapi/model/${key}.java`)); + } catch (e) {} + } + } + } +}; \ No newline at end of file diff --git a/hooks/fixModelFileNames.js b/hooks/04_fixModelFileNames.js similarity index 92% rename from hooks/fixModelFileNames.js rename to hooks/04_fixModelFileNames.js index b6a3cf719..e412db254 100644 --- a/hooks/fixModelFileNames.js +++ b/hooks/04_fixModelFileNames.js @@ -15,7 +15,7 @@ module.exports = { } } for (let [key, value] of schemas) { - if (_.upperFirst(key) !== key) { + 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`)); } diff --git a/hooks/packageProcessor.js b/hooks/05_packageProcessor.js similarity index 100% rename from hooks/packageProcessor.js rename to hooks/05_packageProcessor.js