Hacktoberfest 2026:维护者为十月标记出来的 issue,仍然开放、适合新手。 浏览 Hacktoberfest issue

Support extracting Bean Validation constraints from method parameters

未关闭
#1,026 2 条评论 0 个 reaction 已指派 0 人 在 GitHub 查看

@JunggiKim 已经在做这个了。

开始于 2026年4月1日。

  • #1035 来自 @JunggiKim —— 未关闭

评估

难度
5/5
预计耗时
一周以上
新手友好度
45/100
Issue 类型
功能
描述清晰度
基本清楚
活跃度
冷清
技术栈
java, spring

调研方向

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 内容生成。

描述

status: waiting-for-triage

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

Acceptance criteria

  • Supports common Bean Validation annotations on method parameters (@Min, @Max, @Pattern, @NotBlank, etc.)
  • Works for @RequestParam and @PathVariable use 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 模板
  • 阅读贡献指南

从这里开始

  1. 先读完整个 Issue,再读项目的贡献指南。
  2. 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
  3. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

spring-projects/spring-restdocs 的其他 Issue

查看 spring-projects/spring-restdocs 的全部 Issue

相似的 Issue

更多 Java Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。