Revision 07d9161c
Added by Andreas Kohlbecker about 8 years ago
cdmlib-remote-webapp/src/main/java/eu/etaxonomy/cdm/remote/staticSwagger/StaticSwaggerApiDoc.java | ||
---|---|---|
39 | 39 |
*/ |
40 | 40 |
|
41 | 41 |
@Controller |
42 |
@RequestMapping(value = {"/v2/api-docs"}) |
|
43 | 42 |
public class StaticSwaggerApiDoc { |
44 | 43 |
|
45 |
@RequestMapping(method = RequestMethod.GET) |
|
46 |
public void group( |
|
44 |
public static final String SWAGGER_STATIC = "swagger-static"; |
|
45 |
|
|
46 |
|
|
47 |
@RequestMapping(value = "configuration/ui", method = RequestMethod.GET) |
|
48 |
public void configurationUi( |
|
49 |
HttpServletResponse response) throws IOException { |
|
50 |
|
|
51 |
response.addHeader("Content-Type", "application/json;charset=utf-8"); |
|
52 |
response.getOutputStream().write("{\"validatorUrl\":null}".getBytes()); |
|
53 |
} |
|
54 |
|
|
55 |
@RequestMapping(value = "swagger-resources", method = RequestMethod.GET) |
|
56 |
public void swaggerResources( |
|
57 |
HttpServletRequest request, |
|
58 |
HttpServletResponse response) throws IOException { |
|
59 |
|
|
60 |
|
|
61 |
InputStream staticDocStream = getClass().getClassLoader().getResourceAsStream(SWAGGER_STATIC + "/swagger-resources"); |
|
62 |
if(staticDocStream == null) { |
|
63 |
HttpStatusMessage.create("Static swagger-resources not found.", 500).send(response); |
|
64 |
} else { |
|
65 |
response.addHeader("Content-Type", "application/json;charset=utf-8"); |
|
66 |
IOUtils.copy(staticDocStream, response.getOutputStream()); |
|
67 |
staticDocStream.close(); |
|
68 |
} |
|
69 |
} |
|
70 |
|
|
71 |
@RequestMapping(value = "/v2/api-docs", method = RequestMethod.GET) |
|
72 |
public void apiDocs( |
|
47 | 73 |
@RequestParam(value = "group", required = true) String group, |
48 | 74 |
HttpServletRequest request, |
49 | 75 |
HttpServletResponse response) throws IOException { |
... | ... | |
52 | 78 |
if(groupConfig == null) { |
53 | 79 |
HttpStatusMessage.create("Unknown swagger group name.", 400).send(response); |
54 | 80 |
} |
55 |
InputStream staticDocStream = getClass().getClassLoader().getResourceAsStream("api-docs-static/" + groupConfig.name());
|
|
81 |
InputStream staticDocStream = getClass().getClassLoader().getResourceAsStream(SWAGGER_STATIC + "/api-docs/" + groupConfig.name());
|
|
56 | 82 |
if(staticDocStream == null) { |
57 | 83 |
HttpStatusMessage.create("Static swagger api doc file for group '" + group + "' not found.", 500).send(response); |
58 | 84 |
} else { |
Also available in: Unified diff
#5657 incomplete static swagger documentation fixed