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

@ -1,173 +1,186 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.*; import io.swagger.model.*;
import io.swagger.api.PetApiService; import io.swagger.api.PetApiService;
import io.swagger.api.factories.PetApiServiceFactory; 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;
import java.io.InputStream; import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*; import javax.ws.rs.*;
@Path("/pet") @Path("/pet")
@io.swagger.annotations.Api(description = "the pet API") @io.swagger.annotations.Api(description = "the pet API")
public class PetApi { public class PetApi {
private final PetApiService delegate = PetApiServiceFactory.getPetApi(); private final PetApiService delegate = PetApiServiceFactory.getPetApi();
@POST @POST
@Consumes({ "application/json", "application/xml" }) @Consumes({ "application/json", "application/xml" })
@Produces({ "application/xml", "application/json" }) @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = void.class, authorizations = { @io.swagger.annotations.ApiOperation(value = "Add a new pet to the store", notes = "", response = void.class, authorizations = {
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
}) })
}, 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
throws NotFoundException { ,@Context SecurityContext securityContext)
return delegate.addPet(body,securityContext); throws NotFoundException {
} return delegate.addPet(body,securityContext);
@DELETE }
@Path("/{petId}") @DELETE
@Path("/{petId}")
@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = void.class, authorizations = { @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @io.swagger.annotations.ApiOperation(value = "Deletes a pet", notes = "", response = void.class, authorizations = {
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
}) @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
}, tags={ "pet", }) })
@io.swagger.annotations.ApiResponses(value = { }, tags={ "pet", })
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = void.class) }) @io.swagger.annotations.ApiResponses(value = {
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) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid pet value", response = void.class) })
throws NotFoundException { public Response deletePet(@ApiParam(value = "Pet id to delete",required=true) @PathParam("petId") Long petId
return delegate.deletePet(petId,apiKey,securityContext); ,@ApiParam(value = "" )@HeaderParam("api_key") String apiKey
} ,@Context SecurityContext securityContext)
@GET throws NotFoundException {
@Path("/findByStatus") return delegate.deletePet(petId,apiKey,securityContext);
}
@Produces({ "application/xml", "application/json" }) @GET
@io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = { @Path("/findByStatus")
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") @io.swagger.annotations.ApiOperation(value = "Finds Pets by status", notes = "Multiple status values can be provided with comma separated strings", response = Pet.class, responseContainer = "List", authorizations = {
}) @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
}, tags={ "pet", }) @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), })
}, tags={ "pet", })
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid status value", response = Pet.class, responseContainer = "List") }) @io.swagger.annotations.ApiResponses(value = {
public Response findPetsByStatus(@ApiParam(value = "Status values that need to be considered for filter",required=true) @QueryParam("status") List<String> status,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
throws NotFoundException {
return delegate.findPetsByStatus(status,securityContext); @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
@GET ,@Context SecurityContext securityContext)
@Path("/findByTags") throws NotFoundException {
return delegate.findPetsByStatus(status,securityContext);
@Produces({ "application/xml", "application/json" }) }
@io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = { @GET
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { @Path("/findByTags")
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") @Produces({ "application/xml", "application/json" })
}) @io.swagger.annotations.ApiOperation(value = "Finds Pets by tags", notes = "Multiple tags can be provided with comma separated strings. Use tag1, tag2, tag3 for testing.", response = Pet.class, responseContainer = "List", authorizations = {
}, tags={ "pet", }) @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
})
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") }) }, tags={ "pet", })
public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List<String> tags,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponses(value = {
throws NotFoundException { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class, responseContainer = "List"),
return delegate.findPetsByTags(tags,securityContext);
} @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid tag value", response = Pet.class, responseContainer = "List") })
@GET public Response findPetsByTags(@ApiParam(value = "Tags to filter by",required=true) @QueryParam("tags") List<String> tags
@Path("/{petId}") ,@Context SecurityContext securityContext)
throws NotFoundException {
@Produces({ "application/xml", "application/json" }) return delegate.findPetsByTags(tags,securityContext);
@io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = { }
@io.swagger.annotations.Authorization(value = "api_key") @GET
}, tags={ "pet", }) @Path("/{petId}")
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class), @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Find pet by ID", notes = "Returns a single pet", response = Pet.class, authorizations = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class), @io.swagger.annotations.Authorization(value = "api_key")
}, tags={ "pet", })
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = Pet.class) }) @io.swagger.annotations.ApiResponses(value = {
public Response getPetById(@ApiParam(value = "ID of pet to return",required=true) @PathParam("petId") Long petId,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Pet.class),
throws NotFoundException {
return delegate.getPetById(petId,securityContext); @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = Pet.class),
}
@PUT @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
@Consumes({ "application/json", "application/xml" }) ,@Context SecurityContext securityContext)
@Produces({ "application/xml", "application/json" }) throws NotFoundException {
@io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = void.class, authorizations = { return delegate.getPetById(petId,securityContext);
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { }
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), @PUT
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
}) @Consumes({ "application/json", "application/xml" })
}, tags={ "pet", }) @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiOperation(value = "Update an existing pet", notes = "", response = void.class, authorizations = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class), @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
@io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = void.class), @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
})
@io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = void.class) }) }, tags={ "pet", })
public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet body,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponses(value = {
throws NotFoundException { @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid ID supplied", response = void.class),
return delegate.updatePet(body,securityContext);
} @io.swagger.annotations.ApiResponse(code = 404, message = "Pet not found", response = void.class),
@POST
@Path("/{petId}") @io.swagger.annotations.ApiResponse(code = 405, message = "Validation exception", response = void.class) })
@Consumes({ "application/x-www-form-urlencoded" }) public Response updatePet(@ApiParam(value = "Pet object that needs to be added to the store" ,required=true) Pet body
@Produces({ "application/xml", "application/json" }) ,@Context SecurityContext securityContext)
@io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = void.class, authorizations = { throws NotFoundException {
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { return delegate.updatePet(body,securityContext);
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), }
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") @POST
}) @Path("/{petId}")
}, tags={ "pet", }) @Consumes({ "application/x-www-form-urlencoded" })
@io.swagger.annotations.ApiResponses(value = { @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = void.class) }) @io.swagger.annotations.ApiOperation(value = "Updates a pet in the store with form data", notes = "", response = void.class, authorizations = {
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) @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
throws NotFoundException { @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
return delegate.updatePetWithForm(petId,name,status,securityContext); @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
} })
@POST }, tags={ "pet", })
@Path("/{petId}/uploadImage") @io.swagger.annotations.ApiResponses(value = {
@Consumes({ "multipart/form-data" }) @io.swagger.annotations.ApiResponse(code = 405, message = "Invalid input", response = void.class) })
@Produces({ "application/json" }) public Response updatePetWithForm(@ApiParam(value = "ID of pet that needs to be updated",required=true) @PathParam("petId") Long petId
@io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = { ,@ApiParam(value = "Updated name of the pet")@FormParam("name") String name
@io.swagger.annotations.Authorization(value = "petstore_auth", scopes = { ,@ApiParam(value = "Updated status of the pet")@FormParam("status") String status
@io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"), ,@Context SecurityContext securityContext)
@io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets") throws NotFoundException {
}) return delegate.updatePetWithForm(petId,name,status,securityContext);
}, tags={ "pet", }) }
@io.swagger.annotations.ApiResponses(value = { @POST
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = ModelApiResponse.class) }) @Path("/{petId}/uploadImage")
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, @Consumes({ "multipart/form-data" })
@FormDataParam("file") InputStream inputStream, @Produces({ "application/json" })
@FormDataParam("file") FormDataContentDisposition fileDetail,@Context SecurityContext securityContext) @io.swagger.annotations.ApiOperation(value = "uploads an image", notes = "", response = ModelApiResponse.class, authorizations = {
throws NotFoundException { @io.swagger.annotations.Authorization(value = "petstore_auth", scopes = {
return delegate.uploadFile(petId,additionalMetadata,inputStream, fileDetail,securityContext); @io.swagger.annotations.AuthorizationScope(scope = "write:pets", description = "modify pets in your account"),
} @io.swagger.annotations.AuthorizationScope(scope = "read:pets", description = "read your pets")
} })
}, tags={ "pet", })
@io.swagger.annotations.ApiResponses(value = {
@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
,
@FormDataParam("file") InputStream fileInputStream,
@FormDataParam("file") FormDataContentDisposition fileDetail
,@Context SecurityContext securityContext)
throws NotFoundException {
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

@ -1,87 +1,90 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.*; import io.swagger.model.*;
import io.swagger.api.StoreApiService; import io.swagger.api.StoreApiService;
import io.swagger.api.factories.StoreApiServiceFactory; import io.swagger.api.factories.StoreApiServiceFactory;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import java.util.Map; import java.util.Map;
import io.swagger.model.Order; import io.swagger.model.Order;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;
import java.io.InputStream; import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*; import javax.ws.rs.*;
@Path("/store") @Path("/store")
@io.swagger.annotations.Api(description = "the store API") @io.swagger.annotations.Api(description = "the store API")
public class StoreApi { public class StoreApi {
private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi(); private final StoreApiService delegate = StoreApiServiceFactory.getStoreApi();
@DELETE @DELETE
@Path("/order/{orderId}") @Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" }) @Produces({ "application/xml", "application/json" })
@io.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, tags={ "store", }) @io.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, tags={ "store", })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiResponses(value = {
@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
throws NotFoundException { ,@Context SecurityContext securityContext)
return delegate.deleteOrder(orderId,securityContext); throws NotFoundException {
} return delegate.deleteOrder(orderId,securityContext);
@GET }
@Path("/inventory") @GET
@Path("/inventory")
@Produces({ "application/json" })
@io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = { @Produces({ "application/json" })
@io.swagger.annotations.Authorization(value = "api_key") @io.swagger.annotations.ApiOperation(value = "Returns pet inventories by status", notes = "Returns a map of status codes to quantities", response = Integer.class, responseContainer = "Map", authorizations = {
}, tags={ "store", }) @io.swagger.annotations.Authorization(value = "api_key")
@io.swagger.annotations.ApiResponses(value = { }, tags={ "store", })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") }) @io.swagger.annotations.ApiResponses(value = {
public Response getInventory(@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Integer.class, responseContainer = "Map") })
throws NotFoundException { public Response getInventory(@Context SecurityContext securityContext)
return delegate.getInventory(securityContext); throws NotFoundException {
} return delegate.getInventory(securityContext);
@GET }
@Path("/order/{orderId}") @GET
@Path("/order/{orderId}")
@Produces({ "application/xml", "application/json" })
@io.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, tags={ "store", }) @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponses(value = { @io.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, tags={ "store", })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
@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) })
public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponse(code = 404, message = "Order not found", response = Order.class) })
throws NotFoundException { public Response getOrderById(@ApiParam(value = "ID of pet that needs to be fetched",required=true) @PathParam("orderId") Long orderId
return delegate.getOrderById(orderId,securityContext); ,@Context SecurityContext securityContext)
} throws NotFoundException {
@POST return delegate.getOrderById(orderId,securityContext);
@Path("/order") }
@POST
@Produces({ "application/xml", "application/json" }) @Path("/order")
@io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
@io.swagger.annotations.ApiResponses(value = { @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class), @io.swagger.annotations.ApiOperation(value = "Place an order for a pet", notes = "", response = Order.class, tags={ "store", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = Order.class),
public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true) Order body,@Context SecurityContext securityContext)
throws NotFoundException { @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid Order", response = Order.class) })
return delegate.placeOrder(body,securityContext); public Response placeOrder(@ApiParam(value = "order placed for purchasing the pet" ,required=true) Order body
} ,@Context SecurityContext securityContext)
} throws NotFoundException {
return delegate.placeOrder(body,securityContext);
}
}

