Skip to content

Commit

Permalink
refs-swagger-api/swagger-codegen#12448 / Use ParameterMessageInterpol…
Browse files Browse the repository at this point in the history
…ation to get rid of hibernate error with missing dependency
  • Loading branch information
micryc committed Nov 5, 2024
1 parent f10a1a0 commit e0bc7ff
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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}};
Expand Down Expand Up @@ -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}} };
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}};
Expand Down Expand Up @@ -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}} };
Expand Down

0 comments on commit e0bc7ff

Please sign in to comment.