Skip to content

Commit ae0e75d

Browse files
committed
fix api
1 parent 4a28d93 commit ae0e75d

File tree

6 files changed

+270
-101
lines changed

6 files changed

+270
-101
lines changed

.idea/workspace.xml

Lines changed: 257 additions & 88 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/Mpociot/ApiDoc/Commands/GenerateDocumentation.php

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -255,11 +255,13 @@ private function processLaravelRoutes(AbstractGenerator $generator, $allowedRout
255255
$routes = $this->getRoutes();
256256
$bindings = $this->getBindings();
257257
$parsedRoutes = [];
258+
$i =1;
258259
foreach ($routes as $route) {
259260
if (in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->getUri()) || in_array($middleware, $route->middleware())) {
260261
if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
261-
$parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse);
262+
$parsedRoutes[] = $generator->processRoute($i, $route, $bindings, $this->option('header'), $withResponse);
262263
$this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->getUri());
264+
$i++;
263265
} else {
264266
$this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->getUri());
265267
}
@@ -285,7 +287,7 @@ private function processDingoRoutes(AbstractGenerator $generator, $allowedRoutes
285287
foreach ($routes as $route) {
286288
if (empty($allowedRoutes) || in_array($route->getName(), $allowedRoutes) || str_is($routePrefix, $route->uri()) || in_array($middleware, $route->middleware())) {
287289
if ($this->isValidRoute($route) && $this->isRouteVisibleForDocumentation($route->getAction()['uses'])) {
288-
$parsedRoutes[] = $generator->processRoute($route, $bindings, $this->option('header'), $withResponse);
290+
$parsedRoutes[] = $generator->processRoute(0, $route, $bindings, $this->option('header'), $withResponse);
289291
$this->info('Processed route: ['.implode(',', $route->getMethods()).'] '.$route->uri());
290292
} else {
291293
$this->warn('Skipping route: ['.implode(',', $route->getMethods()).'] '.$route->uri());

src/Mpociot/ApiDoc/Generators/AbstractGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ abstract protected function getUri($route);
2727
*
2828
* @return array
2929
*/
30-
abstract public function processRoute($route, $bindings = [], $withResponse = true);
30+
abstract public function processRoute($i, $route, $bindings = [], $withResponse = true);
3131

3232
/**
3333
* Prepares / Disables route middlewares.

src/Mpociot/ApiDoc/Generators/DingoGenerator.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class DingoGenerator extends AbstractGenerator
1414
*
1515
* @return array
1616
*/
17-
public function processRoute($route, $bindings = [], $headers = [], $withResponse = true)
17+
public function processRoute($i, $route, $bindings = [], $headers = [], $withResponse = true)
1818
{
1919
$response = '';
2020

src/Mpociot/ApiDoc/Generators/LaravelGenerator.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ protected function getUri($route)
2828
*
2929
* @return array
3030
*/
31-
public function processRoute($route, $bindings = [], $headers = [], $withResponse = true)
31+
public function processRoute($i, $route, $bindings = [], $headers = [], $withResponse = true)
3232
{
3333
$content = '';
3434

@@ -48,7 +48,7 @@ public function processRoute($route, $bindings = [], $headers = [], $withRespons
4848
return $this->getParameters([
4949
'id' => md5($route->getUri().':'.implode($route->getMethods())),
5050
'resource' => $routeGroup,
51-
'title' => $routeDescription['short'],
51+
'title' => $i. " - " . $routeDescription['short'],
5252
'description' => $routeDescription['long'],
5353
'methods' => $route->getMethods(),
5454
'uri' => $route->getUri(),
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,26 @@
11
<!-- START_{{$parsedRoute['id']}} -->
2-
@if($parsedRoute['title'] != '')## {{ $parsedRoute['title']}}
2+
@if($parsedRoute['title'] != '')## {{$parsedRoute['title']}}
33
@else## {{$parsedRoute['uri']}}
44
@endif
5-
@if($parsedRoute['description'])
65

7-
{!! $parsedRoute['description'] !!}
6+
@if($parsedRoute['description'])
7+
{!! $parsedRoute['description'] !!}
88
@endif
99

10-
1110
### HTTP Request
1211

1312
@foreach($parsedRoute['methods'] as $method)
14-
`{{$method}} {{$parsedRoute['uri']}}`
13+
@if($method!="HEAD")`{{$method}} {{$parsedRoute['uri']}}`@endif
1514
@endforeach
1615

1716
@if(count($parsedRoute['parameters']))
18-
#### Parameters
17+
### Parameters
1918

2019
Parameter | Type | Status | Description
2120
--------- | ------- | ------- | ------- | -----------
2221
@foreach($parsedRoute['parameters'] as $attribute => $parameter)
2322
{{$attribute}} | {{$parameter['type']}} | @if($parameter['required']) required @else optional @endif | {!! implode(' ',$parameter['description']) !!}
2423
@endforeach
25-
2624
@endif
2725

2826
<!-- END_{{$parsedRoute['id']}} -->

0 commit comments

Comments
 (0)