update jaxrs sample

This commit is contained in:
wing328 2016-07-07 11:38:07 +08:00
parent 4d76dd24eb
commit 2d24e9971c
7 changed files with 422 additions and 397 deletions

View File

@ -36,6 +36,6 @@ public abstract class PetApiService {
throws NotFoundException; throws NotFoundException;
public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext)
throws NotFoundException; throws NotFoundException;
public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream inputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext)
throws NotFoundException; throws NotFoundException;
} }

View File

@ -65,7 +65,7 @@ public class PetApiServiceImpl extends PetApiService {
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
} }
@Override @Override
public Response uploadFile(Long petId, String additionalMetadata, InputStream inputStream, FormDataContentDisposition fileDetail, SecurityContext securityContext) public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, FormDataContentDisposition fileDetail, SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
// do some magic! // do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();

View File

@ -7,8 +7,8 @@ import io.swagger.api.factories.PetApiServiceFactory;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.model.Pet; import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File; import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;
@ -43,7 +43,8 @@ public class PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = void.class) })
public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet body,@Context SecurityContext securityContext) public Response addPet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.addPet(body,securityContext); return delegate.addPet(body,securityContext);
} }
@ -59,7 +60,9 @@ public class PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = void.class) })
public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathParam("petId") Long petId,@ApiParam(value = "" )@HeaderParam("api_key") String apiKey,@Context SecurityContext securityContext) public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathParam("petId") Long petId
,@ApiParam(value = "" )@HeaderParam("api_key") String apiKey
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.deletePet(petId,apiKey,securityContext); return delegate.deletePet(petId,apiKey,securityContext);
} }
@ -77,7 +80,8 @@ public class PetApi {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") })
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter",required=true) @QueryParam("status") List<String> status,@Context SecurityContext securityContext) public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter",required=true) @QueryParam("status") List<String> status
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.findPetsByStatus(status,securityContext); return delegate.findPetsByStatus(status,securityContext);
} }
@ -95,7 +99,8 @@ public class PetApi {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") })
public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List<String> tags,@Context SecurityContext securityContext) public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List<String> tags
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.findPetsByTags(tags,securityContext); return delegate.findPetsByTags(tags,securityContext);
} }
@ -112,7 +117,8 @@ public class PetApi {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class) })
public Response getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathParam("petId") Long petId,@Context SecurityContext securityContext) public Response getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathParam("petId") Long petId
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.getPetById(petId,securityContext); return delegate.getPetById(petId,securityContext);
} }
@ -132,7 +138,8 @@ public class PetApi {
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = void.class), @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = void.class),
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = void.class) })
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet body,@Context SecurityContext securityContext) public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.updatePet(body,securityContext); return delegate.updatePet(body,securityContext);
} }
@ -148,7 +155,10 @@ public class PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = void.class) })
public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathParam("petId") Long petId,@ApiParam(value = "Updated name of the pet")@FormParam("name") String name,@ApiParam(value = "Updated status of the pet")@FormParam("status") String status,@Context SecurityContext securityContext) public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathParam("petId") Long petId
,@ApiParam(value = "Updated name of the pet")@FormParam("name") String name
,@ApiParam(value = "Updated status of the pet")@FormParam("status") String status
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.updatePetWithForm(petId,name,status,securityContext); return delegate.updatePetWithForm(petId,name,status,securityContext);
} }
@ -164,10 +174,13 @@ public class PetApi {
}, tags={ "pet", }) }, tags={ "pet", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) })
public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata") String additionalMetadata, public Response uploadFile(@ApiParam(value = "ID of pet to update",required=true) @PathParam("petId") Long petId
@FormDataParam("file") InputStream inputStream, ,@ApiParam(value = "Additional data to pass to server")@FormDataParam("additionalMetadata") String additionalMetadata
@FormDataParam("file") FormDataContentDisposition fileDetail,@Context SecurityContext securityContext) ,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.uploadFile(petId,additionalMetadata,inputStream, fileDetail,securityContext); return delegate.uploadFile(petId,additionalMetadata,fileInputStream, fileDetail,securityContext);
} }
} }

View File

@ -6,8 +6,8 @@ import io.swagger.model.*;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import io.swagger.model.Pet; import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File; import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;
@ -26,5 +26,5 @@ public abstract class PetApiService {
public abstract Response getPetById(Long petId,SecurityContext securityContext) throws NotFoundException; public abstract Response getPetById(Long petId,SecurityContext securityContext) throws NotFoundException;
public abstract Response updatePet(Pet body,SecurityContext securityContext) throws NotFoundException; public abstract Response updatePet(Pet body,SecurityContext securityContext) throws NotFoundException;
public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException; public abstract Response updatePetWithForm(Long petId,String name,String status,SecurityContext securityContext) throws NotFoundException;
public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream inputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException; public abstract Response uploadFile(Long petId,String additionalMetadata,InputStream fileInputStream, FormDataContentDisposition fileDetail,SecurityContext securityContext) throws NotFoundException;
} }

