문서의 선택한 두 판 사이의 차이를 보여줍니다.
양쪽 이전 판 이전 판 다음 판 | 이전 판 다음 판 양쪽 다음 판 | ||
springframework:springfox [2018/07/24 13:39] kwon37xi |
springframework:springfox [2019/06/04 17:48] kwon37xi |
||
---|---|---|---|
줄 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(); | ||
+ | } | ||
+ | } | ||
+ | </ | ||
+ | |||
+ | ===== 숫자값 parsing 에러 ===== | ||
+ | * 파라미터 타입이 primitive 숫자(int, long 등)인데, example을 지정하지 않으면 empty string이 example로 들어오게 되고, 그로인해 Swagger UI 출력시 숫자값 파싱 오류가 발생한다. 이때 example을 적합한 숫자로 넣어주면 된다. | ||
+ | * 원칙적으로 Boxed Type에 대해서는 발생하지 않을거 같고 일부 괜찮은데 일부는 또 파싱 오류가 발생하기도 한다.(example값에 empty string을 넣어서) | ||
+ | |||
+ | <code java> | ||
+ | @ApiParam(value = " | ||
+ | </ | ||
+ | |||
+ | ===== 참조 ===== | ||
+ | * [[http:// | ||
+ | * [[https:// | ||
+ | * [[https:// |