TestController.php 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164
  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.
  32. * @bodyParam room_id string The id of the room.
  33. * @bodyParam forever boolean Whether to ban the user forever.
  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 filters The filters.
  45. */
  46. public function withQueryParameters()
  47. {
  48. return '';
  49. }
  50. /**
  51. * @authenticated
  52. */
  53. public function withAuthenticatedTag()
  54. {
  55. return '';
  56. }
  57. public function checkCustomHeaders(Request $request)
  58. {
  59. return $request->headers->all();
  60. }
  61. public function shouldFetchRouteResponse()
  62. {
  63. $fruit = new \stdClass();
  64. $fruit->id = 4;
  65. $fruit->name = ' banana ';
  66. $fruit->color = 'RED';
  67. $fruit->weight = 1;
  68. $fruit->delicious = true;
  69. return [
  70. 'id' => (int) $fruit->id,
  71. 'name' => trim($fruit->name),
  72. 'color' => strtolower($fruit->color),
  73. 'weight' => $fruit->weight.' kg',
  74. 'delicious' => $fruit->delicious,
  75. ];
  76. }
  77. public function shouldFetchRouteResponseWithEchoedSettings($id)
  78. {
  79. return [
  80. '{id}' => $id,
  81. 'APP_ENV' => getenv('APP_ENV'),
  82. 'header' => request()->header('header'),
  83. 'queryParam' => request()->query('queryParam'),
  84. 'bodyParam' => request()->get('bodyParam'),
  85. ];
  86. }
  87. /**
  88. * @response {
  89. * "result": "Лорем ипсум долор сит амет"
  90. * }
  91. */
  92. public function withUtf8ResponseTag()
  93. {
  94. return ['result' => 'Лорем ипсум долор сит амет'];
  95. }
  96. /**
  97. * @hideFromAPIDocumentation
  98. */
  99. public function skip()
  100. {
  101. }
  102. /**
  103. * @response {
  104. * "id": 4,
  105. * "name": "banana",
  106. * "color": "red",
  107. * "weight": "1 kg",
  108. * "delicious": true
  109. * }
  110. */
  111. public function withResponseTag()
  112. {
  113. return '';
  114. }
  115. /**
  116. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  117. */
  118. public function transformerTag()
  119. {
  120. return '';
  121. }
  122. /**
  123. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  124. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  125. */
  126. public function transformerTagWithModel()
  127. {
  128. return '';
  129. }
  130. /**
  131. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  132. */
  133. public function transformerCollectionTag()
  134. {
  135. return '';
  136. }
  137. /**
  138. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  139. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  140. */
  141. public function transformerCollectionTagWithModel()
  142. {
  143. return '';
  144. }
  145. }