swagger-api / swagger-api/swagger-core

Support Composed Constraints

Open
#4,799 2 comments 1 reaction 0 assignees View on GitHub

Nobody has claimed this yet.

backlog
Dominant language
Java
Stars
7.5k
Forks
2.3k
Avg merge
18h 1m
Merged PRs (30d)
10

Description

Jakarta Bean Validation allows to compose constraints as described in 3.3. Constraint composition.

I'd like to implement basic support for this. My idea would be to add a preprocessing step to https://github.com/swagger-api/swagger-core/blob/df88c8a8ebaae1cb8ec39d1af295d07620dcaf87/modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java#L1560

which flattens all Annotations. That means: when an annotation is annotated with javax.validation.Constraint, all its annotations are treated as if all annotations are on the annotated element.

This has been requested as feature e.g. in https://github.com/springdoc/springdoc-openapi/issues/1486

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in modules/swagger-core/src/main/java/io/swagger/v3/core/jackson/ModelResolver.java around line 1560, and read Jakarta Bean Validation 3.0 section 3.3 on constraint composition. Define the preprocessing behavior for annotations marked with javax.validation.Constraint; done means composed annotations are treated as annotations on the annotated element.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, backend-api-design
Issue type
Feature
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.