Skip to content

Commit a17c6d5

Browse files
committed
updated jaxrs resteasy sample.
1 parent b5394bd commit a17c6d5

File tree

10 files changed

+148
-126
lines changed

10 files changed

+148
-126
lines changed

samples/server/petstore/jaxrs-resteasy/default/pom.xml

Lines changed: 56 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@
2525
</plugin>
2626
<plugin>
2727
<artifactId>maven-failsafe-plugin</artifactId>
28-
<version>2.6</version>
28+
<version>2.18.1</version>
2929
<executions>
3030
<execution>
3131
<goals>
@@ -35,6 +35,40 @@
3535
</execution>
3636
</executions>
3737
</plugin>
38+
<plugin>
39+
<groupId>org.eclipse.jetty</groupId>
40+
<artifactId>jetty-maven-plugin</artifactId>
41+
<version>${jetty-version}</version>
42+
<configuration>
43+
<webApp>
44+
<contextPath>/</contextPath>
45+
</webApp>
46+
<scanIntervalSeconds>10</scanIntervalSeconds>
47+
<stopKey>alpha</stopKey>
48+
<stopPort>9099</stopPort>
49+
<stopWait>2</stopWait>
50+
</configuration>
51+
<executions>
52+
<execution>
53+
<id>start-jetty</id>
54+
<phase>pre-integration-test</phase>
55+
<goals>
56+
<goal>start</goal>
57+
</goals>
58+
<configuration>
59+
<scanIntervalSeconds>0</scanIntervalSeconds>
60+
<daemon>true</daemon>
61+
</configuration>
62+
</execution>
63+
<execution>
64+
<id>stop-jetty</id>
65+
<phase>post-integration-test</phase>
66+
<goals>
67+
<goal>stop</goal>
68+
</goals>
69+
</execution>
70+
</executions>
71+
</plugin>
3872
<plugin>
3973
<groupId>org.codehaus.mojo</groupId>
4074
<artifactId>build-helper-maven-plugin</artifactId>
@@ -63,7 +97,6 @@
6397
<groupId>javax</groupId>
6498
<artifactId>javaee-api</artifactId>
6599
<version>7.0</version>
66-
<scope>provided</scope>
67100
</dependency>
68101
<dependency>
69102
<groupId>io.swagger.core.v3</groupId>
@@ -79,32 +112,32 @@
79112
<groupId>javax.servlet</groupId>
80113
<artifactId>servlet-api</artifactId>
81114
<version>${servlet-api-version}</version>
82-
<scope>provided</scope>
83115
</dependency>
84116

