사용자 도구

사이트 도구


programming:documentation:swagger

차이

문서의 선택한 두 판 사이의 차이를 보여줍니다.

차이 보기로 링크

양쪽 이전 판 이전 판
다음 판
이전 판
다음 판 양쪽 다음 판
programming:documentation:swagger [2015/02/04 16:43]
kwon37xi
programming:documentation:swagger [2018/07/12 08:38]
kwon37xi
줄 2: 줄 2:
   * http://swagger.io/   * http://swagger.io/
   * [[https://github.com/swagger-api/swagger-core/wiki/Annotations|Swagger Annotations]]   * [[https://github.com/swagger-api/swagger-core/wiki/Annotations|Swagger Annotations]]
 +  * [[https://dzone.com/articles/why-is-swagger-json-better-than-swagger-java-clien|Why Is Swagger JSON Better Than Swagger Java Client? - DZone Java]]
  
 ===== Spring MVC and swagger ===== ===== Spring MVC and swagger =====
줄 13: 줄 14:
 @Override @Override
 protected void addResourceHandlers(ResourceHandlerRegistry registry) { protected void addResourceHandlers(ResourceHandlerRegistry registry) {
-    registry.addResourceHandler("css/**", "js/**", "lib/**", "images/**", "swagger-ui.js"+  registry.addResourceHandler("css/**", "js/**", "lib/**", "images/**", "swagger-ui.js"
-        .addResourceLocations(WEB_JAR_RESOURCE_LOCATION, WEB_JAR_RESOURCE_LOCATION + "css/", WEB_JAR_RESOURCE_LOCATION + "js/", +    .addResourceLocations(WEB_JAR_RESOURCE_LOCATION, 
-                WEB_JAR_RESOURCE_LOCATION + "lib/", WEB_JAR_RESOURCE_LOCATION + "images/").setCachePeriod(0); +        WEB_JAR_RESOURCE_LOCATION + "css/", 
-    super.addResourceHandlers(registry);+        WEB_JAR_RESOURCE_LOCATION + "js/", 
 +        WEB_JAR_RESOURCE_LOCATION + "lib/", 
 +        WEB_JAR_RESOURCE_LOCATION + "images/") 
 +    .setCachePeriod(0); 
 +  super.addResourceHandlers(registry);
 } }
  
줄 22: 줄 27:
 @Controller @Controller
 public class SwaggerController { public class SwaggerController {
-    @Autowired +  @Autowired 
-        private ResourceLoader resourceLoader;+    private ResourceLoader resourceLoader;
  
-    @RequestMapping("/swagger"+  @RequestMapping("/swagger"
-        public void swagger(HttpServletResponse response) throws IOException { +    public void swagger(HttpServletResponse response) throws IOException { 
-            final Resource swaggerHtmlResource = resourceLoader.getResource("classpath:/META-INF/resources/sdoc.jsp");+      final Resource swaggerHtmlResource = 
 +        resourceLoader.getResource("classpath:/META-INF/resources/sdoc.jsp");
  
-            final String swaggerHtmlContents = CoupangIOUtils.toString(swaggerHtmlResource.getInputStream(), "UTF-8"); +      final String swaggerHtmlContents = 
-            final String refinedHtml = swaggerHtmlContents +        CoupangIOUtils.toString(swaggerHtmlResource.getInputStream(), "UTF-8"); 
-                .replaceAll("http://swagger.wordnik.com", "/api/swagger");+      final String refinedHtml = swaggerHtmlContents 
 +        .replaceAll("http://swagger.wordnik.com", "/api/swagger");
  
-            response.setContentType("text/html; charset=UTF-8"); +      response.setContentType("text/html; charset=UTF-8"); 
-            final PrintWriter writer = response.getWriter(); +      final PrintWriter writer = response.getWriter(); 
-            writer.write(refinedHtml); +      writer.write(refinedHtml); 
-            writer.close(); +      writer.close(); 
-        }+    }
 } }
 </code> </code>
programming/documentation/swagger.txt · 마지막으로 수정됨: 2023/08/17 15:39 저자 kwon37xi