shalvah vor 5 Jahren
Ursprung
Commit
901f153ea3

+ 6 - 2
src/Strategies/Responses/UseApiResourceTags.php

@@ -2,6 +2,7 @@
 
 namespace Mpociot\ApiDoc\Strategies\Responses;
 
+use Exception;
 use Illuminate\Database\Eloquent\Model;
 use Illuminate\Http\Request;
 use Illuminate\Http\Resources\Json\JsonResource;
@@ -113,9 +114,8 @@ try {
 
     /**
      * @param array $tags
-     * @param ReflectionMethod $apiResourceMethod
      *
-     * @return null|string
+     * @return string
      */
     private function getClassToBeTransformed(array $tags): string
     {
@@ -125,6 +125,10 @@ try {
 
         $type = $modelTag->getContent();
 
+        if (empty($type)) {
+            throw new Exception("Failed to detect an Eloquent API resource model. Please specify a model using @apiResourceModel.");
+        }
+
         return $type;
     }
 

+ 2 - 2
src/Strategies/Responses/UseTransformerTags.php

@@ -107,7 +107,7 @@ class UseTransformerTags extends Strategy
      * @param array $tags
      * @param ReflectionMethod $transformerMethod
      *
-     * @return null|string
+     * @return string
      */
     private function getClassToBeTransformed(array $tags, ReflectionMethod $transformerMethod): string
     {
@@ -127,7 +127,7 @@ class UseTransformerTags extends Strategy
         }
 
         if ($type == null) {
-            throw new Exception("Failed to detect a transformer model. Please specify a model using @transformermodel.");
+            throw new Exception("Failed to detect a transformer model. Please specify a model using @transformerModel.");
         }
 
         return $type;