Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Conditional @Validated annotation is ignored #2307

Open
2 tasks
mkhayata opened this issue Mar 17, 2018 · 9 comments
Open
2 tasks

Conditional @Validated annotation is ignored #2307

mkhayata opened this issue Mar 17, 2018 · 9 comments

Comments

@mkhayata
Copy link

mkhayata commented Mar 17, 2018

What kind of issue is this?

  • @validated annotation from org.springframework.validation.annotation is ignored by the doc generation of swagger.
  • I'm using the springfox-bean-validators plugin to get @NotNull annotation constraints up in swagger documentation. However, those annotations from JSR-303 do work in conjunction with @validated annotation from org.springframework.validation.annotation package to apply conditional validation constraints on the same model e.g.

In Model class (Entity.java):

@NotNull(message = "Field cannot be null", groups = {ConditionalValidation.class})
private String someField;

In Controller class:
public void createEntity( @Validated(ConditionalValidation.class) @RequestBody Entity someEntity) {}

  • As of now, someField is always showing as required in the swagger documentation no matter if the conditional group is applied or not.
  • I want to see in Swagger someField as required but only for the API createEntity and as optional for any other API that does apply the @Validate without the ConditionalValidation.class.
@MaksimOrlov
Copy link
Member

Hi, @mkhayata.
JSR - 303 validation groups is under work for now. There is a related issue for this #1356 and that issue is blocked until #2056 will be merged.

@MaksimOrlov
Copy link
Member

MaksimOrlov commented Mar 19, 2018

Approximately it will take a few months to be present in the snapshot version.

@AAMoeini
Copy link

AAMoeini commented May 14, 2020

Hi, @MaksimOrlov .
when JSR - 303 Validation group would add?
I think this facility is important.

@MaksimOrlov
Copy link
Member

@AliAkbarMoeini, release is planned to this month. That is link for details

@stale
Copy link

stale bot commented Aug 12, 2020

This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.

@stale stale bot added the wontfix label Aug 12, 2020
@dilipkrish dilipkrish added next and removed wontfix labels Aug 16, 2020
@nlbwqmz
Copy link

nlbwqmz commented Nov 6, 2020

mark

@nlbwqmz
Copy link

nlbwqmz commented Nov 6, 2020

plus one

@rranjithkumar100
Copy link

Still the issue is not resolved

1 similar comment
@wangpinpin
Copy link

Still the issue is not resolved

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

7 participants