feat: swagger2 set
parent
617c152901
commit
705663da49
@ -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;
|
||||
}
|
||||
}
|
@ -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>
|
Loading…
Reference in New Issue