Skip to content

Commit

Permalink
Move from default_group to groups.default
Browse files Browse the repository at this point in the history
  • Loading branch information
shalvah committed Jul 3, 2022
1 parent 29ddcfc commit c850967
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 9 deletions.
9 changes: 5 additions & 4 deletions config/scribe.php
Original file line number Diff line number Diff line change
Expand Up @@ -318,12 +318,13 @@
*
* 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',
// ]
],
],
Expand Down
4 changes: 2 additions & 2 deletions src/Commands/GenerateDocumentation.php
Original file line number Diff line number Diff line change
Expand Up @@ -121,14 +121,14 @@ protected function mergeUserDefinedEndpoints(array $groupedEndpoints, array $use
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)],
];
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/Extractor.php
Original file line number Diff line number Diff line change
Expand Up @@ -125,7 +125,7 @@ public function processRoute(Route $route, array $routeRules = []): ExtractedEnd
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) {
Expand Down
2 changes: 1 addition & 1 deletion src/Extracting/Strategies/Metadata/GetFromDocBlocks.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,6 @@ protected function getRouteGroupDescriptionAndTitle(DocBlock $methodDocBlock, Do
}
}

return [$this->config->get('default_group'), '', $methodDocBlock->getShortDescription()];
return [$this->config->get('groups.default'), '', $methodDocBlock->getShortDescription()];
}
}
2 changes: 1 addition & 1 deletion tests/Unit/ExtractorTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down

0 comments on commit c850967

Please sign in to comment.