View File

@ -1,131 +1,140 @@
package io.swagger.api; package io.swagger.api;
import io.swagger.model.*; import io.swagger.model.*;
import io.swagger.api.UserApiService; import io.swagger.api.UserApiService;
import io.swagger.api.factories.UserApiServiceFactory; import io.swagger.api.factories.UserApiServiceFactory;
import io.swagger.annotations.ApiParam; import io.swagger.annotations.ApiParam;
import io.swagger.model.User; import io.swagger.model.User;
import java.util.List; import java.util.List;
import java.util.List; import java.util.List;
import io.swagger.api.NotFoundException; import io.swagger.api.NotFoundException;
import java.io.InputStream; import java.io.InputStream;
import org.glassfish.jersey.media.multipart.FormDataContentDisposition; import org.glassfish.jersey.media.multipart.FormDataContentDisposition;
import org.glassfish.jersey.media.multipart.FormDataParam; import org.glassfish.jersey.media.multipart.FormDataParam;
import javax.ws.rs.core.Context; import javax.ws.rs.core.Context;
import javax.ws.rs.core.Response; import javax.ws.rs.core.Response;
import javax.ws.rs.core.SecurityContext; import javax.ws.rs.core.SecurityContext;
import javax.ws.rs.*; import javax.ws.rs.*;
@Path("/user") @Path("/user")
@io.swagger.annotations.Api(description = "the user API") @io.swagger.annotations.Api(description = "the user API")
public class UserApi { public class UserApi {
private final UserApiService delegate = UserApiServiceFactory.getUserApi(); private final UserApiService delegate = UserApiServiceFactory.getUserApi();
@POST @POST
@Produces({ "application/xml", "application/json" }) @Produces({ "application/xml", "application/json" })
@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
throws NotFoundException { ,@Context SecurityContext securityContext)
return delegate.createUser(body,securityContext); throws NotFoundException {
} return delegate.createUser(body,securityContext);
@POST }
@Path("/createWithArray") @POST
@Path("/createWithArray")
@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", }) @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponses(value = { @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) @io.swagger.annotations.ApiResponses(value = {
public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true) List<User> body,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) })
throws NotFoundException { public Response createUsersWithArrayInput(@ApiParam(value = "List of user object" ,required=true) List<User> body
return delegate.createUsersWithArrayInput(body,securityContext); ,@Context SecurityContext securityContext)
} throws NotFoundException {
@POST return delegate.createUsersWithArrayInput(body,securityContext);
@Path("/createWithList") }
@POST
@Produces({ "application/xml", "application/json" }) @Path("/createWithList")
@io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
@io.swagger.annotations.ApiResponses(value = { @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) @io.swagger.annotations.ApiOperation(value = "Creates list of users with given input array", notes = "", response = void.class, tags={ "user", })
public Response createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true) List<User> body,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponses(value = {
throws NotFoundException { @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) })
return delegate.createUsersWithListInput(body,securityContext); public Response createUsersWithListInput(@ApiParam(value = "List of user object" ,required=true) List<User> body
} ,@Context SecurityContext securityContext)
@DELETE throws NotFoundException {
@Path("/{username}") return delegate.createUsersWithListInput(body,securityContext);
}
@Produces({ "application/xml", "application/json" }) @DELETE
@io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) @Path("/{username}")
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = void.class), @Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiOperation(value = "Delete user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", })
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) }) @io.swagger.annotations.ApiResponses(value = {
public Response deleteUser(@ApiParam(value = "The name that needs to be deleted",required=true) @PathParam("username") String username,@Context SecurityContext securityContext) @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = void.class),
throws NotFoundException {
return delegate.deleteUser(username,securityContext); @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
@GET ,@Context SecurityContext securityContext)
@Path("/{username}") throws NotFoundException {
return delegate.deleteUser(username,securityContext);
@Produces({ "application/xml", "application/json" }) }
@io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", }) @GET
@io.swagger.annotations.ApiResponses(value = { @Path("/{username}")
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = User.class),
@Produces({ "application/xml", "application/json" })
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class), @io.swagger.annotations.ApiOperation(value = "Get user by user name", notes = "", response = User.class, tags={ "user", })
@io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) }) @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", 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)
throws NotFoundException { @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username supplied", response = User.class),
return delegate.getUserByName(username,securityContext);
} @io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = User.class) })
@GET public Response getUserByName(@ApiParam(value = "The name that needs to be fetched. Use user1 for testing. ",required=true) @PathParam("username") String username
@Path("/login") ,@Context SecurityContext securityContext)
throws NotFoundException {
@Produces({ "application/xml", "application/json" }) return delegate.getUserByName(username,securityContext);
@io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", }) }
@io.swagger.annotations.ApiResponses(value = { @GET
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class), @Path("/login")
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) }) @Produces({ "application/xml", "application/json" })
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) @io.swagger.annotations.ApiOperation(value = "Logs user into the system", notes = "", response = String.class, tags={ "user", })
throws NotFoundException { @io.swagger.annotations.ApiResponses(value = {
return delegate.loginUser(username,password,securityContext); @io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = String.class),
}
@GET @io.swagger.annotations.ApiResponse(code = 400, message = "Invalid username/password supplied", response = String.class) })
@Path("/logout") 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
@Produces({ "application/xml", "application/json" }) ,@Context SecurityContext securityContext)
@io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = void.class, tags={ "user", }) throws NotFoundException {
@io.swagger.annotations.ApiResponses(value = { return delegate.loginUser(username,password,securityContext);
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) }) }
public Response logoutUser(@Context SecurityContext securityContext) @GET
throws NotFoundException { @Path("/logout")
return delegate.logoutUser(securityContext);
} @Produces({ "application/xml", "application/json" })
@PUT @io.swagger.annotations.ApiOperation(value = "Logs out current logged in user session", notes = "", response = void.class, tags={ "user", })
@Path("/{username}") @io.swagger.annotations.ApiResponses(value = {
@io.swagger.annotations.ApiResponse(code = 200, message = "successful operation", response = void.class) })
@Produces({ "application/xml", "application/json" }) public Response logoutUser(@Context SecurityContext securityContext)
@io.swagger.annotations.ApiOperation(value = "Updated user", notes = "This can only be done by the logged in user.", response = void.class, tags={ "user", }) throws NotFoundException {
@io.swagger.annotations.ApiResponses(value = { return delegate.logoutUser(securityContext);
@io.swagger.annotations.ApiResponse(code = 400, message = "Invalid user supplied", response = void.class), }
@PUT
@io.swagger.annotations.ApiResponse(code = 404, message = "User not found", response = void.class) }) @Path("/{username}")
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 { @Produces({ "application/xml", "application/json" })
return delegate.updateUser(username,body,securityContext); @io.swagger.annotations.ApiOperation(value = "Updated 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.ApiResponse(code = 400, message = "Invalid user supplied", 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)
throws NotFoundException {
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();
} }