TestController.php 6.1 KB

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