85117
<dependency>
86118
<groupId>org.jboss.resteasy</groupId>
87119
<artifactId>resteasy-jaxrs</artifactId>
88120
<version>${resteasy-version}</version>
89-
<scope>provided</scope>
121+
</dependency>
122+
<dependency>
123+
<groupId>org.jboss.resteasy</groupId>
124+
<artifactId>resteasy-servlet-initializer</artifactId>
125+
<version>${resteasy-version}</version>
90126
</dependency>
91127
<dependency>
92128
<groupId>org.jboss.resteasy</groupId>
93129
<artifactId>jaxrs-api</artifactId>
94130
<version>${resteasy-version}</version>
95-
<scope>provided</scope>
96131
</dependency>
97132
<dependency>
98133
<groupId>org.jboss.resteasy</groupId>
99134
<artifactId>resteasy-validator-provider-11</artifactId>
100135
<version>${resteasy-version}</version>
101-
<scope>provided</scope>
102136
</dependency>
103137
<dependency>
104138
<groupId>org.jboss.resteasy</groupId>
105139
<artifactId>resteasy-multipart-provider</artifactId>
106140
<version>${resteasy-version}</version>
107-
<scope>provided</scope>
108141
</dependency>
109142
<dependency>
110143
<groupId>org.jboss.resteasy</groupId>
@@ -122,13 +155,28 @@
122155
<dependency>
123156
<groupId>com.fasterxml.jackson.datatype</groupId>
124157
<artifactId>jackson-datatype-joda</artifactId>
125-
<version>2.4.1</version>
158+
<version>2.6.3</version>
126159
</dependency>
127160
<dependency>
128161
<groupId>joda-time</groupId>
129162
<artifactId>joda-time</artifactId>
130163
<version>2.7</version>
131164
</dependency>
165+
<dependency>
166+
<groupId>com.fasterxml.jackson.core</groupId>
167+
<artifactId>jackson-databind</artifactId>
168+
<version>2.6.3</version>
169+
</dependency>
170+
<dependency>
171+
<groupId>com.fasterxml.jackson.core</groupId>
172+
<artifactId>jackson-core</artifactId>
173+
<version>2.6.3</version>
174+
</dependency>
175+
<dependency>
176+
<groupId>com.fasterxml.jackson.core</groupId>
177+
<artifactId>jackson-annotations</artifactId>
178+
<version>2.6.3</version>
179+
</dependency>
132180
<dependency>
133181
<groupId>io.swagger.core.v3</groupId>
134182
<artifactId>swagger-jaxrs2</artifactId>

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/PetApi.java

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,33 +41,41 @@ public class PetApi {
4141

4242
@Consumes({ "application/json", "application/xml" })
4343

44-
@Operation(summary = "Add a new pet to the store", description = "", tags={ "pet" })
44+
@Operation(summary = "Add a new pet to the store", description = "", security = {
45+
@SecurityRequirement(name = "petstore_auth", scopes = {
46+
""
47+
})
48+
}, tags={ "pet" })
4549
@ApiResponses(value = {
4650
@ApiResponse(responseCode = "405", description = "Invalid input") })
47-
public Response addPet(
48-
@Parameter(description = "Pet object that needs to be added to the store" ,required=true) Pet body
49-
,@Context SecurityContext securityContext)
51+
public Response addPet(@Parameter(description = "Pet object that needs to be added to the store" ,required=true) Pet body,@Context SecurityContext securityContext)
5052
throws NotFoundException {
5153
return service.addPet(body,securityContext);
5254
}
5355
@DELETE
5456
@Path("/{petId}")
5557

5658

57-
@Operation(summary = "Deletes a pet", description = "", tags={ "pet" })
59+
@Operation(summary = "Deletes a pet", description = "", security = {
60+
@SecurityRequirement(name = "petstore_auth", scopes = {
61+
""
62+
})
63+
}, tags={ "pet" })
5864
@ApiResponses(value = {
5965
@ApiResponse(responseCode = "400", description = "Invalid pet value") })
60-
public Response deletePet( @PathParam("petId") Integer petId,
61-
@Parameter(description = "" )@HeaderParam("api_key") String apiKey
62-
,@Context SecurityContext securityContext)
66+
public Response deletePet( @PathParam("petId") Integer petId,@Parameter(description = "" )@HeaderParam("api_key") String apiKey,@Context SecurityContext securityContext)
6367
throws NotFoundException {
6468
return service.deletePet(petId,apiKey,securityContext);
6569
}
6670
@GET
6771
@Path("/findByStatus")
6872

6973
@Produces({ "application/xml", "application/json" })
70-
@Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", tags={ "pet" })
74+
@Operation(summary = "Finds Pets by status", description = "Multiple status values can be provided with comma separated strings", security = {
75+
@SecurityRequirement(name = "petstore_auth", scopes = {
76+
""
77+
})
78+
}, tags={ "pet" })
7179
@ApiResponses(value = {
7280
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))),
7381

@@ -80,7 +88,11 @@ public Response findPetsByStatus( @NotNull @QueryParam("status") List<String> s
8088
@Path("/findByTags")
8189

8290
@Produces({ "application/xml", "application/json" })
83-
@Operation(summary = "Finds Pets by tags", description = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", tags={ "pet" })
91+
@Operation(summary = "Finds Pets by tags", description = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", security = {
92+
@SecurityRequirement(name = "petstore_auth", scopes = {
93+
""
94+
})
95+
}, tags={ "pet" })
8496
@ApiResponses(value = {
8597
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Pet.class)))),
8698

@@ -93,7 +105,9 @@ public Response findPetsByTags( @NotNull @QueryParam("tags") List<String> tags,
93105
@Path("/{petId}")
94106

95107
@Produces({ "application/xml", "application/json" })
96-
@Operation(summary = "Find pet by ID", description = "Returns a single pet", tags={ "pet" })
108+
@Operation(summary = "Find pet by ID", description = "Returns a single pet", security = {
109+
@SecurityRequirement(name = "api_key")
110+
}, tags={ "pet" })
97111
@ApiResponses(value = {
98112
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Pet.class))),
99113

