route.blade.php 2.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. <!-- START_{{$route['id']}} -->
  2. @if($route['title'] != '')## {{ $route['title']}}
  3. @else## {{$route['uri']}}@endif
  4. @if($route['authenticated'])<small style="
  5. padding: 1px 9px 2px;
  6. font-weight: bold;
  7. white-space: nowrap;
  8. color: #ffffff;
  9. -webkit-border-radius: 9px;
  10. -moz-border-radius: 9px;
  11. border-radius: 9px;
  12. background-color: #3a87ad;">Requires authentication</small>@endif
  13. @if($route['description'])
  14. {!! $route['description'] !!}
  15. @endif
  16. > Example request:
  17. ```bash
  18. curl -X {{$route['methods'][0]}} {{$route['methods'][0] == 'GET' ? '-G ' : ''}}"{{ trim(config('app.docs_url') ?: config('app.url'), '/')}}/{{ ltrim($route['uri'], '/') }}" \
  19. -H "Accept: application/json"@if(count($route['headers'])) \
  20. @foreach($route['headers'] as $header => $value)
  21. -H "{{$header}}: {{$value}}" @if(! ($loop->last))\
  22. @endif
  23. @endforeach
  24. @endif
  25. @if(count($route['parameters'])) \
  26. @foreach($route['parameters'] as $attribute => $parameter)
  27. -d "{{$attribute}}"={{$parameter['value']}} @if(! ($loop->last))\
  28. @endif
  29. @endforeach
  30. @endif
  31. ```
  32. ```javascript
  33. var settings = {
  34. "async": true,
  35. "crossDomain": true,
  36. "url": "{{ rtrim(config('app.docs_url') ?: config('app.url'), '/') }}/{{ ltrim($route['uri'], '/') }}",
  37. "method": "{{$route['methods'][0]}}",
  38. @if(count($route['parameters']))
  39. "data": {!! str_replace("\n}","\n }", str_replace(' ',' ',json_encode(array_combine(array_keys($route['parameters']), array_map(function($param){ return $param['value']; },$route['parameters'])), JSON_PRETTY_PRINT))) !!},
  40. @endif
  41. "headers": {
  42. "accept": "application/json",
  43. @foreach($route['headers'] as $header => $value)
  44. "{{$header}}": "{{$value}}",
  45. @endforeach
  46. }
  47. }
  48. $.ajax(settings).done(function (response) {
  49. console.log(response);
  50. });
  51. ```
  52. @if(in_array('GET',$route['methods']) || (isset($route['showresponse']) && $route['showresponse']))
  53. > Example response:
  54. ```json
  55. @if(is_object($route['response']) || is_array($route['response']))
  56. {!! json_encode($route['response'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
  57. @else
  58. {!! json_encode(json_decode($route['response']), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
  59. @endif
  60. ```
  61. @endif
  62. ### HTTP Request
  63. @foreach($route['methods'] as $method)
  64. `{{$method}} {{$route['uri']}}`
  65. @endforeach
  66. @if(count($route['parameters']))
  67. #### Parameters
  68. Parameter | Type | Status | Description
  69. --------- | ------- | ------- | ------- | -----------
  70. @foreach($route['parameters'] as $attribute => $parameter)
  71. {{$attribute}} | {{$parameter['type']}} | @if($parameter['required']) required @else optional @endif | {!! $parameter['description'] !!}
  72. @endforeach
  73. @endif
  74. <!-- END_{{$route['id']}} -->