forked from loafle/openapi-generator-original
[Jaxrs-Resteasy] Add beanvalidation annotations (#4506)
* add beanvalidation to jaxrs-resteasy #4091 * replace tabs
This commit is contained in:
@@ -1,6 +1,7 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.codegen.languages.features.BeanValidationFeatures;
|
||||
import io.swagger.codegen.languages.features.JbossFeature;
|
||||
import io.swagger.models.Operation;
|
||||
import org.apache.commons.lang3.BooleanUtils;
|
||||
@@ -9,10 +10,11 @@ import org.apache.commons.lang3.StringUtils;
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature {
|
||||
public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen implements JbossFeature, BeanValidationFeatures {
|
||||
|
||||
protected boolean useBeanValidation = true;
|
||||
protected boolean generateJbossDeploymentDescriptor = true;
|
||||
|
||||
|
||||
public JavaResteasyServerCodegen() {
|
||||
|
||||
super();
|
||||
@@ -35,6 +37,7 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
|
||||
|
||||
embeddedTemplateDir = templateDir = "JavaJaxRS" + File.separator + "resteasy";
|
||||
|
||||
cliOptions.add(CliOption.newBoolean(USE_BEANVALIDATION, "Use BeanValidation API annotations"));
|
||||
cliOptions.add(
|
||||
CliOption.newBoolean(GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR, "Generate Jboss Deployment Descriptor"));
|
||||
}
|
||||
@@ -58,6 +61,14 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
|
||||
GENERATE_JBOSS_DEPLOYMENT_DESCRIPTOR);
|
||||
this.setGenerateJbossDeploymentDescriptor(generateJbossDeploymentDescriptorProp);
|
||||
}
|
||||
|
||||
if (additionalProperties.containsKey(USE_BEANVALIDATION)) {
|
||||
this.setUseBeanValidation(convertPropertyToBoolean(USE_BEANVALIDATION));
|
||||
}
|
||||
|
||||
if (useBeanValidation) {
|
||||
writePropertyBack(USE_BEANVALIDATION, useBeanValidation);
|
||||
}
|
||||
|
||||
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
writeOptional(outputFolder, new SupportingFile("gradle.mustache", "", "build.gradle"));
|
||||
@@ -214,6 +225,10 @@ public class JavaResteasyServerCodegen extends AbstractJavaJAXRSServerCodegen im
|
||||
|
||||
return objs;
|
||||
}
|
||||
|
||||
public void setUseBeanValidation(boolean useBeanValidation) {
|
||||
this.useBeanValidation = useBeanValidation;
|
||||
}
|
||||
|
||||
public void setGenerateJbossDeploymentDescriptor(boolean generateJbossDeploymentDescriptor) {
|
||||
this.generateJbossDeploymentDescriptor = generateJbossDeploymentDescriptor;
|
||||
|
||||
Reference in New Issue
Block a user