TestController.php 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221
  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. * @bodyParam book.name string
  38. * @bodyParam book.author_id integer
  39. * @bodyParam ids.* integer
  40. */
  41. public function withBodyParameters()
  42. {
  43. return '';
  44. }
  45. /**
  46. * @queryParam location_id required The id of the location.
  47. * @queryParam user_id required The id of the user. Example: me
  48. * @queryParam page required The page number. Example: 4
  49. * @queryParam filters The filters.
  50. */
  51. public function withQueryParameters()
  52. {
  53. return '';
  54. }
  55. /**
  56. * @authenticated
  57. */
  58. public function withAuthenticatedTag()
  59. {
  60. return '';
  61. }
  62. public function checkCustomHeaders(Request $request)
  63. {
  64. return $request->headers->all();
  65. }
  66. public function shouldFetchRouteResponse()
  67. {
  68. $fruit = new \stdClass();
  69. $fruit->id = 4;
  70. $fruit->name = ' banana ';
  71. $fruit->color = 'RED';
  72. $fruit->weight = 1;
  73. $fruit->delicious = true;
  74. return [
  75. 'id' => (int) $fruit->id,
  76. 'name' => trim($fruit->name),
  77. 'color' => strtolower($fruit->color),
  78. 'weight' => $fruit->weight.' kg',
  79. 'delicious' => $fruit->delicious,
  80. ];
  81. }
  82. public function shouldFetchRouteResponseWithEchoedSettings($id)
  83. {
  84. return [
  85. '{id}' => $id,
  86. 'APP_ENV' => getenv('APP_ENV'),
  87. 'header' => request()->header('header'),
  88. 'queryParam' => request()->query('queryParam'),
  89. 'bodyParam' => request()->get('bodyParam'),
  90. ];
  91. }
  92. /**
  93. * @response {
  94. * "result": "Лорем ипсум долор сит амет"
  95. * }
  96. */
  97. public function withUtf8ResponseTag()
  98. {
  99. return ['result' => 'Лорем ипсум долор сит амет'];
  100. }
  101. /**
  102. * @hideFromAPIDocumentation
  103. */
  104. public function skip()
  105. {
  106. }
  107. /**
  108. * @response {
  109. * "id": 4,
  110. * "name": "banana",
  111. * "color": "red",
  112. * "weight": "1 kg",
  113. * "delicious": true
  114. * }
  115. */
  116. public function withResponseTag()
  117. {
  118. return '';
  119. }
  120. /**
  121. * @response 422 {
  122. * "message": "Validation error"
  123. * }
  124. */
  125. public function withResponseTagAndStatusCode()
  126. {
  127. return '';
  128. }
  129. /**
  130. * @response {
  131. * "id": 4,
  132. * "name": "banana",
  133. * "color": "red",
  134. * "weight": "1 kg",
  135. * "delicious": true
  136. * }
  137. * @response 401 {
  138. * "message": "Unauthorized"
  139. * }
  140. */
  141. public function withMultipleResponseTagsAndStatusCode()
  142. {
  143. return '';
  144. }
  145. /**
  146. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  147. */
  148. public function transformerTag()
  149. {
  150. return '';
  151. }
  152. /**
  153. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  154. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  155. */
  156. public function transformerTagWithModel()
  157. {
  158. return '';
  159. }
  160. /**
  161. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  162. */
  163. public function transformerCollectionTag()
  164. {
  165. return '';
  166. }
  167. /**
  168. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  169. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  170. */
  171. public function transformerCollectionTagWithModel()
  172. {
  173. return '';
  174. }
  175. /**
  176. * @responseFile response_test.json
  177. */
  178. public function responseFileTag()
  179. {
  180. return '';
  181. }
  182. /**
  183. * @responseFile response_test.json
  184. * @responseFile 401 response_error_test.json
  185. */
  186. public function withResponseFileTagAndStatusCode()
  187. {
  188. return '';
  189. }
  190. /**
  191. * @responseFile response_test.json {"message" : "Serendipity"}
  192. */
  193. public function responseFileTagAndCustomJson()
  194. {
  195. return '';
  196. }
  197. }