Skip to content

Commit 4eecf10

Browse files
committed
Merge remote-tracking branch 'origin/non-static-docs' into v4
# Conflicts: # src/Extracting/Strategies/QueryParameters/GetFromQueryParamTag.php # src/Extracting/Strategies/Responses/UseApiResourceTags.php # src/Matching/RouteMatcher.php # src/Writing/PostmanCollectionWriter.php
2 parents 61163a7 + 30bb475 commit 4eecf10

File tree

9 files changed

+28
-28
lines changed

9 files changed

+28
-28
lines changed

src/Commands/GenerateDocumentation.php

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,8 +9,8 @@
99
use Mpociot\ApiDoc\Tools\Flags;
1010
use Mpociot\ApiDoc\Tools\Utils;
1111
use Mpociot\Reflection\DocBlock;
12-
use Mpociot\ApiDoc\Writing\Writer;
1312
use Illuminate\Support\Collection;
13+
use Mpociot\ApiDoc\Writing\Writer;
1414
use Illuminate\Support\Facades\URL;
1515
use Mpociot\ApiDoc\Extracting\Generator;
1616
use Mpociot\ApiDoc\Matching\RouteMatcher;
@@ -154,5 +154,4 @@ private function isRouteVisibleForDocumentation(array $action)
154154

155155
return true;
156156
}
157-
158157
}

src/Extracting/Strategies/QueryParameters/GetFromQueryParamTag.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,8 @@
1010
use Mpociot\Reflection\DocBlock\Tag;
1111
use Mpociot\ApiDoc\Extracting\ParamHelpers;
1212
use Mpociot\ApiDoc\Extracting\RouteDocBlocker;
13-
use Dingo\Api\Http\FormRequest as DingoFormRequest;
1413
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
14+
use Dingo\Api\Http\FormRequest as DingoFormRequest;
1515
use Illuminate\Foundation\Http\FormRequest as LaravelFormRequest;
1616

1717
class GetFromQueryParamTag extends Strategy

src/Extracting/Strategies/Responses/UseApiResourceTags.php

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,9 @@
1414
use Mpociot\Reflection\DocBlock;
1515
use Mpociot\Reflection\DocBlock\Tag;
1616
use Illuminate\Database\Eloquent\Model;
17+
use League\Fractal\Resource\Collection;
1718
use Mpociot\ApiDoc\Extracting\RouteDocBlocker;
19+
use Illuminate\Http\Resources\Json\JsonResource;
1820
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
1921
use Illuminate\Http\Resources\Json\ResourceCollection;
2022

src/Matching/RouteMatcher.php

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,6 @@ class RouteMatcher
1919
*/
2020
protected $routeRules;
2121

