forked from loafle/openapi-generator-original
[Java] BeanValidation + JAXRS CXF server generator (#4068)
* add pom-file to cxf including cxf-client #2017 * adapt pom sourceFolder in pom.mustache to gen/java #2017 * add test templates for CXF #2017 * optimize mustache template structure, remove tabs #3280 #2549 * refined dependency to swagger-jaxrs #2017 * refined annotations and line breaks #2549 * fix tabs instead of spaces... * move annotations from getter to field for server model * cleanup tabs * add example for gzipping #2017 * add complete WAR to cxf-server #2017 * add readme + rework pom #2017 * add cli switch for beanvalidation #2549 * move beanvalidation into separate subtemplate and reuse for cxf * add beanValidation java template * corrected path to mustache file * fix AbstractOptionsTest, add default false for USE_BEANVALIDATION * add pom-file to cxf including cxf-client #2017 * adapt pom sourceFolder in pom.mustache to gen/java #2017 * add test templates for CXF #2017 * optimize mustache template structure, remove tabs #3280 #2549 * refined dependency to swagger-jaxrs #2017 * refined annotations and line breaks #2549 * fix tabs instead of spaces... * move annotations from getter to field for server model * cleanup tabs * add example for gzipping #2017 * add complete WAR to cxf-server #2017 * add readme + rework pom #2017 * add cli switch for beanvalidation #2549 * move beanvalidation into separate subtemplate and reuse for cxf * add beanValidation java template * corrected path to mustache file * fix AbstractOptionsTest, add default false for USE_BEANVALIDATION * add beanvalidation to okhttp-gson library #2549 * cleanup api.mustache for cxf #3281 * temporary fix for invalid BeanValidation-pattern with / #2549 * temporary fix for invalid BeanValidation-pattern with / #2549 * remove jaxrs-annotations from implementation classes #3281 * add configuration to generate spring web application #4003 * clean up unnecessary @Path annotation (part of method level!) * add support for minItems/maxItems #2549 * add support for BeanValidation for query params #2549 * add imports for bean validation #2549 * add switches for various cxf server features #2017 * fix tests #2549 #2017 * re-create bin folder * cleanup * cleanup * Revert "temporary solution for pattern - move to AbstractJavaCodegen #2549" This reverts commit 82df5e657f31303bcb7d38f1dc013183d3509da2, reversing changes made to 65e87f23a6804a0d5c0926c916a9cd6866e7fee0. Conflicts: bin/akka-scala-petstore.sh bin/android-petstore-all.sh bin/android-petstore-httpclient.sh bin/android-petstore-volley.sh bin/android-petstore.sh bin/aspnet5-petstore-server.sh bin/clojure-petstore.sh bin/cpprest-petstore.sh bin/csharp-dotnet2-petstore.sh bin/csharp-petstore-all.sh bin/csharp-petstore.sh bin/csharp-property-changed-petstore.sh bin/cwiki-petstore.sh bin/dart-petstore.sh bin/dynamic-html.sh bin/erlang-petstore-server.sh bin/flash-petstore.sh bin/flaskConnexion-python2.sh bin/flaskConnexion.sh bin/go-petstore-server.sh bin/go-petstore.sh bin/groovy-petstore.sh bin/haskell-servant-petstore.sh bin/html-petstore.sh bin/html2-petstore.sh bin/java-inflector-petstore-server.sh bin/java-petstore-all.sh bin/java-petstore-feign.sh bin/java-petstore-jersey1.sh bin/java-petstore-jersey2.sh bin/java-petstore-okhttp-gson-parcelable.sh bin/java-petstore-okhttp-gson.sh bin/java-petstore-retrofit.sh bin/java-petstore-retrofit2.sh bin/java-petstore-retrofit2rx.sh bin/java-undertow-petstore-server.sh bin/java8-petstore-jersey2.sh bin/javascript-closure-angular.sh bin/javascript-petstore-all.sh bin/javascript-petstore.sh bin/javascript-promise-petstore.sh bin/jaxrs-cxf-cdi-petstore-server.sh bin/jaxrs-cxf-petstore-server.sh bin/jaxrs-jersey1-petstore-server.sh bin/jaxrs-petstore-server.sh bin/jaxrs-resteasy-joda-petstore-server.json bin/jaxrs-resteasy-joda-petstore-server.sh bin/jaxrs-resteasy-petstore-server.sh bin/jaxrs-spec-petstore-server.sh bin/jmeter-petstore.sh bin/lumen-petstore-server.sh bin/nancyfx-petstore-server.sh bin/nodejs-petstore-server.sh bin/objc-petstore-all.sh bin/objc-petstore-coredata.sh bin/objc-petstore.sh bin/perl-petstore.sh bin/php-petstore.sh bin/python-petstore.sh bin/qt5-petstore.sh bin/rails5-petstore-server.sh bin/ruby-petstore.sh bin/run-all-petstore bin/scala-async-petstore.sh bin/scala-petstore.sh bin/scalatra-petstore-server.sh bin/security/csharp-petstore.sh bin/security/go-petstore.sh bin/security/java-petstore-okhttp-gson.sh bin/security/javascript-closure-angular.sh bin/security/javascript-petstore.sh bin/security/lumen-petstore-server.sh bin/security/objc-petstore.sh bin/security/perl-petstore.sh bin/security/php-petstore.sh bin/security/python-petstore.sh bin/security/qt5cpp-petstore.sh bin/security/ruby-petstore.sh bin/security/run-all-petstore-security-test bin/security/scala-petstore.sh bin/security/silex-petstore-server.sh bin/security/slim-petstore-server.sh bin/security/swift-petstore.sh bin/security/typescript-angular.sh bin/security/typescript-angular2.sh bin/security/typescript-fetch.sh bin/security/typescript-node.sh bin/silex-petstore-server.sh bin/sinatra-petstore-server.sh bin/slim-petstore-server.sh bin/spring-all-pestore.sh bin/spring-cloud-feign-petstore.sh bin/spring-mvc-petstore-j8-async-server.sh bin/spring-mvc-petstore-server.sh bin/spring-stubs.sh bin/springboot-petstore-server.sh bin/swift-petstore-all.sh bin/swift-petstore-promisekit.sh bin/swift-petstore-rxswift.sh bin/swift-petstore.sh bin/tizen-petstore.sh bin/typescript-angular-petstore.sh bin/typescript-angular2-petstore-all.sh bin/typescript-angular2-petstore-with-npm.sh bin/typescript-angular2-petstore.sh bin/typescript-fetch-petstore-all.sh bin/typescript-fetch-petstore-target-es6.sh bin/typescript-fetch-petstore-with-npm-version.sh bin/typescript-fetch-petstore.sh bin/typescript-node-petstore-all.sh bin/typescript-node-petstore-with-npm.sh bin/typescript-node-petstore.sh bin/typescript-petstore-npm.json bin/windows/akka-scala-petstore.bat bin/windows/android-petstore.bat bin/windows/aspnet5-petstore-server.bat bin/windows/async-scala-petstore.bat bin/windows/clojure-petstore.bat bin/windows/cpprest-petstore.bat bin/windows/csharp-petstore.bat bin/windows/dart-petstore.bat bin/windows/dynamic-html-petstore.bat bin/windows/flash-petstore.bat bin/windows/go-petstore.bat bin/windows/html-petstore.bat bin/windows/java-petstore-okhttp-gson.bat bin/windows/java-petstore.bat bin/windows/javascript-petstore.bat bin/windows/objc-petstore.bat bin/windows/perl-petstore.bat bin/windows/php-petstore.bat bin/windows/python-petstore.bat bin/windows/qt5cpp-petstore.bat bin/windows/rails5-petstore-server.bat bin/windows/ruby-petstore.bat bin/windows/scala-petstore.bat bin/windows/spring-mvc-petstore-j8-async-server.bat bin/windows/spring-mvc-petstore-server.bat bin/windows/springboot-petstore-server.bat bin/windows/swift-petstore.bat bin/windows/tizen-petstore.bat bin/windows/typescript-angular.bat bin/windows/typescript-angular2.bat bin/windows/typescript-fetch.bat bin/windows/typescript-node-with-npm.bat bin/windows/typescript-node.bat * Revert "cleanup" This reverts commit c752ba85d8a795ebcaf902a0eb06ab0c5755d128. * Revert "re-create bin folder" This reverts commit 8a6d41314784a2ae5ce29ae54d7db1ebec418751. Conflicts: bin/windows/spring-mvc-petstore-j8-async-server.bat bin/windows/spring-mvc-petstore-server.bat bin/windows/springboot-petstore-server.bat * Revert "re-create bin folder" This reverts commit 8a6d41314784a2ae5ce29ae54d7db1ebec418751. Conflicts: bin/windows/spring-mvc-petstore-j8-async-server.bat bin/windows/spring-mvc-petstore-server.bat bin/windows/springboot-petstore-server.bat * re-create bin from master * Revert "re-create bin from master" This reverts commit d4b5c9aac54d62dfb3790c1bf2829472be2ec8fd. * Revert "Revert "re-create bin folder"" This reverts commit 4369b35dbe9d21f8a93e7632fd92a9a760256db5. * Revert "re-create bin folder" This reverts commit 8a6d41314784a2ae5ce29ae54d7db1ebec418751. * Revert "temporary solution for pattern - move to AbstractJavaCodegen #2549" This reverts commit 82df5e657f31303bcb7d38f1dc013183d3509da2, reversing changes made to 65e87f23a6804a0d5c0926c916a9cd6866e7fee0. * correct @Path to re-activate Swagger support # * change sourceFolder to default * re-activate unittest generator + support gzip switch #2017 * add switch to support Spring Boot + integration tests * add cxf client generator, rename cxf server generator #2017 * add interfaces for language feature support #4003 * add comments #2017 * correct reference to context.xml.mustache #4003 * use dynamic sourceFolder path #2017 * replace tabs with spaces #4003 * use hard-coded sourceFolder #4003 * rename language for backwards compatibility * cleanup todo comment #4003 * move convertPropertyToBooleanAndWriteBack to DefaultCodegen #4003 * change reference to beanValidation.mustache to local copy for cxf * cleanup client-side beanvalidation (currently not working in CXF) * add support for tags #4003 * fix instantiiation of method parameters * move commonValidationFeature from bus to endpoint #4003
This commit is contained in:
@@ -58,6 +58,8 @@ public class JavaClientOptionsTest extends AbstractOptionsTest {
|
||||
times = 1;
|
||||
//clientCodegen.setSupportJava6(Boolean.valueOf(JavaOptionsProvider.SUPPORT_JAVA6));
|
||||
//times = 1;
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(JavaOptionsProvider.USE_BEANVALIDATION));
|
||||
times = 1;
|
||||
}};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,80 @@
|
||||
package io.swagger.codegen.jaxrs;
|
||||
|
||||
import io.swagger.codegen.AbstractOptionsTest;
|
||||
import io.swagger.codegen.CodegenConfig;
|
||||
import io.swagger.codegen.languages.JavaCXFServerCodegen;
|
||||
import io.swagger.codegen.options.JavaCXFServerOptionsProvider;
|
||||
import io.swagger.codegen.options.OptionsProvider;
|
||||
import mockit.Expectations;
|
||||
import mockit.Tested;
|
||||
|
||||
public class JaxrsCXFServerOptionsTest extends AbstractOptionsTest {
|
||||
|
||||
@Tested
|
||||
private JavaCXFServerCodegen clientCodegen;
|
||||
|
||||
public JaxrsCXFServerOptionsTest() {
|
||||
super(new JavaCXFServerOptionsProvider());
|
||||
}
|
||||
|
||||
protected JaxrsCXFServerOptionsTest(OptionsProvider optionsProvider) {
|
||||
super(optionsProvider);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected CodegenConfig getCodegenConfig() {
|
||||
return clientCodegen;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void setExpectations() {
|
||||
new Expectations(clientCodegen) {{
|
||||
clientCodegen.setModelPackage(JavaCXFServerOptionsProvider.MODEL_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setApiPackage(JavaCXFServerOptionsProvider.API_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSortParamsByRequiredFlag(Boolean.valueOf(JavaCXFServerOptionsProvider.SORT_PARAMS_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setInvokerPackage(JavaCXFServerOptionsProvider.INVOKER_PACKAGE_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setGroupId(JavaCXFServerOptionsProvider.GROUP_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactId(JavaCXFServerOptionsProvider.ARTIFACT_ID_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setArtifactVersion(JavaCXFServerOptionsProvider.ARTIFACT_VERSION_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSourceFolder(JavaCXFServerOptionsProvider.SOURCE_FOLDER_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setLocalVariablePrefix(JavaCXFServerOptionsProvider.LOCAL_PREFIX_VALUE);
|
||||
times = 1;
|
||||
clientCodegen.setSerializableModel(Boolean.valueOf(JavaCXFServerOptionsProvider.SERIALIZABLE_MODEL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setFullJavaUtil(Boolean.valueOf(JavaCXFServerOptionsProvider.FULL_JAVA_UTIL_VALUE));
|
||||
times = 1;
|
||||
clientCodegen.setSerializeBigDecimalAsString(true);
|
||||
times = 1;
|
||||
|
||||
clientCodegen.setUseBeanValidation(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_BEANVALIDATION));
|
||||
times = 1;
|
||||
|
||||
clientCodegen.setGenerateSpringApplication(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_SWAGGER_FEATURE));
|
||||
times = 1;
|
||||
clientCodegen.setUseWadlFeature(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_WADL_FEATURE));
|
||||
times = 1;
|
||||
clientCodegen.setUseMultipartFeature(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_MULTIPART_FEATURE));
|
||||
times = 1;
|
||||
clientCodegen.setUseGzipFeature(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_GZIP_FEATURE));
|
||||
times = 1;
|
||||
clientCodegen.setUseLoggingFeature(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_LOGGING_FEATURE));
|
||||
times = 1;
|
||||
clientCodegen.setUseBeanValidationFeature(Boolean.valueOf(JavaCXFServerOptionsProvider.USE_BEANVALIDATION_FEATURE));
|
||||
times = 1;
|
||||
|
||||
clientCodegen.setGenerateSpringBootApplication(Boolean.valueOf(JavaCXFServerOptionsProvider.GENERATE_SPRING_BOOT_APPLICATION));
|
||||
times = 1;
|
||||
|
||||
|
||||
|
||||
}};
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,65 @@
|
||||
package io.swagger.codegen.options;
|
||||
|
||||
import java.util.Map;
|
||||
|
||||
import com.google.common.collect.ImmutableMap;
|
||||
|
||||
import io.swagger.codegen.CodegenConstants;
|
||||
import io.swagger.codegen.languages.JavaCXFServerCodegen;
|
||||
|
||||
public class JavaCXFServerOptionsProvider extends JavaOptionsProvider {
|
||||
|
||||
public static final String GENERATE_SPRING_APPLICATION = "true";
|
||||
|
||||
public static final String USE_SWAGGER_FEATURE = "true";
|
||||
|
||||
public static final String USE_WADL_FEATURE = "true";
|
||||
|
||||
public static final String USE_MULTIPART_FEATURE = "true";
|
||||
|
||||
public static final String USE_GZIP_FEATURE = "true";
|
||||
|
||||
public static final String USE_LOGGING_FEATURE = "true";
|
||||
|
||||
public static final String USE_BEANVALIDATION_FEATURE = "true";
|
||||
|
||||
public static final String GENERATE_SPRING_BOOT_APPLICATION = "true";
|
||||
|
||||
public static final String IMPL_FOLDER_VALUE = "src/main/java";
|
||||
|
||||
@Override
|
||||
public boolean isServer() {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getLanguage() {
|
||||
return "jaxrs-cxf";
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<String, String> createOptions() {
|
||||
|
||||
Map<String, String> parentOptions = super.createOptions();
|
||||
|
||||
ImmutableMap.Builder<String, String> builder = new ImmutableMap.Builder<String, String>()
|
||||
.putAll(parentOptions);
|
||||
|
||||
builder.put(CodegenConstants.IMPL_FOLDER, IMPL_FOLDER_VALUE);
|
||||
builder.put("title", "Test title");
|
||||
|
||||
builder.put(JavaCXFServerCodegen.USE_BEANVALIDATION, JavaOptionsProvider.USE_BEANVALIDATION);
|
||||
builder.put(JavaCXFServerCodegen.GENERATE_SPRING_APPLICATION, GENERATE_SPRING_APPLICATION);
|
||||
builder.put(JavaCXFServerCodegen.USE_SWAGGER_FEATURE, USE_SWAGGER_FEATURE);
|
||||
builder.put(JavaCXFServerCodegen.USE_WADL_FEATURE, USE_WADL_FEATURE);
|
||||
builder.put(JavaCXFServerCodegen.USE_MULTIPART_FEATURE, USE_MULTIPART_FEATURE);
|
||||
builder.put(JavaCXFServerCodegen.USE_GZIP_FEATURE, USE_GZIP_FEATURE);
|
||||
builder.put(JavaCXFServerCodegen.USE_LOGGING_FEATURE, USE_LOGGING_FEATURE);
|
||||
builder.put(JavaCXFServerCodegen.USE_BEANVALIDATION_FEATURE, USE_BEANVALIDATION_FEATURE);
|
||||
|
||||
builder.put(JavaCXFServerCodegen.GENERATE_SPRING_BOOT_APPLICATION, GENERATE_SPRING_BOOT_APPLICATION);
|
||||
|
||||
return builder.build();
|
||||
|
||||
}
|
||||
}
|
||||
@@ -18,6 +18,7 @@ public class JavaClientOptionsProvider extends JavaOptionsProvider {
|
||||
options.put(JavaClientCodegen.USE_RX_JAVA, "false");
|
||||
options.put(JavaClientCodegen.PARCELABLE_MODEL, "false");
|
||||
options.put(JavaClientCodegen.SUPPORT_JAVA6, "false");
|
||||
options.put(JavaClientCodegen.USE_BEANVALIDATION, "false");
|
||||
|
||||
return options;
|
||||
}
|
||||
|
||||
@@ -20,6 +20,7 @@ public class JavaOptionsProvider implements OptionsProvider {
|
||||
public static final String FULL_JAVA_UTIL_VALUE = "true";
|
||||
public static final String ENSURE_UNIQUE_PARAMS_VALUE = "true";
|
||||
//public static final String SUPPORT_JAVA6 = "true";
|
||||
public static final String USE_BEANVALIDATION = "false";
|
||||
|
||||
private ImmutableMap<String, String> options;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user