Skip to content

Commit ad9b790

Browse files
committed
updated sample
1 parent 82436c5 commit ad9b790

25 files changed

+799
-425
lines changed

samples/server/petstore/jaxrs/pom.xml

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,25 @@
6262
</execution>
6363
</executions>
6464
</plugin>
65+
<plugin>
66+
<groupId>org.codehaus.mojo</groupId>
67+
<artifactId>build-helper-maven-plugin</artifactId>
68+
<version>1.9.1</version>
69+
<executions>
70+
<execution>
71+
<id>add-source</id>
72+
<phase>generate-sources</phase>
73+
<goals>
74+
<goal>add-source</goal>
75+
</goals>
76+
<configuration>
77+
<sources>
78+
<source>src/gen/java</source>
79+
</sources>
80+
</configuration>
81+
</execution>
82+
</executions>
83+
</plugin>
6584
</plugins>
6685
</build>
6786
<dependencies>
File renamed without changes.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Lines changed: 156 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,156 @@
1+
package io.swagger.api;
2+
3+
import io.swagger.model.*;
4+
import io.swagger.api.PetApiService;
5+
import io.swagger.api.factories.PetApiServiceFactory;
6+
7+
import com.wordnik.swagger.annotations.ApiParam;
8+
9+
import com.sun.jersey.multipart.FormDataParam;
10+
11+
import io.swagger.model.Pet;
12+
import java.io.File;
13+
14+
import java.util.List;
15+
import io.swagger.api.NotFoundException;
16+
17+
import java.io.InputStream;
18+
19+
import com.sun.jersey.core.header.FormDataContentDisposition;
20+
import com.sun.jersey.multipart.FormDataParam;
21+
22+
import javax.ws.rs.core.Response;
23+
import javax.ws.rs.*;
24+
25+
@Path("/pet")
26+
27+
28+
@com.wordnik.swagger.annotations.Api(value = "/pet", description = "the pet API")
29+
public class PetApi {
30+
31+
private final PetApiService delegate = PetApiServiceFactory.getPetApi();
32+
33+
@PUT
34+
35+
@Consumes({ "application/json", "application/xml" })
36+
@Produces({ "application/json", "application/xml" })
37+
@com.wordnik.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = Void.class)
38+
@com.wordnik.swagger.annotations.ApiResponses(value = {
39+
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Validation exception"),
40+
41+
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
42+
43+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
44+
45+
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
46+
throws NotFoundException {
47+
// do some magic!
48+
return delegate.updatePet(body);
49+
}
50+
@POST
51+
52+
@Consumes({ "application/json", "application/xml" })
53+
@Produces({ "application/json", "application/xml" })
54+
@com.wordnik.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = Void.class)
55+
@com.wordnik.swagger.annotations.ApiResponses(value = {
56+
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
57+
58+
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ) Pet body)
59+
throws NotFoundException {
60+
// do some magic!
61+
return delegate.addPet(body);
62+
}
63+
@GET
64+
@Path("/findByStatus")
65+
66+
@Produces({ "application/json", "application/xml" })
67+
@com.wordnik.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma seperated strings", response = Pet.class, responseContainer = "List")
68+
@com.wordnik.swagger.annotations.ApiResponses(value = {
69+
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
70+
71+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value") })
72+
73+
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter", defaultValue="available") @QueryParam("status") List<String> status)
74+
throws NotFoundException {
75+
// do some magic!
76+
return delegate.findPetsByStatus(status);
77+
}
78+
@GET
79+
@Path("/findByTags")
80+
81+
@Produces({ "application/json", "application/xml" })
82+
@com.wordnik.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Muliple tags can be provided with comma seperated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List")
83+
@com.wordnik.swagger.annotations.ApiResponses(value = {
84+
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
85+
86+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value") })
87+
88+
public Response findPetsByTags(@ApiParam(value = "Tags to filter by") @QueryParam("tags") List<String> tags)
89+
throws NotFoundException {
90+
// do some magic!
91+
return delegate.findPetsByTags(tags);
92+
}
93+
@GET
94+
@Path("/{petId}")
95+
96+
@Produces({ "application/json", "application/xml" })
97+
@com.wordnik.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a pet when ID < 10. ID > 10 or nonintegers will simulate API error conditions", response = Pet.class)
98+
@com.wordnik.swagger.annotations.ApiResponses(value = {
99+
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Pet not found"),
100+
101+
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
102+
103+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
104+
105+
public Response getPetById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("petId") Long petId)
106+
throws NotFoundException {
107+
// do some magic!
108+
return delegate.getPetById(petId);
109+
}
110+
@POST
111+
@Path("/{petId}")
112+
@Consumes({ "application/x-www-form-urlencoded" })
113+
@Produces({ "application/json", "application/xml" })
114+
@com.wordnik.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = Void.class)
115+
@com.wordnik.swagger.annotations.ApiResponses(value = {
116+
@com.wordnik.swagger.annotations.ApiResponse(code = 405, message = "Invalid input") })
117+
118+
public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true ) @PathParam("petId") String petId,
119+
@ApiParam(value = "Updated name of the pet" )@FormParam("name") String name,
120+
@ApiParam(value = "Updated status of the pet" )@FormParam("status") String status)
121+
throws NotFoundException {
122+
// do some magic!
123+
return delegate.updatePetWithForm(petId,name,status);
124+
}
125+
@DELETE
126+
@Path("/{petId}")
127+
128+
@Produces({ "application/json", "application/xml" })
129+
@com.wordnik.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = Void.class)
130+
@com.wordnik.swagger.annotations.ApiResponses(value = {
131+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value") })
132+
133+
public Response deletePet(@ApiParam(value = "" )@HeaderParam("api_key") String apiKey,
134+
@ApiParam(value = "Pet id to delete",required=true ) @PathParam("petId") Long petId)
135+
throws NotFoundException {
136+
// do some magic!
137+
return delegate.deletePet(apiKey,petId);
138+
}
139+
@POST
140+
@Path("/{petId}/uploadImage")
141+
@Consumes({ "multipart/form-data" })
142+
@Produces({ "application/json", "application/xml" })
143+
@com.wordnik.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = Void.class)
144+
@com.wordnik.swagger.annotations.ApiResponses(value = {
145+
@com.wordnik.swagger.annotations.ApiResponse(code = 0, message = "successful operation") })
146+
147+
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true ) @PathParam("petId") Long petId,
148+
@ApiParam(value = "Additional data to pass to server" )@FormParam("additionalMetadata") String additionalMetadata,
149+
@ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream,
150+
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail)
151+
throws NotFoundException {
152+
// do some magic!
153+
return delegate.uploadFile(petId,additionalMetadata,fileDetail);
154+
}
155+
}
156+
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
package io.swagger.api;
2+
3+
import io.swagger.api.*;
4+
import io.swagger.model.*;
5+
6+
import com.sun.jersey.multipart.FormDataParam;
7+
8+
import io.swagger.model.Pet;
9+
import java.io.File;
10+
11+
import java.util.List;
12+
import io.swagger.api.NotFoundException;
13+
14+
import java.io.InputStream;
15+
16+
import com.sun.jersey.core.header.FormDataContentDisposition;
17+
import com.sun.jersey.multipart.FormDataParam;
18+
19+
import javax.ws.rs.core.Response;
20+
21+
public abstract class PetApiService {
22+
23+
public abstract Response updatePet(Pet body)
24+
throws NotFoundException;
25+
26+
public abstract Response addPet(Pet body)
27+
throws NotFoundException;
28+
29+
public abstract Response findPetsByStatus(List<String> status)
30+
throws NotFoundException;
31+
32+
public abstract Response findPetsByTags(List<String> tags)
33+
throws NotFoundException;
34+
35+
public abstract Response getPetById(Long petId)
36+
throws NotFoundException;
37+
38+
public abstract Response updatePetWithForm(String petId,String name,String status)
39+
throws NotFoundException;
40+
41+
public abstract Response deletePet(String apiKey,Long petId)
42+
throws NotFoundException;
43+
44+
public abstract Response uploadFile(Long petId,String additionalMetadata,FormDataContentDisposition fileDetail)
45+
throws NotFoundException;
46+
47+
}
Lines changed: 94 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,94 @@
1+
package io.swagger.api;
2+
3+
import io.swagger.model.*;
4+
import io.swagger.api.StoreApiService;
5+
import io.swagger.api.factories.StoreApiServiceFactory;
6+
7+
import com.wordnik.swagger.annotations.ApiParam;
8+
9+
import com.sun.jersey.multipart.FormDataParam;
10+
11+
import java.util.Map;
12+
import io.swagger.model.Order;
13+
14+
import java.util.List;
15+
import io.swagger.api.NotFoundException;
16+
17+
import java.io.InputStream;
18+
19+
import com.sun.jersey.core.header.FormDataContentDisposition;
20+
import com.sun.jersey.multipart.FormDataParam;
21+
22+
import javax.ws.rs.core.Response;
23+
import javax.ws.rs.*;
24+
25+
@Path("/store")
26+
27+
28+
@com.wordnik.swagger.annotations.Api(value = "/store", description = "the store API")
29+
public class StoreApi {
30+
31+
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
32+
33+
@GET
34+
@Path("/inventory")
35+
36+
@Produces({ "application/json", "application/xml" })
37+
@com.wordnik.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "map")
38+
@com.wordnik.swagger.annotations.ApiResponses(value = {
39+
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation") })
40+
41+
public Response getInventory()
42+
throws NotFoundException {
43+
// do some magic!
44+
return delegate.getInventory();
45+
}
46+
@POST
47+
@Path("/order")
48+
49+
@Produces({ "application/json", "application/xml" })
50+
@com.wordnik.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class)
51+
@com.wordnik.swagger.annotations.ApiResponses(value = {
52+
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
53+
54+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order") })
55+
56+
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ) Order body)
57+
throws NotFoundException {
58+
// do some magic!
59+
return delegate.placeOrder(body);
60+
}
61+
@GET
62+
@Path("/order/{orderId}")
63+
64+
@Produces({ "application/json", "application/xml" })
65+
@com.wordnik.swagger.annotations.ApiOperation(value = "Find purchase order by ID", notes = "For valid response try integer IDs with value <= 5 or > 10. Other values will generated exceptions", response = Order.class)
66+
@com.wordnik.swagger.annotations.ApiResponses(value = {
67+
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
68+
69+
@com.wordnik.swagger.annotations.ApiResponse(code = 200, message = "successful operation"),
70+
71+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
72+
73+
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true ) @PathParam("orderId") String orderId)
74+
throws NotFoundException {
75+
// do some magic!
76+
return delegate.getOrderById(orderId);
77+
}
78+
@DELETE
79+
@Path("/order/{orderId}")
80+
81+
@Produces({ "application/json", "application/xml" })
82+
@com.wordnik.swagger.annotations.ApiOperation(value = "Delete purchase order by ID", notes = "For valid response try integer IDs with value < 1000. Anything above 1000 or nonintegers will generate API errors", response = Void.class)
83+
@com.wordnik.swagger.annotations.ApiResponses(value = {
84+
@com.wordnik.swagger.annotations.ApiResponse(code = 404, message = "Order not found"),
85+
86+
@com.wordnik.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied") })
87+
88+
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true ) @PathParam("orderId") String orderId)
89+
throws NotFoundException {
90+
// do some magic!
91+
return delegate.deleteOrder(orderId);
92+
}
93+
}
94+
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
package io.swagger.api;
2+
3+
import io.swagger.api.*;
4+
import io.swagger.model.*;
5+
6+
import com.sun.jersey.multipart.FormDataParam;
7+
8+
import java.util.Map;
9+
import io.swagger.model.Order;
10+
11+
import java.util.List;
12+
import io.swagger.api.NotFoundException;
13+
14+
import java.io.InputStream;
15+
16+
import com.sun.jersey.core.header.FormDataContentDisposition;
17+
import com.sun.jersey.multipart.FormDataParam;
18+
19+
import javax.ws.rs.core.Response;
20+
21+
public abstract class StoreApiService {
22+
23+
public abstract Response getInventory()
24+
throws NotFoundException;
25+
26+
public abstract Response placeOrder(Order body)
27+
throws NotFoundException;
28+
29+
public abstract Response getOrderById(String orderId)
30+
throws NotFoundException;
31+
32+
public abstract Response deleteOrder(String orderId)
33+
throws NotFoundException;
34+
35+
}

0 commit comments

Comments
 (0)