22-
2322
public function __construct(array $routeRules = [], string $router = 'laravel')
2423
{
2524
$this->router = $router;

src/Writing/PostmanCollectionWriter.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ public function getCollection()
4040
$collection = [
4141
'variables' => [],
4242
'info' => [
43-
'name' => config('apidoc.postman.name') ?: config('app.name'). ' API',
43+
'name' => config('apidoc.postman.name') ?: config('app.name').' API',
4444
'_postman_id' => Uuid::uuid4()->toString(),
4545
'description' => config('apidoc.postman.description') ?: '',
4646
'schema' => 'https://schema.getpostman.com/json/collection/v2.0.0/collection.json',
@@ -57,8 +57,8 @@ public function getCollection()
5757
'request' => [
5858
'url' => url($route['uri']).(collect($route['queryParameters'])->isEmpty()
5959
? ''
60-
: ('?' . implode('&', collect($route['queryParameters'])->map(function ($parameter, $key) {
61-
return urlencode($key).'=' . urlencode($parameter['value'] ?? '');
60+
: ('?'.implode('&', collect($route['queryParameters'])->map(function ($parameter, $key) {
61+
return urlencode($key).'='.urlencode($parameter['value'] ?? '');
6262
})->all()))),
6363
'method' => $route['methods'][0],
6464
'header' => collect($route['headers'])

src/Writing/Writer.php

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -140,7 +140,7 @@ public function writeMarkdownAndSourceFiles(Collection $parsedRoutes, string $so
140140

141141
$this->output->info('Writing index.md and source files to: '.$sourceOutputPath);
142142

143-
if (!is_dir($sourceOutputPath)) {
143+
if (! is_dir($sourceOutputPath)) {
144144
$documentarian = new Documentarian();
145145
$documentarian->create($sourceOutputPath);
146146
}
@@ -229,7 +229,7 @@ protected function getMarkdownToPrepend(string $sourceOutputPath): string
229229
? file_get_contents($prependFile)."\n" : '';
230230

231231
return $prependFileContents;
232-
}
232+
}
233233

234234
/**
235235
* @param string $sourceOutputPath
@@ -243,7 +243,7 @@ protected function getMarkdownToAppend(string $sourceOutputPath): string
243243
? "\n".file_get_contents($appendFile) : '';
244244

245245
return $appendFileContents;
246-
}
246+
}
247247

248248
protected function copyAssetsFromSourceFolderToPublicFolder(string $sourceOutputPath, bool $isStatic = true): void
249249
{

tests/GenerateDocumentationTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ public function can_parse_resource_routes()
136136
/** @test */
137137
public function can_parse_partial_resource_routes()
138138
{
139-
RouteFacade::resource('/api/users', TestResourceController::class)
139+
RouteFacade::resource('/api/users', TestResourceController::class)
140140
->only(['index', 'create']);
141141

142142
config(['apidoc.routes.0.match.prefixes' => ['api/*']]);
@@ -152,7 +152,7 @@ public function can_parse_partial_resource_routes()
152152
$generatedMarkdown = __DIR__.'/../resources/docs/source/index.md';
153153
$this->assertFilesHaveSameContent($fixtureMarkdown, $generatedMarkdown);
154154

155-
RouteFacade::apiResource('/api/users', TestResourceController::class)
155+
RouteFacade::apiResource('/api/users', TestResourceController::class)
156156
->only(['index', 'create']);
157157

158158
$this->artisan('apidoc:generate');

tests/Unit/GeneratorPluginSystemTestCase.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,10 +6,10 @@
66
use ReflectionMethod;
77
use Illuminate\Routing\Route;
88
use Mpociot\ApiDoc\Extracting\Generator;
9-
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
109
use Mpociot\ApiDoc\Tools\DocumentationConfig;
1110
use Mpociot\ApiDoc\Tests\Fixtures\TestController;
1211
use Mpociot\ApiDoc\ApiDocGeneratorServiceProvider;
12+
use Mpociot\ApiDoc\Extracting\Strategies\Strategy;
1313

1414
class GeneratorPluginSystemTestCase extends LaravelGeneratorTest
1515
{

tests/Unit/RouteMatcherTest.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,25 +56,25 @@ public function testRespectsDomainsRuleForDingoRouter()
5656
$routeRules[0]['match']['prefixes'] = ['*'];
5757

5858
$routeRules[0]['match']['domains'] = ['*'];
59-
$matcher = new RouteMatcher($routeRules, "dingo");
59+
$matcher = new RouteMatcher($routeRules, 'dingo');
6060
$routes = $matcher->getRoutes();
6161
$this->assertCount(12, $routes);
6262

6363
$routeRules[0]['match']['domains'] = ['domain1.*', 'domain2.*'];
64-
$matcher = new RouteMatcher($routeRules, "dingo");
64+
$matcher = new RouteMatcher($routeRules, 'dingo');
6565
$routes = $matcher->getRoutes();
6666
$this->assertCount(12, $routes);
6767

6868
$routeRules[0]['match']['domains'] = ['domain1.*'];
69-
$matcher = new RouteMatcher($routeRules, "dingo");
69+
$matcher = new RouteMatcher($routeRules, 'dingo');
7070
$routes = $matcher->getRoutes();
7171
$this->assertCount(6, $routes);
7272
foreach ($routes as $route) {
7373
$this->assertContains('domain1', $route['route']->getDomain());
7474
}
7575

7676
$routeRules[0]['match']['domains'] = ['domain2.*'];
77-
$matcher = new RouteMatcher($routeRules, "dingo");
77+
$matcher = new RouteMatcher($routeRules, 'dingo');
7878
$routes = $matcher->getRoutes();
7979
$this->assertCount(6, $routes);
8080
foreach ($routes as $route) {
@@ -121,25 +121,25 @@ public function testRespectsPrefixesRuleForDingoRouter()
121121
$routeRules[0]['match']['domains'] = ['*'];
122122

123123
$routeRules[0]['match']['prefixes'] = ['*'];
124-
$matcher = new RouteMatcher($routeRules, "dingo");
124+
$matcher = new RouteMatcher($routeRules, 'dingo');
125125
$routes = $matcher->getRoutes();
126126
$this->assertCount(12, $routes);
127127

128128
$routeRules[0]['match']['prefixes'] = ['prefix1/*', 'prefix2/*'];
129-
$matcher = new RouteMatcher($routeRules, "dingo");
129+
$matcher = new RouteMatcher($routeRules, 'dingo');
130130
$routes = $matcher->getRoutes();
131131
$this->assertCount(8, $routes);
132132

133133
$routeRules[0]['match']['prefixes'] = ['prefix1/*'];
134-
$matcher = new RouteMatcher($routeRules, "dingo");
134+
$matcher = new RouteMatcher($routeRules, 'dingo');
135135
$routes = $matcher->getRoutes();
136136
$this->assertCount(4, $routes);
137137
foreach ($routes as $route) {
138138
$this->assertTrue(Str::is('prefix1/*', $route['route']->uri()));
139139
}
140140

141141
$routeRules[0]['match']['prefixes'] = ['prefix2/*'];
142-
$matcher = new RouteMatcher($routeRules, "dingo");
142+
$matcher = new RouteMatcher($routeRules, 'dingo');
143143
$routes = $matcher->getRoutes();
144144
$this->assertCount(4, $routes);
145145
foreach ($routes as $route) {
@@ -154,7 +154,7 @@ public function testRespectsVersionsRuleForDingoRouter()
154154
$routeRules[0]['match']['versions'] = ['v2'];
155155
$routeRules[0]['match']['domains'] = ['*'];
156156
$routeRules[0]['match']['prefixes'] = ['*'];
157-
$matcher = new RouteMatcher($routeRules, "dingo");
157+
$matcher = new RouteMatcher($routeRules, 'dingo');
158158
$routes = $matcher->getRoutes();
159159
$this->assertCount(6, $routes);
160160
foreach ($routes as $route) {
@@ -164,7 +164,7 @@ public function testRespectsVersionsRuleForDingoRouter()
164164
$routeRules[0]['match']['versions'] = ['v1', 'v2'];
165165
$routeRules[0]['match']['domains'] = ['*'];
166166
$routeRules[0]['match']['prefixes'] = ['*'];
167-
$matcher = new RouteMatcher($routeRules, "dingo");
167+
$matcher = new RouteMatcher($routeRules, 'dingo');
168168
$routes = $matcher->getRoutes();
169169
$this->assertCount(18, $routes);
170170
}
@@ -200,7 +200,7 @@ public function testWillIncludeRouteIfListedExplicitlyForDingoRouter()
200200
'include' => [$mustInclude],
201201
],
202202
];
203-
$matcher = new RouteMatcher($routeRules, "dingo");
203+
$matcher = new RouteMatcher($routeRules, 'dingo');
204204
$routes = $matcher->getRoutes();
205205
$oddRuleOut = collect($routes)->filter(function ($route) use ($mustInclude) {
206206
return $route['route']->getName() === $mustInclude;
@@ -241,7 +241,7 @@ public function testWillIncludeRouteIfMatchForAnIncludePatternForDingoRouter()
241241
'include' => [$includePattern],
242242
],
243243
];
244-
$matcher = new RouteMatcher($routeRules, "dingo");
244+
$matcher = new RouteMatcher($routeRules, 'dingo');
245245
$routes = $matcher->getRoutes();
246246
$oddRuleOut = collect($routes)->filter(function ($route) use ($mustInclude) {
247247
return in_array($route['route']->getName(), $mustInclude);
@@ -280,7 +280,7 @@ public function testWillExcludeRouteIfListedExplicitlyForDingoRouter()
280280
'exclude' => [$mustNotInclude],
281281
],
282282
];
283-
$matcher = new RouteMatcher($routeRules, "dingo");
283+
$matcher = new RouteMatcher($routeRules, 'dingo');
284284
$routes = $matcher->getRoutes();
285285
$oddRuleOut = collect($routes)->filter(function ($route) use ($mustNotInclude) {
286286
return $route['route']->getName() === $mustNotInclude;
@@ -321,7 +321,7 @@ public function testWillExcludeRouteIfMatchForAnExcludePatterForDingoRouter()
321321
'exclude' => [$excludePattern],
322322
],
323323
];
324-
$matcher = new RouteMatcher($routeRules, "dingo");
324+
$matcher = new RouteMatcher($routeRules, 'dingo');
325325
$routes = $matcher->getRoutes();
326326
$oddRuleOut = collect($routes)->filter(function ($route) use ($mustNotInclude) {
327327
return in_array($route['route']->getName(), $mustNotInclude);
@@ -386,7 +386,7 @@ public function testMergesRoutesFromDifferentRuleGroupsForDingoRouter()
386386
],
387387
];
388388

389-
$matcher = new RouteMatcher($routeRules, "dingo");
389+
$matcher = new RouteMatcher($routeRules, 'dingo');
390390
$routes = $matcher->getRoutes();
391391
$this->assertCount(18, $routes);
392392

0 commit comments

Comments
 (0)