package io.swagger.resources;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import io.swagger.annotations.ResponseHeader;
import io.swagger.models.NotFoundModel;
import io.swagger.models.Sample;
import javax.ws.rs.DefaultValue;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.QueryParam;
import javax.ws.rs.WebApplicationException;
import javax.ws.rs.core.Response;
@Api(value = "/basic", description = "Basic resource")
@Produces({"application/xml"})
@Path("/")
public class ResourceWithResponseHeaders {
@GET
@Path("/{id}")
@ApiOperation(value = "Get object by ID",
notes = "No details provided",
response = Sample.class,
position = 0,
responseHeaders = {
@ResponseHeader(name = "foo", description = "description", response = String.class)
})
@ApiResponses({
@ApiResponse(code = 400, message = "Invalid ID",
response = NotFoundModel.class,
responseHeaders =
{
@ResponseHeader(name = "X-Rack-Cache", description = "Explains whether or not a cache was used", response = Boolean.class),
@ResponseHeader(name = "X-After-Rack-Cache", description = "verify order", response = String.class)
}),
@ApiResponse(code = 404, message = "object not found")})
public Response getTest(
@ApiParam(value = "sample param data", required = true, allowableValues = "range[0,10]")
@DefaultValue("5")
@PathParam("id") String id,
@QueryParam("limit") Integer limit
) throws WebApplicationException {
Sample out = new Sample();
out.setName("foo");
out.setValue("bar");
return Response.ok().entity(out).build();
}
}