@@ -108,39 +122,45 @@ public Response getPetById( @PathParam("petId") Integer petId,@Context SecurityC
108122

109123
@Consumes({ "application/json", "application/xml" })
110124

111-
@Operation(summary = "Update an existing pet", description = "", tags={ "pet" })
125+
@Operation(summary = "Update an existing pet", description = "", security = {
126+
@SecurityRequirement(name = "petstore_auth", scopes = {
127+
""
128+
})
129+
}, tags={ "pet" })
112130
@ApiResponses(value = {
113131
@ApiResponse(responseCode = "400", description = "Invalid ID supplied"),
114132

115133
@ApiResponse(responseCode = "404", description = "Pet not found"),
116134

117135
@ApiResponse(responseCode = "405", description = "Validation exception") })
118-
public Response updatePet(
119-
@Parameter(description = "Pet object that needs to be added to the store" ,required=true) Pet body
120-
,@Context SecurityContext securityContext)
136+
public Response updatePet(@Parameter(description = "Pet object that needs to be added to the store" ,required=true) Pet body,@Context SecurityContext securityContext)
121137
throws NotFoundException {
122138
return service.updatePet(body,securityContext);
123139
}
124140
@POST
125141
@Path("/{petId}")
126142
@Consumes({ "application/x-www-form-urlencoded" })
127143

128-
@Operation(summary = "Updates a pet in the store with form data", description = "", tags={ "pet" })
144+
@Operation(summary = "Updates a pet in the store with form data", description = "", security = {
145+
@SecurityRequirement(name = "petstore_auth", scopes = {
146+
""
147+
})
148+
}, tags={ "pet" })
129149
@ApiResponses(value = {
130150
@ApiResponse(responseCode = "405", description = "Invalid input") })
131-
public Response updatePetWithForm( @PathParam("petId") Integer petId,
132-
@Parameter(description = "")@FormParam("name") String name
133-
,
134-
@Parameter(description = "")@FormParam("status") String status
135-
,@Context SecurityContext securityContext)
151+
public Response updatePetWithForm( @PathParam("petId") Integer petId,@Parameter(description = "")@FormParam("name") String name,@Parameter(description = "")@FormParam("status") String status,@Context SecurityContext securityContext)
136152
throws NotFoundException {
137153
return service.updatePetWithForm(petId,name,status,securityContext);
138154
}
139155
@POST
140156
@Path("/{petId}/uploadImage")
141157
@Consumes({ "multipart/form-data" })
142158
@Produces({ "application/json" })
143-
@Operation(summary = "uploads an image", description = "", tags={ "pet" })
159+
@Operation(summary = "uploads an image", description = "", security = {
160+
@SecurityRequirement(name = "petstore_auth", scopes = {
161+
""
162+
})
163+
}, tags={ "pet" })
144164
@ApiResponses(value = {
145165
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = ModelApiResponse.class))) })
146166
public Response uploadFile(MultipartFormDataInput input, @PathParam("petId") Integer petId,@Context SecurityContext securityContext)

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/PetApiService.java

Lines changed: 9 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import io.swagger.api.*;
44
import io.swagger.model.*;
5+
import org.jboss.resteasy.plugins.providers.multipart.MultipartFormDataInput;
56

67
import java.io.File;
78
import io.swagger.model.ModelApiResponse;
@@ -16,20 +17,12 @@
1617
import javax.ws.rs.core.SecurityContext;
1718

1819
public interface PetApiService {
19-
Response addPet(Pet body,SecurityContext securityContext)
20-
throws NotFoundException;
21-
Response deletePet(Integer petId,String apiKey,SecurityContext securityContext)
22-
throws NotFoundException;
23-
Response findPetsByStatus(List<String> status,SecurityContext securityContext)
24-
throws NotFoundException;
25-
Response findPetsByTags(List<String> tags,SecurityContext securityContext)
26-
throws NotFoundException;
27-
Response getPetById(Integer petId,SecurityContext securityContext)
28-
throws NotFoundException;
29-
Response updatePet(Pet body,SecurityContext securityContext)
30-
throws NotFoundException;
31-
Response updatePetWithForm(Integer petId,String name,String status,SecurityContext securityContext)
32-
throws NotFoundException;
33-
Response uploadFile(Integer petId,String additionalMetadata,FormDataContentDisposition fileDetail,SecurityContext securityContext)
34-
throws NotFoundException;
20+
Response addPet(Pet body,SecurityContext securityContext) throws NotFoundException;
21+
Response deletePet(Integer petId,String apiKey,SecurityContext securityContext) throws NotFoundException;
22+
Response findPetsByStatus(List<String> status,SecurityContext securityContext) throws NotFoundException;
23+
Response findPetsByTags(List<String> tags,SecurityContext securityContext) throws NotFoundException;
24+
Response getPetById(Integer petId,SecurityContext securityContext) throws NotFoundException;
25+
Response updatePet(Pet body,SecurityContext securityContext) throws NotFoundException;
26+
Response updatePetWithForm(Integer petId,String name,String status,SecurityContext securityContext) throws NotFoundException;
27+
Response uploadFile(MultipartFormDataInput input,Integer petId,SecurityContext securityContext) throws NotFoundException;
3528
}

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/StoreApi.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,9 @@ public Response deleteOrder( @PathParam("orderId") String orderId,@Context Secur
5252
@Path("/inventory")
5353

5454
@Produces({ "application/json" })
55-
@Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", tags={ "store" })
55+
@Operation(summary = "Returns pet inventories by status", description = "Returns a map of status codes to quantities", security = {
56+
@SecurityRequirement(name = "api_key")
57+
}, tags={ "store" })
5658
@ApiResponses(value = {
5759
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(array = @ArraySchema(schema = @Schema(implementation = Map.class)))) })
5860
public Response getInventory(@Context SecurityContext securityContext)
@@ -83,9 +85,7 @@ public Response getOrderById( @DecimalMin("1") @DecimalMax("5") @PathParam("orde
8385
@ApiResponse(responseCode = "200", description = "successful operation", content = @Content(schema = @Schema(implementation = Order.class))),
8486

8587
@ApiResponse(responseCode = "400", description = "Invalid Order") })
86-
public Response placeOrder(
87-
@Parameter(description = "order placed for purchasing the pet" ,required=true) Order body
88-
,@Context SecurityContext securityContext)
88+
public Response placeOrder(@Parameter(description = "order placed for purchasing the pet" ,required=true) Order body,@Context SecurityContext securityContext)
8989
throws NotFoundException {
9090
return service.placeOrder(body,securityContext);
9191
}

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/StoreApiService.java

