Support extracting Bean Validation constraints from method parameters
评估
- 难度
- 5/5
- 预计耗时
- 一周以上
- 新手友好度
- 45/100
- Issue 类型
- 功能
- 描述清晰度
- 基本清楚
- 活跃度
- 冷清
调研方向
Start with the existing ConstraintDescriptions.descriptionsForProperty(String) and ConstraintResolver.resolveForProperty(String, Class<?>) entry points, then read the constraints reference documentation linked in the issue. Define and document a method-parameter extraction path that covers the stated annotations and RequestParam and PathVariable cases while preserving the property-based APIs.
由索引模型根据 Issue 内容生成。
描述
First of all, thank you for maintaining Spring REST Docs. I really appreciate the project and your time.
Problem
Spring REST Docs' Bean Validation constraint support is currently property-centric.
ConstraintDescriptions.descriptionsForProperty(String)ConstraintResolver.resolveForProperty(String, Class<?>)
In real controllers, validation is often declared on method parameters (@RequestParam, @PathVariable, etc.), but there is no standard API path to extract/document those constraints.
Example
@Validated
class KeywordController {
@GetMapping("/keywords/{id}")
void getPopularKeywords(
@RequestParam @Min(1) int limit,
@PathVariable @Pattern(regexp = "^[A-Z0-9_-]+$") String id
) {
}
}
Why this matters
Without a standard extraction path for method parameters, generated parameter docs can diverge from runtime validation rules for query/path/form parameters.
Suggested direction
A dedicated API entry point for method-parameter constraints, for example:
- a new helper class (e.g.,
MethodParameterConstraintDescriptions), or - an explicit overload that accepts method/parameter metadata.
The intention is to keep resolution explicit and deterministic, aligned with Spring REST Docs' existing philosophy.
I understand that custom ConstraintResolver is already supported, but the current standard entry point is still property-based (property, Class<?>).
Related context
- Existing nested-path issue: #106
- Related constraint issues: #717, #887
- Current constraints reference docs: https://docs.spring.io/spring-restdocs/reference/documenting-your-api/constraints.html
Acceptance criteria
- Supports common Bean Validation annotations on method parameters (
@Min,@Max,@Pattern,@NotBlank, etc.) - Works for
@RequestParamand@PathVariableuse cases - Keeps backward compatibility with existing property-based APIs
- Clearly documented usage in reference docs
If this direction is acceptable, I would be happy to prepare a PR.
Thank you again for your work on Spring REST Docs.
- 主要语言
- Java
- 星标
- 1.2k
- 派生
- 731
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 没有 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
spring-projects/spring-restdocs 的其他 Issue
-
Provide default descriptions for Hibernate Validator's BitcoinAddress, ISBN, Normalized, UniqueElements, and UUID constraints可能已有人在做 @chuuminggg 于 2 天前认领。 未关闭status: waiting-for-triage
难度 1/5 1-3 小时 新手友好度 25/100
spring-projects/spring-restdocs#1065 ·
-
Upgrade to Spring Framework 7.0.10可能已有人在做 @wilkinsona 于 7 天前认领。 未关闭type: dependency-upgrade
spring-projects/spring-restdocs#1063 · 已指派 1 人 ·
-
Upgrade to Spring Framework 7.1.0-RC1可能已有人在做 @wilkinsona 于 7 天前认领。 未关闭type: dependency-upgrade
spring-projects/spring-restdocs#1062 · 已指派 1 人 ·
-
status: blocked status: waiting-for-triage
难度 4/5 3-5 天 新手友好度 35/100
spring-projects/spring-restdocs#953 · 7 条评论 ·
-
Add support for modifying a URI's path during pre-processing可能重新可做 关联的 PR 已关闭且未合并。 未关闭type: enhancement
难度 3/5 1-2 天 新手友好度 45/100
查看 spring-projects/spring-restdocs 的全部 Issue
相似的 Issue
-
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 72/100
sqlcipher/sqlcipher-android#97 · 1 条评论 ·
-
area-integrations
难度 2/5 1-3 小时 新手友好度 68/100
维护者通常 1 天内回复
-
bug IIIF interoperability
难度 2/5 1-3 小时 新手友好度 72/100
-
难度 2/5 1-3 小时 新手友好度 72/100