TestController.php 5.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237
  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. /**
  53. * @bodyParam direct_one string Is found directly on the method.
  54. */
  55. public function withNonCommentedFormRequestParameter(TestNonCommentedRequest $request)
  56. {
  57. return '';
  58. }
  59. /**
  60. * @queryParam location_id required The id of the location.
  61. * @queryParam user_id required The id of the user. Example: me
  62. * @queryParam page required The page number. Example: 4
  63. * @queryParam filters The filters.
  64. */
  65. public function withQueryParameters()
  66. {
  67. return '';
  68. }
  69. /**
  70. * @authenticated
  71. */
  72. public function withAuthenticatedTag()
  73. {
  74. return '';
  75. }
  76. public function checkCustomHeaders(Request $request)
  77. {
  78. return $request->headers->all();
  79. }
  80. public function shouldFetchRouteResponse()
  81. {
  82. $fruit = new \stdClass();
  83. $fruit->id = 4;
  84. $fruit->name = ' banana ';
  85. $fruit->color = 'RED';
  86. $fruit->weight = 1;
  87. $fruit->delicious = true;
  88. return [
  89. 'id' => (int) $fruit->id,
  90. 'name' => trim($fruit->name),
  91. 'color' => strtolower($fruit->color),
  92. 'weight' => $fruit->weight.' kg',
  93. 'delicious' => $fruit->delicious,
  94. ];
  95. }
  96. public function shouldFetchRouteResponseWithEchoedSettings($id)
  97. {
  98. return [
  99. '{id}' => $id,
  100. 'APP_ENV' => getenv('APP_ENV'),
  101. 'header' => request()->header('header'),
  102. 'queryParam' => request()->query('queryParam'),
  103. 'bodyParam' => request()->get('bodyParam'),
  104. ];
  105. }
  106. /**
  107. * @response {
  108. * "result": "Лорем ипсум долор сит амет"
  109. * }
  110. */
  111. public function withUtf8ResponseTag()
  112. {
  113. return ['result' => 'Лорем ипсум долор сит амет'];
  114. }
  115. /**
  116. * @hideFromAPIDocumentation
  117. */
  118. public function skip()
  119. {
  120. }
  121. /**
  122. * @response {
  123. * "id": 4,
  124. * "name": "banana",
  125. * "color": "red",
  126. * "weight": "1 kg",
  127. * "delicious": true
  128. * }
  129. */
  130. public function withResponseTag()
  131. {
  132. return '';
  133. }
  134. /**
  135. * @response 422 {
  136. * "message": "Validation error"
  137. * }
  138. */
  139. public function withResponseTagAndStatusCode()
  140. {
  141. return '';
  142. }
  143. /**
  144. * @response {
  145. * "id": 4,
  146. * "name": "banana",
  147. * "color": "red",
  148. * "weight": "1 kg",
  149. * "delicious": true
  150. * }
  151. * @response 401 {
  152. * "message": "Unauthorized"
  153. * }
  154. */
  155. public function withMultipleResponseTagsAndStatusCode()
  156. {
  157. return '';
  158. }
  159. /**
  160. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  161. */
  162. public function transformerTag()
  163. {
  164. return '';
  165. }
  166. /**
  167. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  168. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  169. */
  170. public function transformerTagWithModel()
  171. {
  172. return '';
  173. }
  174. /**
  175. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  176. */
  177. public function transformerCollectionTag()
  178. {
  179. return '';
  180. }
  181. /**
  182. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  183. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  184. */
  185. public function transformerCollectionTagWithModel()
  186. {
  187. return '';
  188. }
  189. /**
  190. * @responseFile response_test.json
  191. */
  192. public function responseFileTag()
  193. {
  194. return '';
  195. }
  196. /**
  197. * @responseFile response_test.json
  198. * @responseFile 401 response_error_test.json
  199. */
  200. public function withResponseFileTagAndStatusCode()
  201. {
  202. return '';
  203. }
  204. /**
  205. * @responseFile response_test.json {"message" : "Serendipity"}
  206. */
  207. public function responseFileTagAndCustomJson()
  208. {
  209. return '';
  210. }
  211. }