jaxrs-cxf-cdi POM template (#3958)

* Don't refer to missing class in Impl classes

* Add POM for jaxrs-cxf-cdi

* Correct jaxrs-cxf-cdi artifactId

* Update samples for jaxrs-cxf-cdi

* Regenerate jaxrs-cxf-cdi samples
This commit is contained in:
Nick Maynard 2016-10-12 08:43:44 +01:00 committed by wing328
parent 504f8f1f21
commit 823ce72e2e
10 changed files with 208 additions and 42 deletions

View File

@ -1,5 +1,6 @@
package io.swagger.codegen.languages;
import io.swagger.codegen.*;
import io.swagger.codegen.CodegenModel;
import io.swagger.codegen.CodegenProperty;
@ -9,17 +10,19 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen
{
public JavaJAXRSCXFCDIServerCodegen()
{
sourceFolder = "src" + File.separator + "gen" + File.separator + "java";
artifactId = "swagger-jaxrs-cxf-cdi-server";
// Three API templates to support CDI injection
apiTemplateFiles.put("apiService.mustache", ".java");
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
sourceFolder = "src" + File.separator + "gen" + File.separator + "java";
// Use standard types
typeMapping.put("DateTime", "java.util.Date");
// Three API templates to support CDI injection
apiTemplateFiles.put("apiService.mustache", ".java");
apiTemplateFiles.put("apiServiceImpl.mustache", ".java");
// Updated template directory
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf-cdi";
// Use standard types
typeMapping.put("DateTime", "java.util.Date");
// Updated template directory
embeddedTemplateDir = templateDir = JAXRS_TEMPLATE_DIRECTORY_NAME + File.separator + "cxf-cdi";
}
@Override
@ -34,20 +37,22 @@ public class JavaJAXRSCXFCDIServerCodegen extends JavaJAXRSSpecServerCodegen
super.processOpts();
supportingFiles.clear(); // Don't need extra files provided by AbstractJAX-RS & Java Codegen
writeOptional(outputFolder, new SupportingFile("pom.mustache", "", "pom.xml"));
}
@Override
public void postProcessModelProperty(CodegenModel model, CodegenProperty property) {
super.postProcessModelProperty(model, property);
super.postProcessModelProperty(model, property);
// Reinstate JsonProperty
model.imports.add("JsonProperty");
// Reinstate JsonProperty
model.imports.add("JsonProperty");
}
@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.";
}
}

View File

