swagger.json
으로 생성하고, 이를 가지고 AsciiDoc을 생성한뒤 AsciiDoctor 를 통해서 다시 HTML/PDF 문서로 바꾼다.// Spring / Swagger 에서 swagger.json 을 파일로 뽑아내는 예제 @WebAppConfiguration @RunWith(SpringJUnit4ClassRunner.class) @AutoConfigureRestDocs(outputDir = "build/asciidoc/snippets") @SpringBootTest(classes = {Application.class, SwaggerConfig.class}) @AutoConfigureMockMvc public class Swagger2MarkupTest { private static final Logger LOG = LoggerFactory.getLogger(Swagger2MarkupTest.class); @Autowired private MockMvc mockMvc; ... @Test public void createSpringfoxSwaggerJson() throws Exception { //String designFirstSwaggerLocation = Swagger2MarkupTest.class.getResource("/swagger.yaml").getPath(); String outputDir = System.getProperty("io.springfox.staticdocs.outputDir"); MvcResult mvcResult = this.mockMvc.perform(get("/v2/api-docs") .accept(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andReturn(); MockHttpServletResponse response = mvcResult.getResponse(); String swaggerJson = response.getContentAsString(); Files.createDirectories(Paths.get(outputDir)); try (BufferedWriter writer = Files.newBufferedWriter(Paths.get(outputDir, "swagger.json"), StandardCharsets.UTF_8)){ writer.write(swaggerJson); } } ... }