Browse Source

Merge branch 'master' into v4

# Conflicts:
#	CHANGELOG.md
#	src/Extracting/Strategies/ResponseFields/GetFromResponseFieldTag.php
#	src/Tools/Globals.php
#	src/Writing/Writer.php
shalvah 2 years ago
parent
commit
895ae5873c

+ 4 - 0
CHANGELOG.md

@@ -23,6 +23,10 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 - Parameter data from successive stages is now merged
 - Basic support for overriding docs for inherited methods ([9735fdf](9735fdf150469f186bab395fcfabd042f570c50c))
 
+## 3.36.0 (12 August 2022)
+### Modified
+- Support `@responseField` on Eloquent API resources ([#505](https://github.com/knuckleswtf/scribe/pull/505))
+
 ## 3.35.0 (27 July 2022)
 ### Modified
 - Use correct folders when generating in multi-docs ([ac47c67](https://github.com/knuckleswtf/scribe/commit/ac47c67eeb5d47cd30db74302d1cdd97720dd695))

+ 18 - 0
src/Extracting/Strategies/ResponseFields/GetFromResponseFieldTag.php

@@ -41,4 +41,22 @@ class GetFromResponseFieldTag extends GetFieldsFromTagStrategy
 
         return $data;
     }
+
+    /**
+     * Get api resource tag.
+     *
+     * @param Tag[] $tags
+     *
+     * @return Tag|null
+     */
+    public function getApiResourceTag(array $tags): ?Tag
+    {
+        $apiResourceTags = array_values(
+            array_filter($tags, function ($tag) {
+                return ($tag instanceof Tag) && in_array(strtolower($tag->getName()), ['apiresource', 'apiresourcecollection']);
+            })
+        );
+
+        return empty($apiResourceTags) ? null : $apiResourceTags[0];
+    }
 }

+ 1 - 1
src/Writing/Writer.php

@@ -230,7 +230,7 @@ class Writer
     {
         if ($this->isStatic) return null;
 
-        return config('view.paths.0', "resources/views")."/$this->docsName";
+        return config('view.paths.0', function_exists('base_path') ? base_path("resources/views") : "resources/views")."/$this->docsName";
     }
 
 }