在 bookmark.yaml 配置文件中,为多个接口路径添加了 '401' 和 '403' 状态码的响应引用, 分别指向 components 中定义的 Unauthorized 和 Forbidden 响应。同时在 components 部分补充了 Forbidden 响应的定义,增强了 API 文档的完整性与规范性。 feat(user_np): 新增用户信息接口与基础错误结构定义 在 user_np.yaml 中新增了 /auth/info 路径下的 GET 和 PUT 接口,用于获取和保存用户信息。 同时,在 components 中定义了 ServerInternalError 响应和 Error 结构体,统一错误返回格式, 提升接口一致性与可维护性。 feat(vfs): 调整内容类型为 text/plain 并增强节点名称校验逻辑 将 vfs.yaml 中涉及二进制流传输的内容类型由 application/octet-stream 修改为 text/plain, 简化数据处理方式。同时在 vfs.go 模型中新增 CheckNameValid 方法,用于校验节点名称合法性, 防止非法字符(如斜杠)造成路径问题。 refactor(bookmark): 优化 API Key 验证逻辑并暴露更新时间字段 重构 BookMarksImpl 的 validateApiKey 函数,简化认证判断流程,并将 adminToken 从指针改为字符串常量。 此外,在 bookmarkModel2Res 函数中新增 UpdatedAt 字段,使书签响应包含更新时间信息。 feat(user_np): 实现用户信息相关接口占位函数 在 UserNPImpl 中新增 GetUserInfo 和 SaveUserInfo 两个方法的占位实现,为后续业务逻辑开发做好准备。 refactor(vfs): 使用文本请求体并加强服务节点操作校验 修改 vfs_impl.go 中读取请求体的方式,由 io.Reader 改为直接解引用文本内容,提升处理效率。 更新 CreateVFSNode、GetVFSNode 和 UpdateVFSNode 方法中对请求体和响应体的处理逻辑, 统一使用文本格式,增强代码一致性与健壮性。 feat(vfs): 为书签代理服务添加认证 Token 支持 在 vfs_bookmark.go 中为 VfsBookMarkService 结构体增加 token 字段,并在调用 bookmark 服务各接口时, 通过 HTTP 请求头设置 X-BookMark-Token,确保服务间通信的安全性与权限控制。
184 lines
4.1 KiB
YAML
184 lines
4.1 KiB
YAML
openapi: '3.0.3'
|
|
info:
|
|
title: zzyxyz_user_np_api
|
|
description: 用户节点权限相关操作(user_name and password)
|
|
version: '1.0'
|
|
servers:
|
|
- url: http://localhost:8081/api
|
|
description: 开发环境
|
|
- url: https://api.zzyxyz.com/api
|
|
description: 生产环境
|
|
security:
|
|
- ApiKeyAuth: []
|
|
|
|
paths:
|
|
/auth/login:
|
|
post:
|
|
summary: 用户登录
|
|
description: 使用用户名和密码进行登录
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/LoginRequest'
|
|
responses:
|
|
'200':
|
|
description: 登录成功
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/LoginResponse'
|
|
'400':
|
|
description: 请求参数错误
|
|
'401':
|
|
description: 认证失败
|
|
|
|
/auth/register:
|
|
post:
|
|
summary: 用户注册
|
|
description: 创建新用户账户
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/RegisterRequest'
|
|
responses:
|
|
'201':
|
|
description: 注册成功
|
|
'400':
|
|
description: 请求参数错误
|
|
'409':
|
|
description: 用户名已存在
|
|
|
|
/auth/password:
|
|
put:
|
|
summary: 修改密码
|
|
description: 修改已登录用户的密码
|
|
security:
|
|
- ApiKeyAuth: []
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/ChangePasswordRequest'
|
|
responses:
|
|
'200':
|
|
description: 密码修改成功
|
|
'400':
|
|
description: 请求参数错误
|
|
'401':
|
|
description: 认证失败
|
|
|
|
/auth/info:
|
|
get:
|
|
summary: 获取用户信息
|
|
description: 获取用户信息 json object
|
|
operationId: getUserInfo
|
|
tags: [auth]
|
|
responses:
|
|
'200':
|
|
description: 用户信息
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
'500':
|
|
$ref: '#/components/responses/ServerInternalError'
|
|
put:
|
|
summary: 保存用户信息
|
|
description: 保存用户信息 json object
|
|
operationId: saveUserInfo
|
|
tags: [auth]
|
|
requestBody:
|
|
required: true
|
|
content:
|
|
application/json:
|
|
schema:
|
|
type: object
|
|
responses:
|
|
'200':
|
|
description: 保存成功
|
|
'500':
|
|
$ref: '#/components/responses/ServerInternalError'
|
|
|
|
components:
|
|
responses:
|
|
ServerInternalError:
|
|
description: 服务器内部错误
|
|
content:
|
|
application/json:
|
|
schema:
|
|
$ref: '#/components/schemas/Error'
|
|
schemas:
|
|
LoginRequest:
|
|
type: object
|
|
required:
|
|
- username
|
|
- password
|
|
properties:
|
|
username:
|
|
type: string
|
|
password:
|
|
type: string
|
|
|
|
LoginResponse:
|
|
type: object
|
|
properties:
|
|
token:
|
|
type: string
|
|
user_id:
|
|
type: integer
|
|
format: int64
|
|
|
|
RegisterRequest:
|
|
type: object
|
|
required:
|
|
- username
|
|
- password
|
|
properties:
|
|
username:
|
|
type: string
|
|
password:
|
|
type: string
|
|
email:
|
|
type: string
|
|
|
|
ChangePasswordRequest:
|
|
type: object
|
|
required:
|
|
- old_password
|
|
- new_password
|
|
- user_name
|
|
properties:
|
|
old_password:
|
|
type: string
|
|
new_password:
|
|
type: string
|
|
user_name:
|
|
type: string
|
|
|
|
Error:
|
|
type: object
|
|
description: 错误信息
|
|
properties:
|
|
errtype:
|
|
type: string
|
|
example: "ParameterError"
|
|
description: 错误类型
|
|
message:
|
|
example: "传递的第一个参数错误"
|
|
type: string
|
|
description: 错误信息
|
|
required:
|
|
- errtype
|
|
- message
|
|
|
|
securitySchemes:
|
|
ApiKeyAuth:
|
|
type: apiKey
|
|
in: header
|
|
name: Authorization
|