ArticlesController.php 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | ThinkCMF [ WE CAN DO IT MORE SIMPLE ]
  4. // +----------------------------------------------------------------------
  5. // | Copyright (c) 2013-2017 http://www.thinkcmf.com All rights reserved.
  6. // +----------------------------------------------------------------------
  7. // | Author: pl125 <xskjs888@163.com>
  8. // +----------------------------------------------------------------------
  9. namespace api\demo\controller;
  10. use cmf\controller\RestBaseController;
  11. use OpenApi\Annotations as OA;
  12. /**
  13. * Class ArticlesController
  14. * @package api\demo\controller
  15. */
  16. class ArticlesController extends RestBaseController
  17. {
  18. /**
  19. * @OA\Get(
  20. * tags={"demo"},
  21. * path="/demo/articles",
  22. * @OA\Parameter(
  23. * name="page",
  24. * in="query",
  25. * description="page param",
  26. * required=false,
  27. * @OA\Schema(
  28. * type="string",
  29. * )
  30. * ),
  31. * @OA\Response(
  32. * response="200",
  33. * description="success",
  34. * @OA\JsonContent(
  35. * example={
  36. * "id": "a3fb6",
  37. * "name": "sss"
  38. * },
  39. * ref="#/components/schemas/DemoArticlesIndexResponse"
  40. * )
  41. * ),
  42. * @OA\Response(
  43. * response="default",
  44. * description="error operation",
  45. * @OA\JsonContent(ref="#/components/schemas/ErrorResponse")
  46. * ),
  47. * )
  48. */
  49. public function index()
  50. {
  51. $articles = [
  52. ['title' => 'article title1'],
  53. ['title' => 'article title2'],
  54. ];
  55. $this->success('请求成功!', ['articles' => $articles]);
  56. }
  57. /**
  58. * @OA\Post(
  59. * tags={"demo"},
  60. * path="/demo/articles",
  61. * @OA\RequestBody(
  62. * required=true,
  63. * description="Created user object",
  64. * @OA\MediaType(
  65. * mediaType="application/x-www-form-urlencoded",
  66. * @OA\Schema(ref="#/components/schemas/DemoArticlesSave")
  67. * )
  68. * ),
  69. * @OA\Response(response="200", description="An example resource"),
  70. * @OA\Response(response="default", description="An example resource")
  71. * )
  72. */
  73. public function save()
  74. {
  75. }
  76. /**
  77. * @OA\Get(
  78. * tags={"demo"},
  79. * path="/demo/articles/{id}",
  80. * @OA\Parameter(
  81. * name="id",
  82. * in="path",
  83. * description="articles id",
  84. * required=true,
  85. * @OA\Schema(
  86. * type="string",
  87. * )
  88. * ),
  89. * @OA\Response(response="200", description="An example resource"),
  90. * @OA\Response(response="default", description="An example resource")
  91. * )
  92. */
  93. public function read($id)
  94. {
  95. }
  96. /**
  97. * @OA\Put(
  98. * tags={"demo"},
  99. * path="/demo/articles/{id}",
  100. * @OA\Parameter(
  101. * name="id",
  102. * in="path",
  103. * description="articles id",
  104. * required=true,
  105. * @OA\Schema(
  106. * type="string",
  107. * )
  108. * ),
  109. * @OA\Response(
  110. * response="200",
  111. * description="success",
  112. * @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  113. * ),
  114. * @OA\Response(
  115. * response="default",
  116. * description="error operation",
  117. * @OA\JsonContent(ref="#/components/schemas/ErrorResponse")
  118. * ),
  119. * )
  120. */
  121. public function update($id)
  122. {
  123. }
  124. /**
  125. * @OA\Delete(
  126. * tags={"demo"},
  127. * path="/demo/articles/{id}",
  128. * @OA\Parameter(
  129. * name="id",
  130. * in="path",
  131. * description="articles id",
  132. * required=true,
  133. * @OA\Schema(
  134. * type="string",
  135. * )
  136. * ),
  137. * @OA\Response(
  138. * response="200",
  139. * description="success",
  140. * @OA\JsonContent(ref="#/components/schemas/SuccessResponse")
  141. * ),
  142. * @OA\Response(
  143. * response="default",
  144. * description="error operation",
  145. * @OA\JsonContent(ref="#/components/schemas/ErrorResponse")
  146. * ),
  147. * )
  148. */
  149. public function delete($id)
  150. {
  151. }
  152. }