Lines changed: 4 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -15,12 +15,8 @@
1515
import javax.ws.rs.core.SecurityContext;
1616

1717
public interface StoreApiService {
18-
Response deleteOrder(String orderId,SecurityContext securityContext)
19-
throws NotFoundException;
20-
Response getInventory(SecurityContext securityContext)
21-
throws NotFoundException;
22-
Response getOrderById(Integer orderId,SecurityContext securityContext)
23-
throws NotFoundException;
24-
Response placeOrder(Order body,SecurityContext securityContext)
25-
throws NotFoundException;
18+
Response deleteOrder(String orderId,SecurityContext securityContext) throws NotFoundException;
19+
Response getInventory(SecurityContext securityContext) throws NotFoundException;
20+
Response getOrderById(Integer orderId,SecurityContext securityContext) throws NotFoundException;
21+
Response placeOrder(Order body,SecurityContext securityContext) throws NotFoundException;
2622
}

samples/server/petstore/jaxrs-resteasy/default/src/gen/java/io/swagger/api/UserApi.java

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -41,9 +41,7 @@ public class UserApi {
4141
@Operation(summary = "Create user", description = "This can only be done by the logged in user.", tags={ "user" })
4242
@ApiResponses(value = {
4343
@ApiResponse(responseCode = "200", description = "successful operation") })
44-
public Response createUser(
45-
@Parameter(description = "Created user object" ,required=true) User body
46-
,@Context SecurityContext securityContext)
44+
public Response createUser(@Parameter(description = "Created user object" ,required=true) User body,@Context SecurityContext securityContext)
4745
throws NotFoundException {
4846
return service.createUser(body,securityContext);
4947
}
@@ -54,9 +52,7 @@ public Response createUser(
5452
@Operation(summary = "Creates list of users with given input array", description = "", tags={ "user" })
5553
@ApiResponses(value = {
5654
@ApiResponse(responseCode = "200", description = "successful operation") })
57-
public Response createUsersWithArrayInput(
58-
@Parameter(description = "List of user object" ,required=true) List<User> body
59-
,@Context SecurityContext securityContext)
55+
public Response createUsersWithArrayInput(@Parameter(description = "List of user object" ,required=true) List<User> body,@Context SecurityContext securityContext)
6056
throws NotFoundException {
6157
return service.createUsersWithArrayInput(body,securityContext);
6258
}
@@ -67,9 +63,7 @@ public Response createUsersWithArrayInput(
6763
@Operation(summary = "Creates list of users with given input array", description = "", tags={ "user" })
6864
@ApiResponses(value = {
6965
@ApiResponse(responseCode = "200", description = "successful operation") })
70-
public Response createUsersWithListInput(
71-
@Parameter(description = "List of user object" ,required=true) List<User> body
72-
,@Context SecurityContext securityContext)
66+
public Response createUsersWithListInput(@Parameter(description = "List of user object" ,required=true) List<User> body,@Context SecurityContext securityContext)
7367
throws NotFoundException {
7468
return service.createUsersWithListInput(body,securityContext);
7569
}
@@ -134,9 +128,7 @@ public Response logoutUser(@Context SecurityContext securityContext)
134128
@ApiResponse(responseCode = "400", description = "Invalid user supplied"),
135129

136130
@ApiResponse(responseCode = "404", description = "User not found") })
137-
public Response updateUser(
138-
@Parameter(description = "Updated user object" ,required=true) User body
139-
, @PathParam("username") String username,@Context SecurityContext securityContext)
131+
public Response updateUser(@Parameter(description = "Updated user object" ,required=true) User body, @PathParam("username") String username,@Context SecurityContext securityContext)
140132
throws NotFoundException {
141133
return service.updateUser(body,username,securityContext);
142134
}

0 commit comments

Comments
 (0)