TestController.php 7.4 KB

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