feat: swagger2 set

main
minuk926 2 years ago
parent 617c152901
commit 705663da49

@ -208,6 +208,21 @@
</exclusions>
</dependency>
<!-- swagger2 -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version>
</dependency>
<!-- swagger2 -->
<dependency>
<groupId>org.thymeleaf</groupId>
<artifactId>thymeleaf</artifactId>

@ -0,0 +1,85 @@
package kr.xit.framework.core.config;
import java.util.HashSet;
import java.util.Set;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration
@EnableSwagger2
@EnableWebMvc
public class Swagger2Config {
// @Bean
// public Docket api() {
// return new Docket(DocumentationType.SWAGGER_2)
// .apiInfo(apiInfo())
// .select()
// //.apis(RequestHandlerSelectors.any())
// .apis(RequestHandlerSelectors.basePackage("kr.xit.fims"))
// // .paths(PathSelectors.regex("/"))
// //.paths(PathSelectors.any())
// .paths(PathSelectors.ant("/**"))
// .build();
// }
@Bean
public Docket newsApiAll() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("01. FIMS Biz API REST Service")
.consumes(getConsumeContentTypes())
.produces(getProduceContentTypes())
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("kr.xit.fims"))
.paths(PathSelectors.ant("/**"))
.build();
}
@Bean
public Docket newsApiAccelerator() {
return new Docket(DocumentationType.SWAGGER_2)
.groupName("02. Framework Biz API REST Service")
.consumes(getConsumeContentTypes())
.produces(getProduceContentTypes())
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("kr.xit.framework"))
.paths(PathSelectors.ant("/**"))
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("통합플랫폼 Rest API Documentation")
.description("통합플랫폼 Rest api 서비스")
.termsOfServiceUrl("https://www.egovframe.go.kr/wiki/doku.php?id=egovframework:hyb:gate_page")
.license("Apache License Version 2.0")
.licenseUrl("https://www.egovframe.go.kr")
.version("0.1")
.build();
}
private Set<String> getConsumeContentTypes() {
Set<String> consumes = new HashSet<>();
consumes.add("application/json;charset=UTF-8");
consumes.add("application/x-www-form-urlencoded");
return consumes;
}
private Set<String> getProduceContentTypes() {
Set<String> produces = new HashSet<>();
produces.add("application/json;charset=UTF-8");
return produces;
}
}

@ -29,6 +29,7 @@
<import resource="classpath:/spring/mvc/mvc-interceptor.xml" />
<import resource="classpath:/spring/mvc/mvc-resolver.xml" />
<import resource="classpath:/spring/mvc/mvc-converter.xml" />
<import resource="classpath:/spring/mvc/mvc-swagger2.xml" />
</beans>

@ -0,0 +1,11 @@
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd">
<mvc:resources location="classpath:/META-INF/resources/" mapping="swagger-ui.html"/>
<mvc:resources location="classpath:/META-INF/resources/webjars/" mapping="/webjars/**"/>
<mvc:resources location="/resources/" mapping="/resources/**"/>
</beans>

@ -21,6 +21,19 @@
<security:http pattern="/framework/biz/mng/usr/addUserPopup.do" security="none"/>
<security:http pattern="\A/WEB-INF/jsp/.*\Z" request-matcher="regex" security="none"/>
<!-- swagger2 set -->
<security:http pattern="/swagger-ui.html/**" security="none"/>
<security:http pattern="/swagger/**" security="none"/>
<security:http pattern="/swagger-resources/**" security="none"/>
<security:http pattern="/v2/api-docs" security="none"/>
<security:http pattern="/v3/api-docs" security="none"/>
<security:http pattern="/webjars/**" security="none"/>
<!-- swagger2 set -->
<!-- <security:http pattern="/webjars/springfox-swagger-ui/*.{js,css}" security="none"/>-->
<!-- 전자정부 프레임워크 사용 시 -->
<!-- <egov-security:config id="securityConfig" -->
<!-- loginUrl="/uat/uia/actionSecurityLogin.do" -->

@ -121,6 +121,13 @@
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
<url-pattern>*.ajax</url-pattern>
<!-- swagger2 set-->
<url-pattern>/swagger-ui.html</url-pattern>
<url-pattern>/webjars/**</url-pattern>
<url-pattern>/</url-pattern>
<!-- swagger2 set-->
</servlet-mapping>
<!-- Ubi Report Servlet -->

Loading…
Cancel
Save