shalvah il y a 3 ans
Parent
commit
b6739fe02a

+ 7 - 0
CHANGELOG.md

@@ -12,6 +12,13 @@ The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/),
 
 ### Removals
 
+## 3.22.0 ( January 2022)
+## Added
+- `@apiResourceAdditional` tag for setting extra attributes on API Resources ([414](https://github.com/knuckleswtf/scribe/pull/414))
+
+## Modified
+- Print multiple fields in `required_if` ([406](https://github.com/knuckleswtf/scribe/pull/406))
+
 ## 3.21.0 (Sunday, 2 January 2022)
 ## Modified
 - Include protocol in baseUrl for Postman collections ([391](https://github.com/knuckleswtf/scribe/pull/391))

+ 4 - 1
phpstan.neon

@@ -1,6 +1,6 @@
 parameters:
     level: 5
-    reportUnmatchedIgnoredErrors: true
+    reportUnmatchedIgnoredErrors: false
     inferPrivatePropertyTypeFromConstructor: true
     ignoreErrors:
         - '#Call to an undefined static method Illuminate\\Support\\Facades\\URL::forceRootUrl\(\)#'
@@ -14,3 +14,6 @@ parameters:
         - '#Access to an undefined property Illuminate\\Contracts\\Foundation\\Application::\$view#'
         - '#Unsafe usage of new static#'
         - '#Dead catch#'
+        - '/Call to an undefined method League\\Flysystem\\Filesystem::deleteDir\(\)./'
+        - '/Instantiated class League\\Flysystem\\Adapter\\Local not found./'
+        - '/Parameter #1 \$adapter of class League\\Flysystem\\Filesystem constructor expects League\\Flysystem\\AdapterInterface, League\\Flysystem\\Adapter\\Local given./'

+ 3 - 2
src/Tools/AnnotationParser.php

@@ -32,8 +32,9 @@ class AnnotationParser
     }
 
     /**
-     * Parse an annotation like 'status=400 when="things go wrong"' to key-value array
-     * All non key-value fields will be ignored
+     * Parse an annotation like 'title=This message="everything good"' into a key-value array.
+     * All non key-value fields will be ignored. Useful for `@apiResourceAdditional`,
+     * where users may specify arbitrary attributes.
      *
      * @param string $annotationContent
      * @return array

+ 1 - 1
src/Tools/Globals.php

@@ -4,7 +4,7 @@ namespace Knuckles\Scribe\Tools;
 
 class Globals
 {
-    public const SCRIBE_VERSION = '3.21.0';
+    public const SCRIBE_VERSION = '3.22.0';
 
     public static bool $shouldBeVerbose = false;
 

+ 4 - 4
src/Tools/Utils.php

@@ -108,10 +108,10 @@ class Utils
             $fs->deleteDirectory($dir);
         } else {
             // v1
-            $adapter = new \League\Flysystem\Adapter\Local($workingDir ?: getcwd()); // @phpstan-ignore-line
-            $fs = new Filesystem($adapter); // @phpstan-ignore-line
-            $dir = str_replace($adapter->getPathPrefix(), '', $dir); // @phpstan-ignore-line
-            $fs->deleteDir($dir); // @phpstan-ignore-line
+            $adapter = new \League\Flysystem\Adapter\Local($workingDir ?: getcwd());
+            $fs = new Filesystem($adapter);
+            $dir = str_replace($adapter->getPathPrefix(), '', $dir);
+            $fs->deleteDir($dir);
         }
     }
 

+ 1 - 1
src/Writing/OpenAPISpecWriter.php

@@ -147,7 +147,7 @@ class OpenAPISpecWriter
                     }
                     $parameters[] = $parameterData;
                 }
-                $pathItem['parameters'] = $parameters; // @phpstan-ignore-line
+                $pathItem['parameters'] = $parameters;
             }
 
             return [$path => $pathItem];

+ 8 - 8
tests/Unit/AnnotationParserTest.php

@@ -66,23 +66,23 @@ class AnnotationParserTest extends TestCase
     public function attributesAnnotations()
     {
         return [
-            "when attributes filled" => [
-                'status=400 scenario="things go wrong" "dummy field"="dummy data", "snaked_data"=value',
+            "with or without quotes" => [
+                'title=This message="everything good" "dummy field"="dummy data", "snaked_data"=value',
                 [
-                    'status' => '400',
-                    'scenario' => 'things go wrong',
+                    'title' => 'This',
+                    'message' => "everything good",
                     'dummy field' => 'dummy data',
                     'snaked_data' => 'value'
                 ]
             ],
-            "when attributes not filled" => [
+            "no attributes" => [
                 '{"message": "failed"}',
                 []
             ],
-            "when attributes wrong" => [
-                'status= scenario="things go wrong"',
+            "attributes with empty values" => [
+                'title= message="everything good"',
                 [
-                    'scenario' => 'things go wrong'
+                    'message' => 'everything good'
                 ]
             ]
         ];