TestController.php 3.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166
  1. <?php
  2. namespace Mpociot\ApiDoc\Tests\Fixtures;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Routing\Controller;
  5. /**
  6. * @group Group A
  7. */
  8. class TestController extends Controller
  9. {
  10. public function dummy()
  11. {
  12. return '';
  13. }
  14. /**
  15. * Example title.
  16. * This will be the long description.
  17. * It can also be multiple lines long.
  18. */
  19. public function withEndpointDescription()
  20. {
  21. return '';
  22. }
  23. /**
  24. * @group Group B
  25. */
  26. public function withGroupOverride()
  27. {
  28. return '';
  29. }
  30. /**
  31. * @bodyParam user_id int required The id of the user. Example: 9
  32. * @bodyParam room_id string The id of the room.
  33. * @bodyParam forever boolean Whether to ban the user forever. Example: false
  34. * @bodyParam another_one number Just need something here.
  35. * @bodyParam yet_another_param object required
  36. * @bodyParam even_more_param array
  37. */
  38. public function withBodyParameters()
  39. {
  40. return '';
  41. }
  42. /**
  43. * @queryParam location_id required The id of the location.
  44. * @queryParam user_id required The id of the user. Example: me
  45. * @queryParam page required The page number. Example: 4
  46. * @queryParam filters The filters.
  47. */
  48. public function withQueryParameters()
  49. {
  50. return '';
  51. }
  52. /**
  53. * @authenticated
  54. */
  55. public function withAuthenticatedTag()
  56. {
  57. return '';
  58. }
  59. public function checkCustomHeaders(Request $request)
  60. {
  61. return $request->headers->all();
  62. }
  63. public function shouldFetchRouteResponse()
  64. {
  65. $fruit = new \stdClass();
  66. $fruit->id = 4;
  67. $fruit->name = ' banana ';
  68. $fruit->color = 'RED';
  69. $fruit->weight = 1;
  70. $fruit->delicious = true;
  71. return [
  72. 'id' => (int) $fruit->id,
  73. 'name' => trim($fruit->name),
  74. 'color' => strtolower($fruit->color),
  75. 'weight' => $fruit->weight.' kg',
  76. 'delicious' => $fruit->delicious,
  77. ];
  78. }
  79. public function shouldFetchRouteResponseWithEchoedSettings($id)
  80. {
  81. return [
  82. '{id}' => $id,
  83. 'APP_ENV' => getenv('APP_ENV'),
  84. 'header' => request()->header('header'),
  85. 'queryParam' => request()->query('queryParam'),
  86. 'bodyParam' => request()->get('bodyParam'),
  87. ];
  88. }
  89. /**
  90. * @response {
  91. * "result": "Лорем ипсум долор сит амет"
  92. * }
  93. */
  94. public function withUtf8ResponseTag()
  95. {
  96. return ['result' => 'Лорем ипсум долор сит амет'];
  97. }
  98. /**
  99. * @hideFromAPIDocumentation
  100. */
  101. public function skip()
  102. {
  103. }
  104. /**
  105. * @response {
  106. * "id": 4,
  107. * "name": "banana",
  108. * "color": "red",
  109. * "weight": "1 kg",
  110. * "delicious": true
  111. * }
  112. */
  113. public function withResponseTag()
  114. {
  115. return '';
  116. }
  117. /**
  118. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  119. */
  120. public function transformerTag()
  121. {
  122. return '';
  123. }
  124. /**
  125. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  126. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  127. */
  128. public function transformerTagWithModel()
  129. {
  130. return '';
  131. }
  132. /**
  133. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  134. */
  135. public function transformerCollectionTag()
  136. {
  137. return '';
  138. }
  139. /**
  140. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  141. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  142. */
  143. public function transformerCollectionTagWithModel()
  144. {
  145. return '';
  146. }
  147. }