docs(api): 完善 WebAPI 文档与 OpenAPI / Swagger 配置#407
Open
ncw1992120 wants to merge 1 commit into
Open
Conversation
Closes mateaix#406 - 新增 OpenApiConfig 全局配置 Bean:标题/描述/服务器 + bearerAuth 安全方案 (覆盖 JWT 与 mc_ PAT,对齐 JwtAuthFilter 前缀分发) - application.yml 增 springdoc default-flat-param-object + mateclaw.openapi.* 外置项 - api.md 中英双语补全「通用约定」(R<T> 信封、ResultCode、错误模型、IPage 分页、 ID 约定、三态认证、X-Workspace-Id 机制)+ 9 个旗舰端点完整参考 - 新增 openapi.md 中英双语 Swagger 使用指南
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Closes #406
背景
项目已有两块 API 文档,但都不完整:
pom.xml已依赖 springdoc-openapi(2.8.16),但没有任何全局 OpenAPI 配置 Bean——Swagger UI 缺标题/描述、没有@SecurityScheme(Authorize 按钮不可用)。docs/{zh,en}/api.md:只是一张 406 行路由表,缺少通用约定(响应信封、错误码、分页、认证模型)和高频端点的完整请求/响应说明。改动
OpenApiConfig.java(新增):全局@ConfigurationBean。Info(标题/版本/描述)+bearerAuth@SecurityScheme(HTTP bearer,覆盖 JWT 与mc_PAT)+ 顶层默认SecurityRequirement。配置项全部@Value注入可外置覆盖。application.yml:springdoc 加default-flat-param-object+ 安全现状注释;新增mateclaw.openapi.{title,version,server-url,description}(全走环境变量)。docs/{zh,en}/api.md:插入「通用约定」章节(R<T>信封、ResultCode状态码表、GlobalExceptionHandler错误模型对照、IPage分页、ID/类型约定、三态认证模型 + 滑动续期、X-Workspace-Id机制)+ 「旗舰端点参考」章节(9 个高频端点完整字段表 + curl)。docs/{zh,en}/openapi.md(新增):Swagger 使用指南(访问地址、Authorize、配置、安全提示)。范围
刻意收窄——不改任何现有 Controller 注解。约 85% 的 Controller 已有
@Tag+@Operation,加全局安全方案后直接受益。@Parameter/@ApiResponse/@Schema增强与 Swagger 门禁属后续。验证
mvn compile通过(dev 基线),OpenApiConfig.class已生成。核对出的事实(已写进文档)
msg不是message——唯一例外是 409ConfirmRequiredException。/swagger-ui*走permitAll()),生产收口应改SecurityConfig。@RequestParam(非 body),路径{id}仅信息性。mc_前缀按前缀分发。1001/2001等)不映射 HTTP 状态,以 HTTP 500 返回。