@@ -396,7 +396,7 @@ protected function generateUrls()
396396 'route ' => "$ controller/ $ a$ action " ,
397397 'actionParams ' => $ actionParams ,
398398 'openApiOperation ' => $ operation ,
399- 'modelClass ' => $ this ->modelNamespace . '\\' . $ modelClass ,
399+ 'modelClass ' => $ modelClass !== null ? $ this ->modelNamespace . '\\' . $ modelClass : null ,
400400 'responseWrapper ' => $ responseWrapper ,
401401 ];
402402 }
@@ -464,16 +464,16 @@ private function guessModelClassFromContent(MediaType $content)
464464 $ referencedSchema = $ content ->schema ->resolve ();
465465 // Model data is directly returned
466466 if ($ referencedSchema ->type === null || $ referencedSchema ->type === 'object ' ) {
467- $ ref = $ content ->schema ->getReference ();
468- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
469- return [substr ($ ref , 21 ), '' , '' ];
467+ $ ref = $ content ->schema ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
468+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
469+ return [substr ($ ref , 20 ), '' , '' ];
470470 }
471471 }
472472 // an array of Model data is directly returned
473473 if ($ referencedSchema ->type === 'array ' && $ referencedSchema ->items instanceof Reference) {
474- $ ref = $ referencedSchema ->items ->getReference ();
475- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
476- return [substr ($ ref , 21 ), '' , '' ];
474+ $ ref = $ referencedSchema ->items ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
475+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
476+ return [substr ($ ref , 20 ), '' , '' ];
477477 }
478478 }
479479 } else {
@@ -488,26 +488,32 @@ private function guessModelClassFromContent(MediaType $content)
488488 $ referencedModelSchema = $ property ->resolve ();
489489 if ($ referencedModelSchema ->type === null || $ referencedModelSchema ->type === 'object ' ) {
490490 // Model data is wrapped
491- $ ref = $ property ->getReference ();
492- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
493- return [substr ($ ref , 21 ), $ propertyName , null ];
491+ $ ref = $ property ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
492+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
493+ return [substr ($ ref , 20 ), $ propertyName , null ];
494494 }
495495 } elseif ($ referencedModelSchema ->type === 'array ' && $ referencedModelSchema ->items instanceof Reference) {
496496 // an array of Model data is wrapped
497- $ ref = $ referencedModelSchema ->items ->getReference ();
498- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
499- return [substr ($ ref , 21 ), null , $ propertyName ];
497+ $ ref = $ referencedModelSchema ->items ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
498+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
499+ return [substr ($ ref , 20 ), null , $ propertyName ];
500500 }
501501 }
502502 } elseif ($ property ->type === 'array ' && $ property ->items instanceof Reference) {
503503 // an array of Model data is wrapped
504- $ ref = $ property ->items ->getReference ();
505- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
506- return [substr ($ ref , 21 ), null , $ propertyName ];
504+ $ ref = $ property ->items ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
505+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
506+ return [substr ($ ref , 20 ), null , $ propertyName ];
507507 }
508508 }
509509 }
510510 }
511+ if ($ referencedSchema ->type === 'array ' && $ referencedSchema ->items instanceof Reference) {
512+ $ ref = $ referencedSchema ->items ->getJsonReference ()->getJsonPointer ()->getPointer ();
513+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
514+ return [substr ($ ref , 20 ), '' , '' ];
515+ }
516+ }
511517 return [null , null , null ];
512518 }
513519
@@ -588,13 +594,13 @@ protected function generateModels()
588594
589595 foreach ($ schema ->properties as $ name => $ property ) {
590596 if ($ property instanceof Reference) {
591- $ ref = $ property ->getReference ();
597+ $ ref = $ property ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
592598 $ resolvedProperty = $ property ->resolve ();
593599 $ dbName = "{$ name }_id " ;
594600 $ dbType = 'integer ' ; // for a foreign key
595- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
601+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
596602 // relation
597- $ type = substr ($ ref , 21 );
603+ $ type = substr ($ ref , 20 );
598604 $ relations [$ name ] = [
599605 'class ' => $ type ,
600606 'method ' => 'hasOne ' ,
@@ -777,9 +783,9 @@ protected function getSchemaType($schema)
777783 return 'float ' ;
778784 case 'array ' :
779785 if (isset ($ schema ->items ) && $ schema ->items instanceof Reference) {
780- $ ref = $ schema ->items ->getReference ();
781- if (strpos ($ ref , '# /components/schemas/ ' ) === 0 ) {
782- return [substr ($ ref , 21 ) . '[] ' , substr ($ ref , 21 )];
786+ $ ref = $ schema ->items ->getJsonReference ()-> getJsonPointer ()-> getPointer ();
787+ if (strpos ($ ref , '/components/schemas/ ' ) === 0 ) {
788+ return [substr ($ ref , 20 ) . '[] ' , substr ($ ref , 20 )];
783789 }
784790 }
785791 // no break here
@@ -813,9 +819,9 @@ protected function getDbType($name, $schema)
813819// case 'array':
814820 // TODO array might refer to has_many relation
815821// if (isset($schema->items) && $schema->items instanceof Reference) {
816- // $ref = $schema->items->getReference ();
817- // if (strpos($ref, '# /components/schemas/') === 0) {
818- // return substr($ref, 21 ) . '[]';
822+ // $ref = $schema->items->getJsonReference()->getJsonPointer()->getPointer ();
823+ // if (strpos($ref, '/components/schemas/') === 0) {
824+ // return substr($ref, 20 ) . '[]';
819825// }
820826// }
821827// // no break here
0 commit comments