mirror of
https://github.com/jlengrand/openapi-generator.git
synced 2026-05-17 00:21:19 +00:00
jaxrs-cxf-cdi :: Add a basic JAX-RS Application and CDI fixes (#4196)
* Add a basic JAX-RS Application and CDI fixes * jaxrs-cxf-cdi :: Fix samples generation template dir * jaxrs-cxf-cdi :: Regenerate samples * jaxrs-cxf-cdi :: Clean up some checkstyle warnings
This commit is contained in:
@@ -1,12 +1,22 @@
|
||||
package io.swagger.codegen.languages;
|
||||
|
||||
import io.swagger.codegen.*;
|
||||
import io.swagger.codegen.CodegenModel;
|
||||
import io.swagger.codegen.CodegenProperty;
|
||||
import io.swagger.codegen.SupportingFile;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
/**
|
||||
* Generates a Java JAXRS Server according to JAXRS 2.0 specification, assuming an
|
||||
* Apache CXF runtime and a Java EE runtime with CDI enabled.
|
||||
* Similar to the original JAXRS generator, this creates API and Service classes
|
||||
* in /src/gen/java and a sample ServiceImpl in /src/main/java. The API uses CDI
|
||||
* to get an instance of ServiceImpl that implements the Service interface.
|
||||
*/
|
||||
public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
|
||||
/**
|
||||
* Default constructor
|
||||
*/
|
||||
public JavaJAXRSCXFCDIServerCodegen() {
|
||||
outputFolder = "generated-code/JavaJaxRS-CXF-CDI";
|
||||
artifactId = "swagger-jaxrs-cxf-cdi-server";
|
||||
@@ -20,7 +30,8 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
|
||||
typeMapping.put("DateTime", "java.util.Date");
|
||||
|
||||
// Updated template directory
|
||||
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf-cdi";
|
||||
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME
|
||||
+ File.separator + "cxf-cdi";
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -31,8 +42,21 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
|
||||
@Override
|
||||
public void processOpts() {
|
||||
super.processOpts();
|
||||
|
||||
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
|
||||
|
||||
// writeOptional means these files are only written if they don't already exist
|
||||
|
||||
// POM
|
||||
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
|
||||
|
||||
// RestApplication into src/main/java
|
||||
writeOptional(outputFolder, new SupportingFile("RestApplication.mustache",
|
||||
(implFolder + '/' + invokerPackage).replace(".", "/"), "RestApplication.java"));
|
||||
|
||||
// Make CDI work in containers with implicit archive scanning disabled
|
||||
writeOptional(outputFolder, new SupportingFile("beans.mustache",
|
||||
"src/main/webapp/WEB-INF", "beans.xml"));
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -45,7 +69,8 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen {
|
||||
|
||||
@Override
|
||||
public String getHelp() {
|
||||
return "Generates a Java JAXRS Server according to JAXRS 2.0 specification, assuming an Apache CXF runtime and a Java EE runtime with CDI enabled.";
|
||||
return "Generates a Java JAXRS Server according to JAXRS 2.0 specification, assuming an "
|
||||
+ "Apache CXF runtime and a Java EE runtime with CDI enabled.";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user