TestController.php 5.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256
  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 echoesConfig()
  101. {
  102. return [
  103. 'app.env' => config('app.env'),
  104. ];
  105. }
  106. public function echoesUrlPathParameters($param)
  107. {
  108. return [
  109. 'param' => $param,
  110. ];
  111. }
  112. public function shouldFetchRouteResponseWithEchoedSettings($id)
  113. {
  114. return [
  115. '{id}' => $id,
  116. 'APP_ENV' => getenv('APP_ENV'),
  117. 'header' => request()->header('header'),
  118. 'queryParam' => request()->query('queryParam'),
  119. 'bodyParam' => request()->get('bodyParam'),
  120. ];
  121. }
  122. /**
  123. * @response {
  124. * "result": "Лорем ипсум долор сит амет"
  125. * }
  126. */
  127. public function withUtf8ResponseTag()
  128. {
  129. return ['result' => 'Лорем ипсум долор сит амет'];
  130. }
  131. /**
  132. * @hideFromAPIDocumentation
  133. */
  134. public function skip()
  135. {
  136. }
  137. /**
  138. * @response {
  139. * "id": 4,
  140. * "name": "banana",
  141. * "color": "red",
  142. * "weight": "1 kg",
  143. * "delicious": true
  144. * }
  145. */
  146. public function withResponseTag()
  147. {
  148. return '';
  149. }
  150. /**
  151. * @response 422 {
  152. * "message": "Validation error"
  153. * }
  154. */
  155. public function withResponseTagAndStatusCode()
  156. {
  157. return '';
  158. }
  159. /**
  160. * @response {
  161. * "id": 4,
  162. * "name": "banana",
  163. * "color": "red",
  164. * "weight": "1 kg",
  165. * "delicious": true
  166. * }
  167. * @response 401 {
  168. * "message": "Unauthorized"
  169. * }
  170. */
  171. public function withMultipleResponseTagsAndStatusCode()
  172. {
  173. return '';
  174. }
  175. /**
  176. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  177. */
  178. public function transformerTag()
  179. {
  180. return '';
  181. }
  182. /**
  183. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  184. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  185. */
  186. public function transformerTagWithModel()
  187. {
  188. return '';
  189. }
  190. /**
  191. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  192. */
  193. public function transformerCollectionTag()
  194. {
  195. return '';
  196. }
  197. /**
  198. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  199. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  200. */
  201. public function transformerCollectionTagWithModel()
  202. {
  203. return '';
  204. }
  205. /**
  206. * @responseFile response_test.json
  207. */
  208. public function responseFileTag()
  209. {
  210. return '';
  211. }
  212. /**
  213. * @responseFile response_test.json
  214. * @responseFile 401 response_error_test.json
  215. */
  216. public function withResponseFileTagAndStatusCode()
  217. {
  218. return '';
  219. }
  220. /**
  221. * @responseFile response_test.json {"message" : "Serendipity"}
  222. */
  223. public function responseFileTagAndCustomJson()
  224. {
  225. return '';
  226. }
  227. }