@ -24,7 +24,7 @@ public class {{classname}}ServiceImpl implements {{classname}}Service {
@Override
public Response {{nickname}}({{#allParams}}{{>serviceQueryParams}}{{>servicePathParams}}{{>serviceHeaderParams}}{{>serviceBodyParams}}{{>serviceFormParams}}, {{/allParams}}SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
{{/operation}}
}

View File

@ -0,0 +1,82 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>{{groupId}}</groupId>
<artifactId>{{artifactId}}</artifactId>
<packaging>war</packaging>
<name>{{artifactId}}</name>
<version>{{artifactVersion}}</version>
<build>
<!-- Main source directory -->
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<!-- Add src/gen/java to compilation -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Java EE 7 doesn't need a web.xml -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxrs -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<!-- Version is just a guess -->
<!-- IBM WebSphere Application Server Liberty Core v8.5.5.6 uses v3.0.2, source https://www.ibm.com/support/knowledgecenter/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/rwlp_jaxrs_secure.html -->
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>[2.8.3,3)</version>
</dependency>
<!-- Swagger annotations -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>[1.5.3,2)</version>
</dependency>
</dependencies>
</project>

View File

@ -0,0 +1,82 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>io.swagger</groupId>
<artifactId>swagger-jaxrs-cxf-cdi-server</artifactId>
<packaging>war</packaging>
<name>swagger-jaxrs-cxf-cdi-server</name>
<version>1.0.0</version>
<build>
<!-- Main source directory -->
<sourceDirectory>src/main/java</sourceDirectory>
<plugins>
<!-- Add src/gen/java to compilation -->
<plugin>
<groupId>org.codehaus.mojo</groupId>
<artifactId>build-helper-maven-plugin</artifactId>
<version>1.9.1</version>
<executions>
<execution>
<id>add-source</id>
<phase>generate-sources</phase>
<goals>
<goal>add-source</goal>
</goals>
<configuration>
<sources>
<source>src/gen/java</source>
</sources>
</configuration>
</execution>
</executions>
</plugin>
<!-- Java EE 7 doesn't need a web.xml -->
<plugin>
<artifactId>maven-war-plugin</artifactId>
<version>3.0.0</version>
<configuration>
<failOnMissingWebXml>false</failOnMissingWebXml>
</configuration>
</plugin>
</plugins>
</build>
<dependencies>
<!-- https://mvnrepository.com/artifact/javax/javaee-api -->
<dependency>
<groupId>javax</groupId>
<artifactId>javaee-api</artifactId>
<version>7.0</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/org.apache.cxf/cxf-rt-frontend-jaxrs -->
<dependency>
<groupId>org.apache.cxf</groupId>
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
<!-- Version is just a guess -->
<!-- IBM WebSphere Application Server Liberty Core v8.5.5.6 uses v3.0.2, source https://www.ibm.com/support/knowledgecenter/SSD28V_8.5.5/com.ibm.websphere.wlp.core.doc/ae/rwlp_jaxrs_secure.html -->
<version>3.0.2</version>
<scope>provided</scope>
</dependency>
<!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.jaxrs/jackson-jaxrs-json-provider -->
<dependency>
<groupId>com.fasterxml.jackson.jaxrs</groupId>
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>[2.8.3,3)</version>
</dependency>
<!-- Swagger annotations -->
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>[1.5.3,2)</version>
</dependency>
</dependencies>
</project>

View File

@ -16,7 +16,7 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-11T07:40:42.070+01:00")
public interface PetApiService {
public Response addPet(Pet body, SecurityContext securityContext);
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext);

View File

@ -15,7 +15,7 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-11T07:40:42.070+01:00")
public interface StoreApiService {
public Response deleteOrder(String orderId, SecurityContext securityContext);
public Response getInventory(SecurityContext securityContext);

View File

@ -15,7 +15,7 @@ import java.io.InputStream;
import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-07T11:14:51.064+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-11T07:40:42.070+01:00")
public interface UserApiService {
public Response createUser(User body, SecurityContext securityContext);
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext);

View File

@ -10,7 +10,6 @@ import io.swagger.model.ModelApiResponse;
import java.io.File;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
@ -19,46 +18,46 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-11T07:40:42.070+01:00")
public class PetApiServiceImpl implements PetApiService {
@Override
public Response addPet(Pet body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response deletePet(Long petId, String apiKey, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response findPetsByStatus(List<String> status, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response findPetsByTags(List<String> tags, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response getPetById(Long petId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response updatePet(Pet body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response updatePetWithForm(Long petId, String name, String status, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, Attachment fileDetail, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
}

View File

@ -9,7 +9,6 @@ import java.util.Map;
import io.swagger.model.Order;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
@ -18,26 +17,26 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-11T07:40:42.070+01:00")
public class StoreApiServiceImpl implements StoreApiService {
@Override
public Response deleteOrder(String orderId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response getInventory(SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response getOrderById(Long orderId, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response placeOrder(Order body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
}

View File

@ -9,7 +9,6 @@ import io.swagger.model.User;
import java.util.List;
import java.util.List;
import io.swagger.api.NotFoundException;
import java.io.InputStream;
@ -18,46 +17,46 @@ import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext;
@RequestScoped
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-06T16:59:45.939+01:00")
@javax.annotation.Generated(value = "class io.swagger.codegen.languages.JavaJAXRSCXFCDIServerCodegen", date = "2016-10-11T07:40:42.070+01:00")
public class UserApiServiceImpl implements UserApiService {
@Override
public Response createUser(User body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response createUsersWithArrayInput(List<User> body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response createUsersWithListInput(List<User> body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response deleteUser(String username, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response getUserByName(String username, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response loginUser(String username, String password, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response logoutUser(SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
@Override
public Response updateUser(String username, User body, SecurityContext securityContext) {
// do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
return Response.ok().entity("magic!").build();
}
}