TestController.php 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130
  1. <?php
  2. namespace Mpociot\ApiDoc\Tests\Fixtures;
  3. use Illuminate\Http\Request;
  4. use Illuminate\Routing\Controller;
  5. class TestController extends Controller
  6. {
  7. public function dummy()
  8. {
  9. return '';
  10. }
  11. /**
  12. * Example title.
  13. * This will be the long description.
  14. * It can also be multiple lines long.
  15. */
  16. public function withEndpointDescription()
  17. {
  18. return '';
  19. }
  20. /**
  21. * @bodyParam user_id int required The id of the user.
  22. * @bodyParam room_id string The id of the room.
  23. */
  24. public function withBodyParameters()
  25. {
  26. return '';
  27. }
  28. /**
  29. * @queryParam location_id required The id of the location.
  30. * @queryParam filters The filters.
  31. */
  32. public function withQueryParameters()
  33. {
  34. return '';
  35. }
  36. public function checkCustomHeaders(Request $request)
  37. {
  38. return $request->headers->all();
  39. }
  40. public function shouldFetchRouteResponse()
  41. {
  42. $fixture = new \stdClass();
  43. $fixture->id = 1;
  44. $fixture->name = 'banana';
  45. $fixture->color = 'red';
  46. $fixture->weight = 300;
  47. $fixture->delicious = 1;
  48. return [
  49. 'id' => (int) $fixture->id,
  50. 'name' => ucfirst($fixture->name),
  51. 'color' => ucfirst($fixture->color),
  52. 'weight' => $fixture->weight.' grams',
  53. 'delicious' => (bool) $fixture->delicious,
  54. ];
  55. }
  56. /**
  57. * @response {
  58. * "result": "Лорем ипсум долор сит амет"
  59. * }
  60. */
  61. public function withUtf8ResponseTag()
  62. {
  63. return ['result' => 'Лорем ипсум долор сит амет'];
  64. }
  65. /**
  66. * @hideFromAPIDocumentation
  67. */
  68. public function skip()
  69. {
  70. }
  71. /**
  72. * @response {
  73. * "id": 4,
  74. * "name": "banana",
  75. * "color": "red",
  76. * "weight": "1 kg",
  77. * "delicious": true
  78. * }
  79. */
  80. public function withResponseTag()
  81. {
  82. return '';
  83. }
  84. /**
  85. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  86. */
  87. public function transformerTag()
  88. {
  89. return '';
  90. }
  91. /**
  92. * @transformer \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  93. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  94. */
  95. public function transformerTagWithModel()
  96. {
  97. return '';
  98. }
  99. /**
  100. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  101. */
  102. public function transformerCollectionTag()
  103. {
  104. return '';
  105. }
  106. /**
  107. * @transformercollection \Mpociot\ApiDoc\Tests\Fixtures\TestTransformer
  108. * @transformermodel \Mpociot\ApiDoc\Tests\Fixtures\TestModel
  109. */
  110. public function transformerCollectionTagWithModel()
  111. {
  112. return '';
  113. }
  114. }