Skip to content

Commit 7655bc9

Browse files
authored
add petstore sample for jaxrs-cxf-client, update travis ci (swagger-api#5111)
1 parent d2b0458 commit 7655bc9

20 files changed

+2152
-2
lines changed

bin/jaxrs-cxf-client-petstore.sh

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
#!/bin/sh
2+
3+
SCRIPT="$0"
4+
5+
while [ -h "$SCRIPT" ] ; do
6+
ls=`ls -ld "$SCRIPT"`
7+
link=`expr "$ls" : '.*-> \(.*\)$'`
8+
if expr "$link" : '/.*' > /dev/null; then
9+
SCRIPT="$link"
10+
else
11+
SCRIPT=`dirname "$SCRIPT"`/"$link"
12+
fi
13+
done
14+
15+
if [ ! -d "${APP_DIR}" ]; then
16+
APP_DIR=`dirname "$SCRIPT"`/..
17+
APP_DIR=`cd "${APP_DIR}"; pwd`
18+
fi
19+
20+
executable="./modules/swagger-codegen-cli/target/swagger-codegen-cli.jar"
21+
22+
if [ ! -f "$executable" ]
23+
then
24+
mvn clean package
25+
fi
26+
27+
# if you've executed sbt assembly previously it will use that instead.
28+
export JAVA_OPTS="${JAVA_OPTS} -XX:MaxPermSize=256M -Xmx1024M -DloggerPath=conf/log4j.properties"
29+
ags="$@ generate --artifact-id "jaxrs-cxf-petstore-client" -t modules/swagger-codegen/src/main/resources/JavaJaxRS/cxf/ -i modules/swagger-codegen/src/test/resources/2_0/petstore.yaml -l jaxrs-cxf -o samples/client/petstore/jaxrs-cxf-client/"
30+
31+
java $JAVA_OPTS -jar $executable $ags
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
set executable=.\modules\swagger-codegen-cli\target\swagger-codegen-cli.jar
2+
3+
If Not Exist %executable% (
4+
mvn clean package
5+
)
6+
7+
REM set JAVA_OPTS=%JAVA_OPTS% -Xmx1024M -DloggerPath=conf/log4j.properties
8+
set ags=generate --artifact-id "jaxrs-cxf-client-petstore-client" -i modules\swagger-codegen\src\test\resources\2_0\petstore.json -l jaxrs-cxf-client -o samples\client\petstore\jaxrs-cxf-client
9+
10+
java %JAVA_OPTS% -jar %executable% %ags%

pom.xml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -755,8 +755,6 @@
755755
</property>
756756
</activation>
757757
<modules>
758-
<!-- run ruby test first which has a random delay script to
759-
avoid issues with running 2 CI jobs in parallel. -->
760758
<!-- clients -->
761759
<module>samples/client/petstore/akka-scala</module>
762760
<module>samples/client/petstore/ruby</module>
@@ -771,6 +769,7 @@
771769
<module>samples/client/petstore/java/retrofit</module>
772770
<module>samples/client/petstore/java/retrofit2</module>
773771
<module>samples/client/petstore/java/retrofit2rx</module>
772+
<module>samples/client/petstore/jaxrs-cxf-client</module>
774773
<module>samples/client/petstore/javascript</module>
775774
<module>samples/client/petstore/python</module>
776775
<module>samples/client/petstore/scala</module>
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
# Swagger Codegen Ignore
2+
# Generated by swagger-codegen https://github.com/swagger-api/swagger-codegen
3+
4+
# Use this file to prevent files from being overwritten by the generator.
5+
# The patterns follow closely to .gitignore or .dockerignore.
6+
7+
# As an example, the C# client generator defines ApiClient.cs.
8+
# You can make changes and tell Swagger Codgen to ignore just this file by uncommenting the following line:
9+
#ApiClient.cs
10+
11+
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
12+
#foo/*/qux
13+
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
14+
15+
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
16+
#foo/**/qux
17+
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
18+
19+
# You can also negate patterns with an exclamation (!).
20+
# For example, you can ignore all files in a docs folder with the file extension .md:
21+
#docs/*.md
22+
# Then explicitly reverse the ignore rule for a single file:
23+
#!docs/README.md
24+
25+
**/impl/*
Lines changed: 198 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,198 @@
1+
<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">
2+
<modelVersion>4.0.0</modelVersion>
3+
<groupId>io.swagger</groupId>
4+
<artifactId>jaxrs-cxf-petstore-client</artifactId>
5+
<packaging>war</packaging>
6+
<name>jaxrs-cxf-petstore-client</name>
7+
<version>1.0.0</version>
8+
<build>
9+
<sourceDirectory>src/main/java</sourceDirectory>
10+
<plugins>
11+
<plugin>
12+
<artifactId>maven-failsafe-plugin</artifactId>
13+
<version>2.6</version>
14+
<executions>
15+
<execution>
16+
<goals>
17+
<goal>integration-test</goal>
18+
<goal>verify</goal>
19+
</goals>
20+
</execution>
21+
</executions>
22+
</plugin>
23+
<!--plugin>
24+
<groupId>org.eclipse.jetty</groupId>
25+
<artifactId>jetty-maven-plugin</artifactId>
26+
<version>${jetty-version}</version>
27+
<configuration>
28+
<webApp>
29+
<contextPath>/</contextPath>
30+
</webApp>
31+
<webAppSourceDirectory>target/${project.artifactId}-${project.version}</webAppSourceDirectory>
32+
<stopPort>8079</stopPort>
33+
<stopKey>stopit</stopKey>
34+
<httpConnector>
35+
<port>8080</port>
36+
<idleTimeout>60000</idleTimeout>
37+
</httpConnector>
38+
</configuration>
39+
<executions>
40+
<execution>
41+
<id>start-jetty</id>
42+
<phase>pre-integration-test</phase>
43+
<goals>
44+
<goal>start</goal>
45+
</goals>
46+
<configuration>
47+
<scanIntervalSeconds>0</scanIntervalSeconds>
48+
<daemon>true</daemon>
49+
</configuration>
50+
</execution>
51+
<execution>
52+
<id>stop-jetty</id>
53+
<phase>post-integration-test</phase>
54+
<goals>
55+
<goal>stop</goal>
56+
</goals>
57+
</execution>
58+
</executions>
59+
</plugin-->
60+
<plugin>
61+
<groupId>org.codehaus.mojo</groupId>
62+
<artifactId>build-helper-maven-plugin</artifactId>
63+
<version>1.9.1</version>
64+
<executions>
65+
<execution>
66+
<id>add-source</id>
67+
<phase>generate-sources</phase>
68+
<goals>
69+
<goal>add-source</goal>
70+
</goals>
71+
<configuration>
72+
<sources>
73+
<source>src/gen/java</source>
74+
</sources>
75+
</configuration>
76+
</execution>
77+
</executions>
78+
</plugin>
79+
80+
<!-- build WAR file -->
81+
<plugin>
82+
<artifactId>maven-war-plugin</artifactId>
83+
<version>2.1.1</version>
84+
<configuration>
85+
<failOnMissingWebXml>false</failOnMissingWebXml>
86+
</configuration>
87+
</plugin>
88+
</plugins>
89+
</build>
90+
<dependencies>
91+
<dependency>
92+
<groupId>io.swagger</groupId>
93+
<artifactId>swagger-jaxrs</artifactId>
94+
<scope>compile</scope>
95+
<version>${swagger-core-version}</version>
96+
</dependency>
97+
<dependency>
98+
<groupId>ch.qos.logback</groupId>
99+
<artifactId>logback-classic</artifactId>
100+
<version>${logback-version}</version>
101+
<scope>compile</scope>
102+
</dependency>
103+
<dependency>
104+
<groupId>ch.qos.logback</groupId>
105+
<artifactId>logback-core</artifactId>
106+
<version>${logback-version}</version>
107+
<scope>compile</scope>
108+
</dependency>
109+
<dependency>
110+
<groupId>junit</groupId>
111+
<artifactId>junit</artifactId>
112+
<version>${junit-version}</version>
113+
<scope>test</scope>
114+
</dependency>
115+
<!-- Bean Validation API support -->
116+
<dependency>
117+
<groupId>javax.validation</groupId>
118+
<artifactId>validation-api</artifactId>
119+
<version>${beanvalidation-version}</version>
120+
<scope>provided</scope>
121+
</dependency>
122+
<!-- CXF Client -->
123+
<dependency>
124+
<groupId>org.apache.cxf</groupId>
125+
<artifactId>cxf-rt-rs-client</artifactId>
126+
<version>${cxf-version}</version>
127+
<scope>test</scope>
128+
</dependency>
129+
130+
<!-- CXF server -->
131+
<dependency>
132+
<groupId>org.apache.cxf</groupId>
133+
<artifactId>cxf-rt-frontend-jaxrs</artifactId>
134+
<version>${cxf-version}</version>
135+
<scope>compile</scope>
136+
</dependency>
137+
<dependency>
138+
<groupId>org.apache.cxf</groupId>
139+
<artifactId>cxf-rt-rs-service-description</artifactId>
140+
<version>${cxf-version}</version>
141+
<scope>compile</scope>
142+
</dependency>
143+
<dependency>
144+
<groupId>org.apache.cxf</groupId>
145+
<artifactId>cxf-rt-rs-service-description-swagger</artifactId>
146+
<version>${cxf-version}</version>
147+
<scope>compile</scope>
148+
</dependency>
149+
<dependency>
150+
<groupId>org.apache.cxf</groupId>
151+
<artifactId>cxf-rt-ws-policy</artifactId>
152+
<version>${cxf-version}</version>
153+
<scope>compile</scope>
154+
</dependency>
155+
<dependency>
156+
<groupId>org.apache.cxf</groupId>
157+
<artifactId>cxf-rt-wsdl</artifactId>
158+
<version>${cxf-version}</version>
159+
<scope>compile</scope>
160+
</dependency>
161+
<dependency>
162+
<groupId>com.fasterxml.jackson.jaxrs</groupId>
163+
<artifactId>jackson-jaxrs-json-provider</artifactId>
164+
<version>${jackson-jaxrs-version}</version>
165+
<scope>compile</scope>
166+
</dependency>
167+
<dependency>
168+
<groupId>com.fasterxml.jackson.datatype</groupId>
169+
<artifactId>jackson-datatype-joda</artifactId>
170+
<version>${jackson-jaxrs-version}</version>
171+
<scope>compile</scope>
172+
</dependency>
173+
</dependencies>
174+
<repositories>
175+
<repository>
176+
<id>sonatype-snapshots</id>
177+
<url>https://oss.sonatype.org/content/repositories/snapshots</url>
178+
<snapshots>
179+
<enabled>true</enabled>
180+
</snapshots>
181+
</repository>
182+
</repositories>
183+
<properties>
184+
<java.version>1.7</java.version>
185+
<maven.compiler.source>${java.version}</maven.compiler.source>
186+
<maven.compiler.target>${java.version}</maven.compiler.target>
187+
<swagger-core-version>1.5.12</swagger-core-version>
188+
<jetty-version>9.2.9.v20150224</jetty-version>
189+
<jersey2-version>2.22.2</jersey2-version>
190+
<junit-version>4.12</junit-version>
191+
<logback-version>1.1.7</logback-version>
192+
<servlet-api-version>2.5</servlet-api-version>
193+
<beanvalidation-version>1.1.0.Final</beanvalidation-version>
194+
<cxf-version>3.1.8</cxf-version>
195+
<jackson-jaxrs-version>2.8.4</jackson-jaxrs-version>
196+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
197+
</properties>
198+
</project>
Lines changed: 101 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,101 @@
1+
package io.swagger.api;
2+
3+
import java.io.File;
4+
import io.swagger.model.ModelApiResponse;
5+
import io.swagger.model.Pet;
6+
7+
import java.io.InputStream;
8+
import java.io.OutputStream;
9+
import java.util.List;
10+
import java.util.Map;
11+
import javax.ws.rs.*;
12+
import javax.ws.rs.core.Response;
13+
import javax.ws.rs.core.MediaType;
14+
import org.apache.cxf.jaxrs.ext.multipart.*;
15+
16+
import io.swagger.annotations.Api;
17+
import io.swagger.annotations.ApiOperation;
18+
import io.swagger.annotations.ApiResponses;
19+
import io.swagger.annotations.ApiResponse;
20+
import io.swagger.jaxrs.PATCH;
21+
import javax.validation.constraints.*;
22+
23+
@Path("/")
24+
@Api(value = "/", description = "")
25+
public interface PetApi {
26+
27+
@POST
28+
@Path("/pet")
29+
@Consumes({ "application/json", "application/xml" })
30+
@Produces({ "application/xml", "application/json" })
31+
@ApiOperation(value = "Add a new pet to the store", tags={ "pet", })
32+
@ApiResponses(value = {
33+
@ApiResponse(code = 405, message = "Invalid input") })
34+
public void addPet(Pet body);
35+
36+
@DELETE
37+
@Path("/pet/{petId}")
38+
@Produces({ "application/xml", "application/json" })
39+
@ApiOperation(value = "Deletes a pet", tags={ "pet", })
40+
@ApiResponses(value = {
41+
@ApiResponse(code = 400, message = "Invalid pet value") })
42+
public void deletePet(@PathParam("petId") Long petId, @HeaderParam("api_key") String apiKey);
43+
44+
@GET
45+
@Path("/pet/findByStatus")
46+
@Produces({ "application/xml", "application/json" })
47+
@ApiOperation(value = "Finds Pets by status", tags={ "pet", })
48+
@ApiResponses(value = {
49+
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
50+
@ApiResponse(code = 400, message = "Invalid status value") })
51+
public List<Pet> findPetsByStatus(@QueryParam("status") @NotNull List<String> status);
52+
53+
@GET
54+
@Path("/pet/findByTags")
55+
@Produces({ "application/xml", "application/json" })
56+
@ApiOperation(value = "Finds Pets by tags", tags={ "pet", })
57+
@ApiResponses(value = {
58+
@ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
59+
@ApiResponse(code = 400, message = "Invalid tag value") })
60+
public List<Pet> findPetsByTags(@QueryParam("tags") @NotNull List<String> tags);
61+
62+
@GET
63+
@Path("/pet/{petId}")
64+
@Produces({ "application/xml", "application/json" })
65+
@ApiOperation(value = "Find pet by ID", tags={ "pet", })
66+
@ApiResponses(value = {
67+
@ApiResponse(code = 200, message = "successful operation", response = Pet.class),
68+
@ApiResponse(code = 400, message = "Invalid ID supplied"),
69+
@ApiResponse(code = 404, message = "Pet not found") })
70+
public Pet getPetById(@PathParam("petId") Long petId);
71+
72+
@PUT
73+
@Path("/pet")
74+
@Consumes({ "application/json", "application/xml" })
75+
@Produces({ "application/xml", "application/json" })
76+
@ApiOperation(value = "Update an existing pet", tags={ "pet", })
77+
@ApiResponses(value = {
78+
@ApiResponse(code = 400, message = "Invalid ID supplied"),
79+
@ApiResponse(code = 404, message = "Pet not found"),
80+
@ApiResponse(code = 405, message = "Validation exception") })
81+
public void updatePet(Pet body);
82+
83+
@POST
84+
@Path("/pet/{petId}")
85+
@Consumes({ "application/x-www-form-urlencoded" })
86+
@Produces({ "application/xml", "application/json" })
87+
@ApiOperation(value = "Updates a pet in the store with form data", tags={ "pet", })
88+
@ApiResponses(value = {
89+
@ApiResponse(code = 405, message = "Invalid input") })
90+
public void updatePetWithForm(@PathParam("petId") Long petId, @Multipart(value = "name", required = false) String name, @Multipart(value = "status", required = false) String status);
91+
92+
@POST
93+
@Path("/pet/{petId}/uploadImage")
94+
@Consumes({ "multipart/form-data" })
95+
@Produces({ "application/json" })
96+
@ApiOperation(value = "uploads an image", tags={ "pet" })
97+
@ApiResponses(value = {
98+
@ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
99+
public ModelApiResponse uploadFile(@PathParam("petId") Long petId, @Multipart(value = "additionalMetadata", required = false) String additionalMetadata, @Multipart(value = "file" , required = false) Attachment fileDetail);
100+
}
101+

0 commit comments

Comments
 (0)