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

mkhayata opened this issue Mar 17, 2018 · 2 comments


Copy link

@mkhayata 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 (

@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.

This comment has been minimized.

Copy link

@MaksimOrlov MaksimOrlov commented Mar 19, 2018

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.


This comment has been minimized.

Copy link

@MaksimOrlov MaksimOrlov commented Mar 19, 2018

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

@dilipkrish dilipkrish added the feature label Mar 20, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
None yet
3 participants
You can’t perform that action at this time.