TestController.php 3.3 KB

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