-
-
Notifications
You must be signed in to change notification settings - Fork 6.6k
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
[BUG] multipleOf-Property not supported by codegens #2192
Comments
Support of multipleOf in |
To fully resolve this issue, one would need templates which make use of @Target({METHOD, FIELD})
@Retention(RUNTIME)
@Repeatable(MultipleOf.List.class)
@Constraint(validatedBy = MultipleOfValidator.class)
public @interface MultipleOf {
double value();
String message() default "{error.multipleOf}";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default { };
@Target({ METHOD, FIELD })
@Retention(RUNTIME)
@Documented
@interface List {
MultipleOf[] value();
}
} public class MultipleOfValidator implements ConstraintValidator<MultipleOf, Number> {
private double value;
@Override
public void initialize(MultipleOf constraintAnnotation) {
this.value = constraintAnnotation.value();
}
@Override
public boolean isValid(Number value, ConstraintValidatorContext context) {
return (value == null) || (value.doubleValue() / this.value) % 1 == 0;
}
} however I do not know where to put these and if the project would be open to templates like this. So my question is: would you accept a PR which provides templates for this custom annotation and validator (and where should I put them?) or shall I put these things into my own codebase and use custom templates? |
Description
I have an object that uses multipleOf-Property on numbers (same workaround as described in OAI/OpenAPI-Specification#602), but there seems to be no way to use mustache templates for customization, because the current templating process does not respect the multipleOf-Property in anyway.
openapi-generator version
I used OpenAPI generator v3.3.2 +
OpenAPI declaration file content or url
Suggest a fix
Making multipleOf-Hook available for templating. (helpful e.g. for creating Custom Constraints/Bean Validation in Java)
The text was updated successfully, but these errors were encountered: