I am describing request data parameter using Java, SpringBoot and Swagger. Normally I would define which parameter is required using @ApiModelProperty or @NotBlank annotation. But I have this case: I have two parameters. Both are optional. But, when send this request data, one of two must be filled, otherwise validation error is expected.
public class ABC{
@ApiModelProperty(notes="FieldA", required= false)
@NotBlank
String fieldA;
String fieldB;
}
my question are
- How to validate this condition before sending the request to API server?
- Is there any available annotation to handle this input validation?
- Or there is no other way than handling it in the service server using if-else condition and check whether fieldA is null, then fieldB cannot be null, etc?