문서의 선택한 두 판 사이의 차이를 보여줍니다.
| 양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
|
programming:documentation:swagger [2020/05/24 19:52] kwon37xi |
programming:documentation:swagger [2024/07/31 14:18] (현재) kwon37xi |
||
|---|---|---|---|
| 줄 1: | 줄 1: | ||
| ====== Swagger ====== | ====== Swagger ====== | ||
| * http:// | * http:// | ||
| + | * [[programming: | ||
| * -> [[programming: | * -> [[programming: | ||
| * [[springframework: | * [[springframework: | ||
| 줄 9: | 줄 10: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * 페이지 내 검색과 더 유려한 UI를 제공해줌. | ||
| + | |||
| + | ===== RapiDoc ===== | ||
| + | * https:// | ||
| + | |||
| ===== Swagger2MarkUp ===== | ===== Swagger2MarkUp ===== | ||
| 줄 14: | 줄 20: | ||
| * [[https:// | * [[https:// | ||
| * [[https:// | * [[https:// | ||
| + | * [[https:// | ||
| + | <code java> | ||
| + | // Spring / Swagger 에서 swagger.json 을 파일로 뽑아내는 예제 | ||
| + | |||
| + | @WebAppConfiguration | ||
| + | @RunWith(SpringJUnit4ClassRunner.class) | ||
| + | @AutoConfigureRestDocs(outputDir = " | ||
| + | @SpringBootTest(classes = {Application.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("/ | ||
| + | |||
| + | String outputDir = System.getProperty(" | ||
| + | MvcResult mvcResult = this.mockMvc.perform(get("/ | ||
| + | .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, | ||
| + | writer.write(swaggerJson); | ||
| + | } | ||
| + | } | ||
| + | ... | ||
| + | } | ||
| + | </ | ||
| + | ===== 기타 ===== | ||
| + | * https:// | ||
| + | * [[https:// | ||