문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:springfox [2018/07/24 13:40] kwon37xi |
springframework:springfox [2018/07/24 13:46] kwon37xi [Spring MVC and swagger] |
||
---|---|---|---|
줄 6: | 줄 6: | ||
> The Springfox suite of java libraries are all about automating the generation of machine and human readable specifications for JSON APIs written using the spring family of projects. | > The Springfox suite of java libraries are all about automating the generation of machine and human readable specifications for JSON APIs written using the spring family of projects. | ||
+ | |||
+ | ===== Spring MVC and swagger ===== | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * Spring MVC Swagger 튜토리얼 시리즈 | ||
+ | * [[http:// | ||
+ | * [[http:// | ||
+ | * < | ||
+ | // /css/*, /js/* 등에 대한 핸들러 추가. | ||
+ | @Override | ||
+ | protected void addResourceHandlers(ResourceHandlerRegistry registry) { | ||
+ | registry.addResourceHandler(" | ||
+ | .addResourceLocations(WEB_JAR_RESOURCE_LOCATION, | ||
+ | WEB_JAR_RESOURCE_LOCATION + " | ||
+ | WEB_JAR_RESOURCE_LOCATION + " | ||
+ | WEB_JAR_RESOURCE_LOCATION + " | ||
+ | WEB_JAR_RESOURCE_LOCATION + " | ||
+ | .setCachePeriod(0); | ||
+ | super.addResourceHandlers(registry); | ||
+ | } | ||
+ | |||
+ | @ApiIgnore | ||
+ | @Controller | ||
+ | public class SwaggerController { | ||
+ | @Autowired | ||
+ | private ResourceLoader resourceLoader; | ||
+ | |||
+ | @RequestMapping("/ | ||
+ | public void swagger(HttpServletResponse response) throws IOException { | ||
+ | final Resource swaggerHtmlResource = | ||
+ | resourceLoader.getResource(" | ||
+ | |||
+ | final String swaggerHtmlContents = | ||
+ | CoupangIOUtils.toString(swaggerHtmlResource.getInputStream(), | ||
+ | final String refinedHtml = swaggerHtmlContents | ||
+ | .replaceAll(" | ||
+ | |||
+ | response.setContentType(" | ||
+ | final PrintWriter writer = response.getWriter(); | ||
+ | writer.write(refinedHtml); | ||
+ | writer.close(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
===== 참조 ===== | ===== 참조 ===== | ||
* [[http:// | * [[http:// |