v2-user.yaml 3.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126
  1. # 由 openapi/scripts/generate.php 生成,请勿手改;补充写到 overrides/v2-user.yaml
  2. get:
  3. summary: 列出用户
  4. tags:
  5. - user
  6. operationId: get_api_v2_user
  7. description: |-
  8. 按 view 指定的口径返回用户列表,支持按昵称搜索、按角色过滤、分页与排序。
  9. 注意:view 只识别 key 和 all 两个值,传其他值或不传会因为查询对象未初始化而报错。
  10. 实现:`UserController@index`
  11. parameters:
  12. -
  13. name: view
  14. in: query
  15. schema:
  16. type: string
  17. enum:
  18. - key
  19. - all
  20. description: 查询口径。key=按关键字匹配用户名或昵称;all=全部用户
  21. required: true
  22. -
  23. name: key
  24. in: query
  25. schema:
  26. type: string
  27. description: 'view=key 时的关键字,同时模糊匹配 username 与 nickname'
  28. -
  29. name: search
  30. in: query
  31. schema:
  32. type: string
  33. description: '按昵称再做一次模糊过滤(nickname like %search%)'
  34. -
  35. name: role
  36. in: query
  37. schema:
  38. type: string
  39. description: '按角色过滤,匹配 role 这个 JSON 数组中是否包含该值'
  40. example: admin
  41. -
  42. name: order
  43. in: query
  44. schema:
  45. type: string
  46. default: username
  47. description: 排序字段
  48. -
  49. name: dir
  50. in: query
  51. schema:
  52. type: string
  53. enum:
  54. - asc
  55. - desc
  56. default: desc
  57. description: 排序方向
  58. -
  59. name: offset
  60. in: query
  61. schema:
  62. type: integer
  63. default: 0
  64. description: 分页起始位置
  65. -
  66. name: limit
  67. in: query
  68. schema:
  69. type: integer
  70. default: 20
  71. description: 每页条数
  72. responses:
  73. 200:
  74. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  75. content:
  76. application/json:
  77. schema:
  78. type: object
  79. properties:
  80. ok:
  81. type: boolean
  82. message:
  83. type: string
  84. data:
  85. type: object
  86. properties:
  87. rows:
  88. type: array
  89. items:
  90. type: object
  91. properties: { id: { type: integer }, userName: { type: string }, nickName: { type: string }, email: { type: string }, role: { type: string }, created_at: { type: string }, updated_at: { type: string }, avatarName: { type: string }, avatar: { type: string } }
  92. count:
  93. type: integer
  94. 401:
  95. $ref: '../../main.yaml#/components/responses/Unauthorized'
  96. 422:
  97. $ref: '../../main.yaml#/components/responses/ValidationError'
  98. post:
  99. summary: 新建用户(未实现)
  100. tags:
  101. - user
  102. operationId: post_api_v2_user
  103. description: |-
  104. 路由已注册 POST /api/v2/user,但方法体为空,不做任何事也不返回内容。
  105. 用户注册走认证相关接口,不走这里。
  106. 实现:`UserController@store`
  107. responses:
  108. 200:
  109. description: '成功。业务失败时 HTTP 仍可能为 200,以 ok 字段为准。'
  110. content:
  111. application/json:
  112. schema:
  113. type: object
  114. properties:
  115. ok:
  116. type: boolean
  117. message:
  118. type: string
  119. data:
  120. type: object
  121. 401:
  122. $ref: '../../main.yaml#/components/responses/Unauthorized'
  123. 422:
  124. $ref: '../../main.yaml#/components/responses/ValidationError'