문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 | ||
programming:documentation:swagger [2015/02/04 16:45] kwon37xi [Spring MVC and swagger] |
programming:documentation:swagger [2024/07/31 14:18] (현재) kwon37xi |
||
---|---|---|---|
줄 1: | 줄 1: | ||
====== Swagger ====== | ====== Swagger ====== | ||
* http:// | * http:// | ||
+ | * [[programming: | ||
+ | * -> [[programming: | ||
+ | * [[springframework: | ||
* [[https:// | * [[https:// | ||
+ | * [[https:// | ||
- | ===== Spring MVC and swagger | + | ===== ReDoc ===== |
- | * [[https:// | + | * [[https:// |
- | * [[https://github.com/adrianbk/swagger-springmvc-demo/tree/master/swagger-ui|Swagger-UI]] | + | * [[https://webhookrelay.com/blog/2018/11/05/openapi-redoc-tutorial/ |
- | * Spring MVC Swagger 튜토리얼 시리즈 | + | * 페이지 내 검색과 더 유려한 UI를 제공해줌. |
- | * [[http://www.javacodegeeks.com/2014/10/spring-rest-api-with-swagger-creating-documentation.html|Spring Rest API with Swagger – Creating documentation Swagger 문서 생성]] | + | |
- | * [[http://www.javacodegeeks.com/2014/11/spring-rest-api-with-swagger-exposing-documentation.html|Spring Rest API with Swagger – Exposing documentation]] Spring REST API를 웹 서비스로 볼 수 있게 해줌 | + | ===== RapiDoc ===== |
- | * Spring MVC API 적용 Servlet의 "/"가 아닌 "/api/*" 형태로 매핑되면 | + | * https:// |
- | // /css/*, /js/* 등에 대한 핸들러 추가. | + | |
- | @Override | + | |
- | protected void addResourceHandlers(ResourceHandlerRegistry registry) { | + | ===== Swagger2MarkUp ===== |
- | | + | |
- | .addResourceLocations(WEB_JAR_RESOURCE_LOCATION, | + | * [[https:// |
- | | + | * [[https://github.com/Swagger2Markup/spring-swagger2markup-demo|Swagger2Markup/ |
- | | + | * [[https://dzone.com/articles/ |
- | | + | <code java> |
- | WEB_JAR_RESOURCE_LOCATION + " | + | // Spring |
- | .setCachePeriod(0); | + | |
- | | + | @WebAppConfiguration |
- | } | + | @RunWith(SpringJUnit4ClassRunner.class) |
+ | @AutoConfigureRestDocs(outputDir = "build/asciidoc/snippets") | ||
+ | @SpringBootTest(classes = {Application.class, SwaggerConfig.class}) | ||
+ | @AutoConfigureMockMvc | ||
+ | public class Swagger2MarkupTest { | ||
+ | |||
+ | | ||
+ | |||
+ | |||
+ | @Autowired | ||
+ | private MockMvc mockMvc; | ||
- | @ApiIgnore | + | ... |
- | @Controller | + | |
- | public class SwaggerController { | + | |
- | @Autowired | + | |
- | private ResourceLoader resourceLoader; | + | |
- | | + | |
- | public void swagger(HttpServletResponse response) throws | + | public void createSpringfoxSwaggerJson() throws |
- | final Resource swaggerHtmlResource | + | // |
- | resourceLoader.getResource(" | + | |
- | final String | + | |
- | CoupangIOUtils.toString(swaggerHtmlResource.getInputStream(), | + | |
- | final String refinedHtml = swaggerHtmlContents | + | .accept(MediaType.APPLICATION_JSON)) |
- | .replaceAll("http:// | + | .andExpect(status().isOk()) |
+ | .andReturn(); | ||
- | | + | MockHttpServletResponse |
- | final PrintWriter writer | + | |
- | | + | Files.createDirectories(Paths.get(outputDir)); |
- | writer.close(); | + | try (BufferedWriter |
+ | writer.write(swaggerJson); | ||
+ | } | ||
} | } | ||
+ | ... | ||
} | } | ||
</ | </ | ||
+ | ===== 기타 ===== | ||
+ | * https:// | ||
+ | * [[https:// |