File tree Expand file tree Collapse file tree 1 file changed +57
-0
lines changed
Expand file tree Collapse file tree 1 file changed +57
-0
lines changed Original file line number Diff line number Diff line change 1+ const fs = require ( 'fs' ) ;
2+
3+ function checkForAnonymousSchemaObjects ( generator ) {
4+ const modelPath = generator . targetDir + '/src/main/java/com/asyncapi/model' ;
5+ var anonymousPresent = false ;
6+ var anonymousFileNames = [ ] ;
7+ fs . readdirSync ( modelPath ) . forEach ( file => {
8+ if ( file . startsWith ( 'AnonymousSchema' ) ) {
9+ anonymousPresent = true ;
10+ anonymousFileNames . push ( generator . templateParams [ 'userJavaPackage' ] . replace ( / \. / g, '/' ) + '/model/' + file ) ;
11+ }
12+ } ) ;
13+ if ( anonymousPresent ) {
14+ console . log ( `Following AnonymousSchema classes were generated in DTO classes:
15+ ${ anonymousFileNames . toString ( ) } \n
16+ This may be a result of explicit (composition, inheritance, array items) Schema Object definition e.g.\n
17+ schemas:
18+ NamedObject:
19+ type: object
20+ properties:
21+ field:
22+ type: array
23+ items:
24+ type: object #Anonymous object
25+ properties:
26+ field:
27+ type: string
28+ \nOR\n
29+ messages:
30+ Message:
31+ payload:
32+ type: object #Anonymous object
33+ properties:\n
34+ Please move such elements to child of "schemas:" to define proper names.
35+ If changing of data model is not possible, you may use "$id" to set name e.g.\n
36+ properties:
37+ field:
38+ type: array
39+ items:
40+ $id: ArrayElement #Name of object
41+ type: object
42+ properties:
43+ field:
44+ type: string` ) ;
45+ }
46+ }
47+
48+ module . exports = {
49+ /**
50+ * Print help information for user if problems encountered during generation.
51+ *
52+ * @param generator
53+ */
54+ 'generate:after' : generator => {
55+ checkForAnonymousSchemaObjects ( generator ) ;
56+ }
57+ } ;
You can’t perform that action at this time.
0 commit comments