Skip to content

Commit 04642ff

Browse files
committed
fixed xml marshaling error
1 parent 82cd80f commit 04642ff

File tree

3 files changed

+11
-7
lines changed

3 files changed

+11
-7
lines changed

samples/java-jersey-jaxrs/src/main/java/com/wordnik/swagger/sample/data/PetData.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,8 +92,12 @@ public List<Pet> findPetByStatus(String status) {
9292
}
9393

9494
public List<Pet> findPetByTags(String tags) {
95-
String[] tagList = tags.split(",");
9695
List<Pet> result = new java.util.ArrayList<Pet>();
96+
97+
if(tags == null) {
98+
return result;
99+
}
100+
String[] tagList = tags.split(",");
97101
for (Pet pet : pets) {
98102
if (null != pet.getTags()) {
99103
for (Tag tag : pet.getTags()) {

samples/java-jersey-jaxrs/src/main/java/com/wordnik/swagger/sample/resource/PetResource.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,7 @@
3232
import java.io.FileInputStream;
3333
import java.io.InputStream;
3434
import java.io.FileOutputStream;
35+
import java.util.List;
3536

3637
import org.apache.commons.io.IOUtils;
3738

@@ -97,7 +98,6 @@ public Response uploadFile(
9798
@ApiParam(value = "file to upload") @FormDataParam("file") InputStream inputStream,
9899
@ApiParam(value = "file detail") @FormDataParam("file") FormDataContentDisposition fileDetail) {
99100
LOGGER.debug("testString: " + testString);
100-
System.out.println("uploading file " + testString);
101101
try {
102102
String uploadedFileLocation = "./" + fileDetail.getFileName();
103103
System.out.println("uploading to " + uploadedFileLocation);
@@ -142,7 +142,8 @@ public Response updatePet(
142142
@ApiResponses(value = { @ApiResponse(code = 400, message = "Invalid status value") })
143143
public Response findPetsByStatus(
144144
@ApiParam(value = "Status values that need to be considered for filter", required = true, defaultValue = "available", allowableValues = "available,pending,sold", allowMultiple = true) @QueryParam("status") String status) {
145-
return Response.ok(petData.findPetByStatus(status)).build();
145+
List<Pet> pets = petData.findPetByStatus(status);
146+
return Response.ok(pets.toArray(new Pet[pets.size()])).build();
146147
}
147148

148149
@GET
@@ -155,7 +156,8 @@ public Response findPetsByStatus(
155156
@Deprecated
156157
public Response findPetsByTags(
157158
@ApiParam(value = "Tags to filter by", required = true, allowMultiple = true) @QueryParam("tags") String tags) {
158-
return Response.ok(petData.findPetByTags(tags)).build();
159+
List<Pet> pets = petData.findPetByTags(tags);
160+
return Response.ok(pets.toArray(new Pet[pets.size()])).build();
159161
}
160162

161163
@POST
@@ -173,6 +175,4 @@ public Response updatePetWithForm (
173175
System.out.println(status);
174176
return Response.ok().entity(new com.wordnik.swagger.sample.model.ApiResponse(200, "SUCCESS")).build();
175177
}
176-
177-
178178
}

samples/java-jersey-jaxrs/src/main/java/com/wordnik/swagger/sample/resource/PetStoreResource.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ public class PetStoreResource {
3535

3636
@GET
3737
@Path("/inventory")
38-
@Produces({MediaType.APPLICATION_JSON, MediaType.APPLICATION_XML})
38+
@Produces({MediaType.APPLICATION_JSON})
3939
@ApiOperation(value = "Returns pet inventories by status",
4040
notes = "Returns a map of status codes to quantities",
4141
response = Integer.class,

0 commit comments

Comments
 (0)