TestController.php 6.3 KB

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