v2-user-user.yaml 7.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-user-user.yaml
  2. get:
  3. summary: 查看单个用户
  4. tags:
  5. - user
  6. operationId: get_api_v2_user_user_
  7. description: |-
  8. 按 userid 查询用户资料并返回(id、用户名、昵称、邮箱、角色、头像等)。
  9. 方法内没有任何鉴权,任何人都可以读取;查不到用户时会以空资源返回。
  10. 实现:`UserController@show`
  11. parameters:
  12. -
  13. name: user
  14. in: path
  15. required: true
  16. schema:
  17. type: integer
  18. description: '用户的 userid(不是表自增主键 id)'
  19. responses:
  20. 200:
  21. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  22. content:
  23. application/json:
  24. schema:
  25. type: object
  26. properties:
  27. ok:
  28. type: boolean
  29. message:
  30. type: string
  31. data:
  32. type: object
  33. properties:
  34. id:
  35. type: integer
  36. userName:
  37. type: string
  38. nickName:
  39. type: string
  40. email:
  41. type: string
  42. role:
  43. type: string
  44. created_at:
  45. type: string
  46. updated_at:
  47. type: string
  48. avatarName:
  49. type: string
  50. avatar:
  51. type: string
  52. 401:
  53. $ref: '../../main.yaml#/components/responses/Unauthorized'
  54. 422:
  55. $ref: '../../main.yaml#/components/responses/ValidationError'
  56. put:
  57. summary: 更新用户资料或角色
  58. tags:
  59. - user
  60. operationId: put_api_v2_user_user_
  61. description: |-
  62. 两种互斥的用法:请求体里带 roles 时只更新角色(整体覆盖,以 JSON 存入 role 字段);
  63. 不带 roles 时更新昵称、头像、邮箱三个字段(未传的会被置空)。
  64. 方法内没有任何鉴权,也没有校验,调用方需自行保证权限;userid 不存在时会报错。
  65. 实现:`UserController@update`
  66. parameters:
  67. -
  68. name: user
  69. in: path
  70. required: true
  71. schema:
  72. type: integer
  73. description: '用户的 userid(不是表自增主键 id)'
  74. requestBody:
  75. required: false
  76. content:
  77. application/json:
  78. schema:
  79. type: object
  80. properties:
  81. roles:
  82. type: array
  83. description: 角色列表,传了就只更新角色,整体覆盖原有角色
  84. nickName:
  85. type: string
  86. description: '昵称,未传 roles 时生效'
  87. avatar:
  88. type: string
  89. description: '头像文件名,未传 roles 时生效'
  90. email:
  91. type: string
  92. description: '邮箱,未传 roles 时生效'
  93. responses:
  94. 200:
  95. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  96. content:
  97. application/json:
  98. schema:
  99. type: object
  100. properties:
  101. ok:
  102. type: boolean
  103. message:
  104. type: string
  105. data:
  106. type: object
  107. properties:
  108. id:
  109. type: integer
  110. userName:
  111. type: string
  112. nickName:
  113. type: string
  114. email:
  115. type: string
  116. role:
  117. type: string
  118. created_at:
  119. type: string
  120. updated_at:
  121. type: string
  122. avatarName:
  123. type: string
  124. avatar:
  125. type: string
  126. 401:
  127. $ref: '../../main.yaml#/components/responses/Unauthorized'
  128. 422:
  129. $ref: '../../main.yaml#/components/responses/ValidationError'
  130. patch:
  131. summary: 更新用户资料或角色
  132. tags:
  133. - user
  134. operationId: patch_api_v2_user_user_
  135. description: |-
  136. 两种互斥的用法:请求体里带 roles 时只更新角色(整体覆盖,以 JSON 存入 role 字段);
  137. 不带 roles 时更新昵称、头像、邮箱三个字段(未传的会被置空)。
  138. 方法内没有任何鉴权,也没有校验,调用方需自行保证权限;userid 不存在时会报错。
  139. 实现:`UserController@update`
  140. parameters:
  141. -
  142. name: user
  143. in: path
  144. required: true
  145. schema:
  146. type: integer
  147. description: '用户的 userid(不是表自增主键 id)'
  148. requestBody:
  149. required: false
  150. content:
  151. application/json:
  152. schema:
  153. type: object
  154. properties:
  155. roles:
  156. type: array
  157. description: 角色列表,传了就只更新角色,整体覆盖原有角色
  158. nickName:
  159. type: string
  160. description: '昵称,未传 roles 时生效'
  161. avatar:
  162. type: string
  163. description: '头像文件名,未传 roles 时生效'
  164. email:
  165. type: string
  166. description: '邮箱,未传 roles 时生效'
  167. responses:
  168. 200:
  169. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  170. content:
  171. application/json:
  172. schema:
  173. type: object
  174. properties:
  175. ok:
  176. type: boolean
  177. message:
  178. type: string
  179. data:
  180. type: object
  181. properties:
  182. id:
  183. type: integer
  184. userName:
  185. type: string
  186. nickName:
  187. type: string
  188. email:
  189. type: string
  190. role:
  191. type: string
  192. created_at:
  193. type: string
  194. updated_at:
  195. type: string
  196. avatarName:
  197. type: string
  198. avatar:
  199. type: string
  200. 401:
  201. $ref: '../../main.yaml#/components/responses/Unauthorized'
  202. 422:
  203. $ref: '../../main.yaml#/components/responses/ValidationError'
  204. delete:
  205. summary: 删除用户(未实现)
  206. tags:
  207. - user
  208. operationId: delete_api_v2_user_user_
  209. description: |-
  210. 路由已注册 DELETE /api/v2/user/{user},但方法体为空,不会删除任何数据也不返回内容。
  211. 实现:`UserController@destroy`
  212. parameters:
  213. -
  214. name: user
  215. in: path
  216. required: true
  217. schema:
  218. type: integer
  219. description: '用户的 userid'
  220. responses:
  221. 200:
  222. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  223. content:
  224. application/json:
  225. schema:
  226. type: object
  227. properties:
  228. ok:
  229. type: boolean
  230. message:
  231. type: string
  232. data:
  233. type: object
  234. 401:
  235. $ref: '../../main.yaml#/components/responses/Unauthorized'
  236. 422:
  237. $ref: '../../main.yaml#/components/responses/ValidationError'