File tree Expand file tree Collapse file tree 2 files changed +17
-4
lines changed
Expand file tree Collapse file tree 2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -568,7 +568,10 @@ function getExtraImports(asyncapi) {
568568function getPayloadPackage ( pubOrSub ) {
569569 let fullPackagePath ;
570570 if ( ! pubOrSub . hasMultipleMessages ( ) ) {
571- const payload = pubOrSub . message ( ) ?. payload ( ) ;
571+ let payload ;
572+ if ( pubOrSub . message ( ) ) {
573+ payload = pubOrSub . message ( ) . payload ( ) ;
574+ }
572575 if ( payload ) {
573576 const type = payload . type ( ) ;
574577 const importName = payload . ext ( 'x-parser-schema-id' ) ;
Original file line number Diff line number Diff line change @@ -13,9 +13,19 @@ function setSchemaIdsForFileName(asyncapi) {
1313 classNameForGenerator = parserSchemaId ? parserSchemaId : _ . camelCase ( schema . $id ( ) . substring ( schema . $id ( ) . lastIndexOf ( '/' ) + 1 ) ) ;
1414
1515 if ( classNameForGenerator === 'items' ) {
16- const parentSchema = schema . options ?. parent ;
17- const parentSchemaItems = parentSchema ?. items ( ) ;
18- if ( parentSchemaItems ?. _json ?. $id === schema . $id ( ) ) {
16+ let parentSchema ;
17+ if ( schema . options ) {
18+ parentSchema = schema . options . parent ;
19+ }
20+ let parentSchemaItems ;
21+ if ( parentSchema ) {
22+ parentSchemaItems = parentSchema . items ( ) ;
23+ }
24+ let parentSchemaItemsId ;
25+ if ( parentSchemaItems && parentSchemaItems . _json ) {
26+ parentSchemaItemsId = parentSchemaItems . _json . $id ;
27+ }
28+ if ( parentSchemaItemsId === schema . $id ( ) ) {
1929 const parentParserSchemaId = parentSchema . ext ( 'x-parser-schema-id' ) ;
2030 classNameForGenerator = parentParserSchemaId ? parentParserSchemaId : _ . camelCase ( parentSchema . $id ( ) . substring ( parentSchema . $id ( ) . lastIndexOf ( '/' ) + 1 ) ) ;
2131 // If we come across this schema later in the code generator, we'll know to rename it to its parent because the proper settings will be set in the model class.
You can’t perform that action at this time.
0 commit comments