TestController.php 5.4 KB

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