-
Notifications
You must be signed in to change notification settings - Fork 2.2k
/
ApiListingResource.java
36 lines (30 loc) · 1.13 KB
/
ApiListingResource.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
package io.swagger.jaxrs.listing;
import io.swagger.annotations.ApiOperation;
import org.apache.commons.lang3.StringUtils;
import javax.servlet.ServletConfig;
import javax.servlet.ServletContext;
import javax.ws.rs.GET;
import javax.ws.rs.Path;
import javax.ws.rs.PathParam;
import javax.ws.rs.Produces;
import javax.ws.rs.core.*;
@Path("/swagger.{type:json|yaml}")
public class ApiListingResource extends BaseApiListingResource {
@Context
ServletContext context;
@GET
@Produces({MediaType.APPLICATION_JSON, "application/yaml"})
@ApiOperation(value = "The swagger definition in either JSON or YAML", hidden = true)
public Response getListing(
@Context Application app,
@Context ServletConfig sc,
@Context HttpHeaders headers,
@Context UriInfo uriInfo,
@PathParam("type") String type) {
if (StringUtils.isNotBlank(type) && type.trim().equalsIgnoreCase("yaml")) {
return getListingYamlResponse(app, context, sc, headers, uriInfo);
} else {
return getListingJsonResponse(app, context, sc, headers, uriInfo);
}
}
}