Commit 88bc2c2 1 parent 9b2dd8d commit 88bc2c2 Copy full SHA for 88bc2c2
File tree 2 files changed +17
-4
lines changed
2 files changed +17
-4
lines changed Original file line number Diff line number Diff line change @@ -568,7 +568,10 @@ function getExtraImports(asyncapi) {
568
568
function getPayloadPackage ( pubOrSub ) {
569
569
let fullPackagePath ;
570
570
if ( ! pubOrSub . hasMultipleMessages ( ) ) {
571
- const payload = pubOrSub . message ( ) ?. payload ( ) ;
571
+ let payload ;
572
+ if ( pubOrSub . message ( ) ) {
573
+ payload = pubOrSub . message ( ) . payload ( ) ;
574
+ }
572
575
if ( payload ) {
573
576
const type = payload . type ( ) ;
574
577
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) {
13
13
classNameForGenerator = parserSchemaId ? parserSchemaId : _ . camelCase ( schema . $id ( ) . substring ( schema . $id ( ) . lastIndexOf ( '/' ) + 1 ) ) ;
14
14
15
15
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 ( ) ) {
19
29
const parentParserSchemaId = parentSchema . ext ( 'x-parser-schema-id' ) ;
20
30
classNameForGenerator = parentParserSchemaId ? parentParserSchemaId : _ . camelCase ( parentSchema . $id ( ) . substring ( parentSchema . $id ( ) . lastIndexOf ( '/' ) + 1 ) ) ;
21
31
// 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