TestController.php 4.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210
  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. * @response 422 {
  119. * "message": "Validation error"
  120. * }
  121. */
  122. public function withResponseTagAndStatusCode()
  123. {
  124. return '';
  125. }
  126. /**
  127. * @response {
  128. * "id": 4,
  129. * "name": "banana",
  130. * "color": "red",
  131. * "weight": "1 kg",
  132. * "delicious": true
  133. * }
  134. * @response 401 {
  135. * "message": "Unauthorized"
  136. * }
  137. */
  138. public function withMultipleResponseTagsAndStatusCode()
  139. {
  140. return '';
  141. }
  142. /**
  143. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  144. */
  145. public function transformerTag()
  146. {
  147. return '';
  148. }
  149. /**
  150. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  151. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  152. */
  153. public function transformerTagWithModel()
  154. {
  155. return '';
  156. }
  157. /**
  158. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  159. */
  160. public function transformerCollectionTag()
  161. {
  162. return '';
  163. }
  164. /**
  165. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  166. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  167. */
  168. public function transformerCollectionTagWithModel()
  169. {
  170. return '';
  171. }
  172. /**
  173. * @responseFile response_test.json
  174. */
  175. public function responseFileTag()
  176. {
  177. return '';
  178. }
  179. /**
  180. * @responseFile response_test.json
  181. * @responseFile 401 response_error_test.json
  182. */
  183. public function withResponseFileTagAndStatusCode()
  184. {
  185. return '';
  186. }
  187. }