From ddf8c3c0f07c0ca2fa6444c4511b61fc9a5c496c Mon Sep 17 00:00:00 2001 From: Vitaly Takmazov Date: Wed, 12 Sep 2018 15:29:37 +0300 Subject: static swagger docs --- .../src/test/java/com/juick/server/tests/ServerTests.java | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'juick-server/src/test/java/com/juick/server/tests') diff --git a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java index 66845cfa..13cb8d41 100644 --- a/juick-server/src/test/java/com/juick/server/tests/ServerTests.java +++ b/juick-server/src/test/java/com/juick/server/tests/ServerTests.java @@ -1651,4 +1651,16 @@ public class ServerTests { String sql = String.format("SELECT * FROM table WHERE data='%s'", Utils.encodeSphinx("';-- DROP TABLE table")); assertThat(sql, is("SELECT * FROM table WHERE data='\\';-- DROP TABLE table\'")); } + @Test + public void swaggerOutput() throws Exception { + MvcResult result = mockMvc.perform(get("/v2/api-docs") + .accept(MediaType.APPLICATION_JSON_UTF8)) + .andExpect(status().isOk()) + .andReturn(); + String outputDir = System.getProperty("io.springfox.staticdocs.outputDir"); + Files.createDirectories(Paths.get(outputDir)); + BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, "swagger.json"), StandardCharsets.UTF_8); + writer.write(result.getResponse().getContentAsString()); + writer.flush(); + } } -- cgit v1.2.3