TestController.php 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257
  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. * @queryParam url_encoded Used for testing that URL parameters will be URL-encoded where needed. Example: + []&=
  69. */
  70. public function withQueryParameters()
  71. {
  72. return '';
  73. }
  74. /**
  75. * @authenticated
  76. */
  77. public function withAuthenticatedTag()
  78. {
  79. return '';
  80. }
  81. public function checkCustomHeaders(Request $request)
  82. {
  83. return $request->headers->all();
  84. }
  85. public function shouldFetchRouteResponse()
  86. {
  87. $fruit = new \stdClass();
  88. $fruit->id = 4;
  89. $fruit->name = ' banana ';
  90. $fruit->color = 'RED';
  91. $fruit->weight = 1;
  92. $fruit->delicious = true;
  93. return [
  94. 'id' => (int) $fruit->id,
  95. 'name' => trim($fruit->name),
  96. 'color' => strtolower($fruit->color),
  97. 'weight' => $fruit->weight.' kg',
  98. 'delicious' => $fruit->delicious,
  99. ];
  100. }
  101. public function echoesConfig()
  102. {
  103. return [
  104. 'app.env' => config('app.env'),
  105. ];
  106. }
  107. public function echoesUrlPathParameters($param)
  108. {
  109. return [
  110. 'param' => $param,
  111. ];
  112. }
  113. public function shouldFetchRouteResponseWithEchoedSettings($id)
  114. {
  115. return [
  116. '{id}' => $id,
  117. 'APP_ENV' => getenv('APP_ENV'),
  118. 'header' => request()->header('header'),
  119. 'queryParam' => request()->query('queryParam'),
  120. 'bodyParam' => request()->get('bodyParam'),
  121. ];
  122. }
  123. /**
  124. * @response {
  125. * "result": "Лорем ипсум долор сит амет"
  126. * }
  127. */
  128. public function withUtf8ResponseTag()
  129. {
  130. return ['result' => 'Лорем ипсум долор сит амет'];
  131. }
  132. /**
  133. * @hideFromAPIDocumentation
  134. */
  135. public function skip()
  136. {
  137. }
  138. /**
  139. * @response {
  140. * "id": 4,
  141. * "name": "banana",
  142. * "color": "red",
  143. * "weight": "1 kg",
  144. * "delicious": true
  145. * }
  146. */
  147. public function withResponseTag()
  148. {
  149. return '';
  150. }
  151. /**
  152. * @response 422 {
  153. * "message": "Validation error"
  154. * }
  155. */
  156. public function withResponseTagAndStatusCode()
  157. {
  158. return '';
  159. }
  160. /**
  161. * @response {
  162. * "id": 4,
  163. * "name": "banana",
  164. * "color": "red",
  165. * "weight": "1 kg",
  166. * "delicious": true
  167. * }
  168. * @response 401 {
  169. * "message": "Unauthorized"
  170. * }
  171. */
  172. public function withMultipleResponseTagsAndStatusCode()
  173. {
  174. return '';
  175. }
  176. /**
  177. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  178. */
  179. public function transformerTag()
  180. {
  181. return '';
  182. }
  183. /**
  184. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  185. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  186. */
  187. public function transformerTagWithModel()
  188. {
  189. return '';
  190. }
  191. /**
  192. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  193. */
  194. public function transformerCollectionTag()
  195. {
  196. return '';
  197. }
  198. /**
  199. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  200. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  201. */
  202. public function transformerCollectionTagWithModel()
  203. {
  204. return '';
  205. }
  206. /**
  207. * @responseFile response_test.json
  208. */
  209. public function responseFileTag()
  210. {
  211. return '';
  212. }
  213. /**
  214. * @responseFile response_test.json
  215. * @responseFile 401 response_error_test.json
  216. */
  217. public function withResponseFileTagAndStatusCode()
  218. {
  219. return '';
  220. }
  221. /**
  222. * @responseFile response_test.json {"message" : "Serendipity"}
  223. */
  224. public function responseFileTagAndCustomJson()
  225. {
  226. return '';
  227. }
  228. }