Explorar o código

Move from default_group to groups.default

shalvah %!s(int64=3) %!d(string=hai) anos
pai
achega
c850967b34

+ 5 - 4
config/scribe.php

@@ -318,12 +318,13 @@ INTRO
          *
          * Any groups or endpoints you don't list here will be added as usual after the ones here.
          * If an endpoint is listed under a group it doesn't belong in, it will be ignored.
+         * Note: omit the initial '/' when writing an endpoint.
          */
         'order' => [
-            // 'Group 1',
-            // 'Group 2' => [
-            //    'POST /this-endpoint-comes-first',
-            //    'GET /this-endpoint-comes-next',
+            // 'This group comes first',
+            // 'This group comes next' => [
+            //    'POST this-endpoint-comes-first',
+            //    'GET this-endpoint-comes-next',
             // ]
         ],
     ],

+ 2 - 2
src/Commands/GenerateDocumentation.php

@@ -121,14 +121,14 @@ class GenerateDocumentation extends Command
         foreach ($userDefinedEndpoints as $endpoint) {
             $indexOfGroupWhereThisEndpointShouldBeAdded = Arr::first(array_keys($groupedEndpoints), function ($key) use ($groupedEndpoints, $endpoint) {
                 $group = $groupedEndpoints[$key];
-                return $group['name'] === ($endpoint['metadata']['groupName'] ?? $this->docConfig->get('default_group', ''));
+                return $group['name'] === ($endpoint['metadata']['groupName'] ?? $this->docConfig->get('groups.default', ''));
             });
 
             if ($indexOfGroupWhereThisEndpointShouldBeAdded !== null) {
                 $groupedEndpoints[$indexOfGroupWhereThisEndpointShouldBeAdded]['endpoints'][] = OutputEndpointData::fromExtractedEndpointArray($endpoint);
             } else {
                 $newGroup = [
-                    'name' => $endpoint['metadata']['groupName'] ?? $this->docConfig->get('default_group', ''),
+                    'name' => $endpoint['metadata']['groupName'] ?? $this->docConfig->get('groups.default', ''),
                     'description' => $endpoint['metadata']['groupDescription'] ?? null,
                     'endpoints' => [OutputEndpointData::fromExtractedEndpointArray($endpoint)],
                 ];

+ 1 - 1
src/Extracting/Extractor.php

@@ -125,7 +125,7 @@ class Extractor
     protected function fetchMetadata(ExtractedEndpointData $endpointData, array $rulesToApply): void
     {
         $endpointData->metadata = new Metadata([
-            'groupName' => $this->config->get('default_group', ''),
+            'groupName' => $this->config->get('groups.default', ''),
         ]);
 
         $this->iterateThroughStrategies('metadata', $endpointData, $rulesToApply, function ($results) use ($endpointData) {

+ 1 - 1
src/Extracting/Strategies/Metadata/GetFromDocBlocks.php

@@ -99,6 +99,6 @@ class GetFromDocBlocks extends Strategy
             }
         }
 
-        return [$this->config->get('default_group'), '', $methodDocBlock->getShortDescription()];
+        return [$this->config->get('groups.default'), '', $methodDocBlock->getShortDescription()];
     }
 }

+ 1 - 1
tests/Unit/ExtractorTest.php

@@ -48,7 +48,7 @@ class ExtractorTest extends TestCase
                 \Knuckles\Scribe\Extracting\Strategies\ResponseFields\GetFromResponseFieldTag::class,
             ],
         ],
-        'default_group' => 'general',
+        'groups.default' => 'general',
     ];
 
     public static $globalValue = null;