View File

@ -39,7 +39,8 @@ public class StoreApi {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = void.class) })
public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathParam("orderId") String orderId,@Context SecurityContext securityContext) public Response deleteOrder(@ApiParam(value = "ID of the order that needs to be deleted",required=true) @PathParam("orderId") String orderId
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.deleteOrder(orderId,securityContext); return delegate.deleteOrder(orderId,securityContext);
} }
@ -67,7 +68,8 @@ public class StoreApi {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class) }) @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class) })
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId,@Context SecurityContext securityContext) public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.getOrderById(orderId,securityContext); return delegate.getOrderById(orderId,securityContext);
} }
@ -80,7 +82,8 @@ public class StoreApi {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true) Order body,@Context SecurityContext securityContext) public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true) Order body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.placeOrder(body,securityContext); return delegate.placeOrder(body,securityContext);
} }

View File

@ -37,7 +37,8 @@ public class UserApi {
@io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) @io.swagger.annotations.ApiOperation(value = "Create user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) })
public Response createUser(@ApiParam(value = "Created user object" ,required=true) User body,@Context SecurityContext securityContext) public Response createUser(@ApiParam(value = "Created user object" ,required=true) User body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.createUser(body,securityContext); return delegate.createUser(body,securityContext);
} }
@ -48,7 +49,8 @@ public class UserApi {
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", }) @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) })
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true) List<User> body,@Context SecurityContext securityContext) public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true) List<User> body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.createUsersWithArrayInput(body,securityContext); return delegate.createUsersWithArrayInput(body,securityContext);
} }
@ -59,7 +61,8 @@ public class UserApi {
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", }) @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) })
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true) List<User> body,@Context SecurityContext securityContext) public Response createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true) List<User> body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.createUsersWithListInput(body,securityContext); return delegate.createUsersWithListInput(body,securityContext);
} }
@ -72,7 +75,8 @@ public class UserApi {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = void.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) })
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathParam("username") String username,@Context SecurityContext securityContext) public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathParam("username") String username
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.deleteUser(username,securityContext); return delegate.deleteUser(username,securityContext);
} }
@ -87,7 +91,8 @@ public class UserApi {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) }) @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) })
public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathParam("username") String username,@Context SecurityContext securityContext) public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathParam("username") String username
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.getUserByName(username,securityContext); return delegate.getUserByName(username,securityContext);
} }
@ -100,7 +105,9 @@ public class UserApi {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class), @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class),
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
public Response loginUser(@ApiParam(value = "The user name for login",required=true) @QueryParam("username") String username,@ApiParam(value = "The password for login in clear text",required=true) @QueryParam("password") String password,@Context SecurityContext securityContext) public Response loginUser(@ApiParam(value = "The user name for login",required=true) @QueryParam("username") String username
,@ApiParam(value = "The password for login in clear text",required=true) @QueryParam("password") String password
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.loginUser(username,password,securityContext); return delegate.loginUser(username,password,securityContext);
} }
@ -124,7 +131,9 @@ public class UserApi {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = void.class), @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = void.class),
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) }) @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) })
public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathParam("username") String username,@ApiParam(value = "Updated user object" ,required=true) User body,@Context SecurityContext securityContext) public Response updateUser(@ApiParam(value = "name that need to be deleted",required=true) @PathParam("username") String username
,@ApiParam(value = "Updated user object" ,required=true) User body
,@Context SecurityContext securityContext)
throws NotFoundException { throws NotFoundException {
return delegate.updateUser(username,body,securityContext); return delegate.updateUser(username,body,securityContext);
} }

View File

@ -4,8 +4,8 @@ import io.swagger.api.*;
import io.swagger.model.*; import io.swagger.model.*;
import io.swagger.model.Pet; import io.swagger.model.Pet;
import io.swagger.model.ModelApiResponse;
import java.io.File; import java.io.File;
import io.swagger.model.ModelApiResponse;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;
@ -55,7 +55,7 @@ public class PetApiServiceImpl extends PetApiService {
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
} }
@Override @Override
public Response uploadFile(Long petId, String additionalMetadata, InputStream inputStream, FormDataContentDisposition fileDetail, SecurityContext securityContext) throws NotFoundException { public Response uploadFile(Long petId, String additionalMetadata, InputStream fileInputStream, FormDataContentDisposition fileDetail, SecurityContext securityContext) throws NotFoundException {
// do some magic! // do some magic!
return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build(); return Response.ok().entity(new ApiResponseMessage(ApiResponseMessage.OK, "magic!")).build();
} }