route.blade.php 2.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  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'], '/') }}" @if(count($route['headers']))\
  19. @foreach($route['headers'] as $header => $value)
  20. -H "{{$header}}: {{$value}}"@if(! ($loop->last) || ($loop->last && count($route['bodyParameters']))) \
  21. @endif
  22. @endforeach
  23. @endif
  24. @foreach($route['bodyParameters'] as $attribute => $parameter)
  25. -d "{{$attribute}}"="{{$parameter['value']}}" @if(! ($loop->last))\
  26. @endif
  27. @endforeach
  28. ```
  29. ```javascript
  30. var settings = {
  31. "async": true,
  32. "crossDomain": true,
  33. "url": "{{ rtrim(config('app.docs_url') ?: config('app.url'), '/') }}/{{ ltrim($route['uri'], '/') }}",
  34. "method": "{{$route['methods'][0]}}",
  35. @if(count($route['bodyParameters']))
  36. "data": {!! str_replace("\n}","\n }", str_replace(' ',' ',json_encode(array_combine(array_keys($route['bodyParameters']), array_map(function($param){ return $param['value']; },$route['bodyParameters'])), JSON_PRETTY_PRINT))) !!},
  37. @endif
  38. "headers": {
  39. @foreach($route['headers'] as $header => $value)
  40. "{{$header}}": "{{$value}}",
  41. @endforeach
  42. }
  43. }
  44. $.ajax(settings).done(function (response) {
  45. console.log(response);
  46. });
  47. ```
  48. @if(in_array('GET',$route['methods']) || (isset($route['showresponse']) && $route['showresponse']))
  49. > Example response:
  50. ```json
  51. @if(is_object($route['response']) || is_array($route['response']))
  52. {!! json_encode($route['response'], JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
  53. @else
  54. {!! json_encode(json_decode($route['response']), JSON_PRETTY_PRINT | JSON_UNESCAPED_UNICODE) !!}
  55. @endif
  56. ```
  57. @endif
  58. ### HTTP Request
  59. @foreach($route['methods'] as $method)
  60. `{{$method}} {{$route['uri']}}`
  61. @endforeach
  62. @if(count($route['bodyParameters']))
  63. #### Body Parameters
  64. Parameter | Type | Status | Description
  65. --------- | ------- | ------- | ------- | -----------
  66. @foreach($route['bodyParameters'] as $attribute => $parameter)
  67. {{$attribute}} | {{$parameter['type']}} | @if($parameter['required']) required @else optional @endif | {!! $parameter['description'] !!}
  68. @endforeach
  69. @endif
  70. @if(count($route['queryParameters']))
  71. #### Query Parameters
  72. Parameter | Status | Description
  73. --------- | ------- | ------- | -----------
  74. @foreach($route['queryParameters'] as $attribute => $parameter)
  75. {{$attribute}} | @if($parameter['required']) required @else optional @endif | {!! implode(' ',$parameter['description']) !!}
  76. @endforeach
  77. @endif
  78. <!-- END_{{$route['id']}} -->