diff --git a/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache b/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache index ff1785a32f..c5747541b7 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp-gson/api.mustache @@ -12,6 +12,7 @@ import {{invokerPackage}}.ProgressRequestBody; import {{invokerPackage}}.ProgressResponseBody; {{#performBeanValidation}} import {{invokerPackage}}.BeanValidationException; +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; {{/performBeanValidation}} import com.google.gson.reflect.TypeToken; @@ -42,6 +43,7 @@ import javax.validation.executable.ExecutableValidator; import java.util.Set; import java.lang.reflect.Method; import java.lang.reflect.Type; +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; {{/performBeanValidation}} {{#imports}}import {{import}}; @@ -165,7 +167,10 @@ public class {{classname}} { {{/performBeanValidation}} {{#performBeanValidation}} try { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + ValidatorFactory factory = Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory(); ExecutableValidator executableValidator = factory.getValidator().forExecutables(); Object[] parameterValues = { {{#parameters}}{{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}} }; diff --git a/src/main/resources/handlebars/Java/libraries/okhttp4-gson/api.mustache b/src/main/resources/handlebars/Java/libraries/okhttp4-gson/api.mustache index 4a13e61eea..b5100c3e82 100644 --- a/src/main/resources/handlebars/Java/libraries/okhttp4-gson/api.mustache +++ b/src/main/resources/handlebars/Java/libraries/okhttp4-gson/api.mustache @@ -29,6 +29,7 @@ import javax.validation.executable.ExecutableValidator; import java.util.Set; import java.lang.reflect.Method; import java.lang.reflect.Type; +import org.hibernate.validator.messageinterpolation.ParameterMessageInterpolator; {{/performBeanValidation}} {{#imports}}import {{import}}; @@ -147,7 +148,10 @@ public class {{classname}} { {{/performBeanValidation}} {{#performBeanValidation}} try { - ValidatorFactory factory = Validation.buildDefaultValidatorFactory(); + ValidatorFactory factory = Validation.byDefaultProvider() + .configure() + .messageInterpolator(new ParameterMessageInterpolator()) + .buildValidatorFactory(); ExecutableValidator executableValidator = factory.getValidator().forExecutables(); Object[] parameterValues = { {{#parameters}}{{paramName}}{{#has this 'more'}}, {{/has}}{{/parameters}} };