TestController.php 6.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289
  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. * This is also in Group B. No route description. Route title before gropp.
  32. *
  33. * @group Group B
  34. */
  35. public function withGroupOverride2()
  36. {
  37. return '';
  38. }
  39. /**
  40. * @group Group B
  41. *
  42. * This is also in Group B. Route title after group.
  43. */
  44. public function withGroupOverride3()
  45. {
  46. return '';
  47. }
  48. /**
  49. * This is in Group C. Route title before group.
  50. *
  51. * @group Group C
  52. *
  53. * Group description after group.
  54. */
  55. public function withGroupOverride4()
  56. {
  57. return '';
  58. }
  59. /**
  60. * @bodyParam user_id int required The id of the user. Example: 9
  61. * @bodyParam room_id string The id of the room.
  62. * @bodyParam forever boolean Whether to ban the user forever. Example: false
  63. * @bodyParam another_one number Just need something here.
  64. * @bodyParam yet_another_param object required
  65. * @bodyParam even_more_param array
  66. * @bodyParam book.name string
  67. * @bodyParam book.author_id integer
  68. * @bodyParam book[pages_count] integer
  69. * @bodyParam ids.* integer
  70. * @bodyParam users.*.first_name string The first name of the user. Example: John
  71. * @bodyParam users.*.last_name string The last name of the user. Example: Doe
  72. */
  73. public function withBodyParameters()
  74. {
  75. return '';
  76. }
  77. public function withFormRequestParameter(TestRequest $request)
  78. {
  79. return '';
  80. }
  81. public function withMultipleFormRequestParameters(string $test, TestRequest $request)
  82. {
  83. return '';
  84. }
  85. /**
  86. * @bodyParam direct_one string Is found directly on the method.
  87. */
  88. public function withNonCommentedFormRequestParameter(TestNonCommentedRequest $request)
  89. {
  90. return '';
  91. }
  92. /**
  93. * @queryParam location_id required The id of the location.
  94. * @queryParam user_id required The id of the user. Example: me
  95. * @queryParam page required The page number. Example: 4
  96. * @queryParam filters The filters.
  97. * @queryParam url_encoded Used for testing that URL parameters will be URL-encoded where needed. Example: + []&=
  98. */
  99. public function withQueryParameters()
  100. {
  101. return '';
  102. }
  103. /**
  104. * @authenticated
  105. */
  106. public function withAuthenticatedTag()
  107. {
  108. return '';
  109. }
  110. public function checkCustomHeaders(Request $request)
  111. {
  112. return $request->headers->all();
  113. }
  114. public function shouldFetchRouteResponse()
  115. {
  116. $fruit = new \stdClass();
  117. $fruit->id = 4;
  118. $fruit->name = ' banana ';
  119. $fruit->color = 'RED';
  120. $fruit->weight = 1;
  121. $fruit->delicious = true;
  122. return [
  123. 'id' => (int) $fruit->id,
  124. 'name' => trim($fruit->name),
  125. 'color' => strtolower($fruit->color),
  126. 'weight' => $fruit->weight.' kg',
  127. 'delicious' => $fruit->delicious,
  128. ];
  129. }
  130. public function echoesConfig()
  131. {
  132. return [
  133. 'app.env' => config('app.env'),
  134. ];
  135. }
  136. public function echoesUrlPathParameters($param)
  137. {
  138. return [
  139. 'param' => $param,
  140. ];
  141. }
  142. public function shouldFetchRouteResponseWithEchoedSettings($id)
  143. {
  144. return [
  145. '{id}' => $id,
  146. 'APP_ENV' => getenv('APP_ENV'),
  147. 'header' => request()->header('header'),
  148. 'queryParam' => request()->query('queryParam'),
  149. 'bodyParam' => request()->get('bodyParam'),
  150. ];
  151. }
  152. /**
  153. * @response {
  154. * "result": "Лорем ипсум долор сит амет"
  155. * }
  156. */
  157. public function withUtf8ResponseTag()
  158. {
  159. return ['result' => 'Лорем ипсум долор сит амет'];
  160. }
  161. /**
  162. * @hideFromAPIDocumentation
  163. */
  164. public function skip()
  165. {
  166. }
  167. /**
  168. * @response {
  169. * "id": 4,
  170. * "name": "banana",
  171. * "color": "red",
  172. * "weight": "1 kg",
  173. * "delicious": true
  174. * }
  175. */
  176. public function withResponseTag()
  177. {
  178. return '';
  179. }
  180. /**
  181. * @response 422 {
  182. * "message": "Validation error"
  183. * }
  184. */
  185. public function withResponseTagAndStatusCode()
  186. {
  187. return '';
  188. }
  189. /**
  190. * @response {
  191. * "id": 4,
  192. * "name": "banana",
  193. * "color": "red",
  194. * "weight": "1 kg",
  195. * "delicious": true
  196. * }
  197. * @response 401 {
  198. * "message": "Unauthorized"
  199. * }
  200. */
  201. public function withMultipleResponseTagsAndStatusCode()
  202. {
  203. return '';
  204. }
  205. /**
  206. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  207. */
  208. public function transformerTag()
  209. {
  210. return '';
  211. }
  212. /**
  213. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  214. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  215. */
  216. public function transformerTagWithModel()
  217. {
  218. return '';
  219. }
  220. /**
  221. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  222. */
  223. public function transformerCollectionTag()
  224. {
  225. return '';
  226. }
  227. /**
  228. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  229. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  230. */
  231. public function transformerCollectionTagWithModel()
  232. {
  233. return '';
  234. }
  235. /**
  236. * @responseFile response_test.json
  237. */
  238. public function responseFileTag()
  239. {
  240. return '';
  241. }
  242. /**
  243. * @responseFile response_test.json
  244. * @responseFile 401 response_error_test.json
  245. */
  246. public function withResponseFileTagAndStatusCode()
  247. {
  248. return '';
  249. }
  250. /**
  251. * @responseFile response_test.json {"message" : "Serendipity"}
  252. */
  253. public function responseFileTagAndCustomJson()
  254. {
  255. return '';
  256. }
  257. }