|
|
|
@ -1,6 +1,9 @@
|
|
|
|
|
package kr.xit.framework.core.config;
|
|
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
|
import java.util.Arrays;
|
|
|
|
|
import java.util.HashSet;
|
|
|
|
|
import java.util.List;
|
|
|
|
|
import java.util.Set;
|
|
|
|
|
|
|
|
|
|
import org.springframework.context.annotation.Bean;
|
|
|
|
@ -10,39 +13,44 @@ 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.builders.ResponseMessageBuilder;
|
|
|
|
|
import springfox.documentation.service.ApiInfo;
|
|
|
|
|
import springfox.documentation.service.ApiKey;
|
|
|
|
|
import springfox.documentation.service.AuthorizationScope ;
|
|
|
|
|
import springfox.documentation.service.ResponseMessage;
|
|
|
|
|
import springfox.documentation.service.SecurityReference;
|
|
|
|
|
import springfox.documentation.spi.DocumentationType;
|
|
|
|
|
import springfox.documentation.spi.service.contexts.SecurityContext;
|
|
|
|
|
import springfox.documentation.spring.web.plugins.Docket;
|
|
|
|
|
import springfox.documentation.swagger.web.DocExpansion;
|
|
|
|
|
import springfox.documentation.swagger.web.ModelRendering;
|
|
|
|
|
import springfox.documentation.swagger.web.OperationsSorter;
|
|
|
|
|
import springfox.documentation.swagger.web.TagsSorter;
|
|
|
|
|
import springfox.documentation.swagger.web.UiConfiguration;
|
|
|
|
|
import springfox.documentation.swagger.web.UiConfigurationBuilder;
|
|
|
|
|
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
|
|
|
|
|
|
|
|
@Configuration
|
|
|
|
|
@EnableSwagger2
|
|
|
|
|
//@EnableSwagger2WebMvc
|
|
|
|
|
@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())
|
|
|
|
|
//.produces(getProduceContentTypes())
|
|
|
|
|
.groupName("01. FIMS Biz API REST Service")
|
|
|
|
|
.select()
|
|
|
|
|
.apis(RequestHandlerSelectors.basePackage("kr.xit.fims"))
|
|
|
|
|
.paths(PathSelectors.ant("/**"))
|
|
|
|
|
.build();
|
|
|
|
|
.apis(RequestHandlerSelectors.basePackage("kr.xit.fims.biz"))
|
|
|
|
|
.paths(PathSelectors.ant("/fims/biz/**"))
|
|
|
|
|
.build()
|
|
|
|
|
.apiInfo(apiInfo())
|
|
|
|
|
//.globalResponseMessage(RequestMethod.GET, getResMessages())
|
|
|
|
|
//.securityContexts(Arrays.asList(securityContext()))
|
|
|
|
|
//.securitySchemes(Arrays.asList(apiKey()))
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
@ -50,14 +58,37 @@ public class Swagger2Config {
|
|
|
|
|
return new Docket(DocumentationType.SWAGGER_2)
|
|
|
|
|
.groupName("02. Framework Biz API REST Service")
|
|
|
|
|
.consumes(getConsumeContentTypes())
|
|
|
|
|
.produces(getProduceContentTypes())
|
|
|
|
|
.apiInfo(apiInfo())
|
|
|
|
|
//.produces(getProduceContentTypes())
|
|
|
|
|
.select()
|
|
|
|
|
.apis(RequestHandlerSelectors.basePackage("kr.xit.framework"))
|
|
|
|
|
.paths(PathSelectors.ant("/**"))
|
|
|
|
|
.build();
|
|
|
|
|
.apis(RequestHandlerSelectors.basePackage("kr.xit.framework.biz"))
|
|
|
|
|
.paths(PathSelectors.ant("/framework/biz/**"))
|
|
|
|
|
.build()
|
|
|
|
|
.apiInfo(apiInfo())
|
|
|
|
|
//.globalResponseMessage(RequestMethod.GET, getResMessages())
|
|
|
|
|
//.securityContexts(Arrays.asList(securityContext()))
|
|
|
|
|
//.securitySchemes(Arrays.asList(apiKey()))
|
|
|
|
|
;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
@Bean
|
|
|
|
|
public UiConfiguration uiConfig() {
|
|
|
|
|
return UiConfigurationBuilder.builder()
|
|
|
|
|
.deepLinking(false)
|
|
|
|
|
.displayOperationId(false)
|
|
|
|
|
.defaultModelsExpandDepth(-1)
|
|
|
|
|
.defaultModelExpandDepth(1)
|
|
|
|
|
.defaultModelRendering(ModelRendering.EXAMPLE)
|
|
|
|
|
.displayRequestDuration(false)
|
|
|
|
|
.docExpansion(DocExpansion.NONE)
|
|
|
|
|
.filter(false)
|
|
|
|
|
.maxDisplayedTags(null)
|
|
|
|
|
.operationsSorter(OperationsSorter.METHOD)
|
|
|
|
|
.showExtensions(false)
|
|
|
|
|
.tagsSorter(TagsSorter.ALPHA)
|
|
|
|
|
.supportedSubmitMethods(UiConfiguration.Constants.DEFAULT_SUBMIT_METHODS)
|
|
|
|
|
.validatorUrl(null)
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private ApiInfo apiInfo() {
|
|
|
|
|
return new ApiInfoBuilder()
|
|
|
|
@ -70,10 +101,36 @@ public class Swagger2Config {
|
|
|
|
|
.build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<ResponseMessage> getResMessages() {
|
|
|
|
|
List<ResponseMessage> responseMessages = new ArrayList<>();
|
|
|
|
|
responseMessages.add(new ResponseMessageBuilder()
|
|
|
|
|
.code(200)
|
|
|
|
|
.message("OK")
|
|
|
|
|
.build());
|
|
|
|
|
responseMessages.add(new ResponseMessageBuilder()
|
|
|
|
|
.code(401)
|
|
|
|
|
.message("Unauthorized")
|
|
|
|
|
.build());
|
|
|
|
|
responseMessages.add(new ResponseMessageBuilder()
|
|
|
|
|
.code(403)
|
|
|
|
|
.message("Forbidden")
|
|
|
|
|
.build());
|
|
|
|
|
responseMessages.add(new ResponseMessageBuilder()
|
|
|
|
|
.code(404)
|
|
|
|
|
.message("Not Found")
|
|
|
|
|
.build());
|
|
|
|
|
responseMessages.add(new ResponseMessageBuilder()
|
|
|
|
|
.code(500)
|
|
|
|
|
.message("Internal Server Error")
|
|
|
|
|
.build());
|
|
|
|
|
|
|
|
|
|
return responseMessages;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private Set<String> getConsumeContentTypes() {
|
|
|
|
|
Set<String> consumes = new HashSet<>();
|
|
|
|
|
consumes.add("application/json;charset=UTF-8");
|
|
|
|
|
consumes.add("application/x-www-form-urlencoded");
|
|
|
|
|
consumes.add("application/json;charset=UTF-8");
|
|
|
|
|
return consumes;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -82,4 +139,22 @@ public class Swagger2Config {
|
|
|
|
|
produces.add("application/json;charset=UTF-8");
|
|
|
|
|
return produces;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//ApiKey 정의
|
|
|
|
|
private ApiKey apiKey() {
|
|
|
|
|
//return new ApiKey("JWT", "Authorization", "header");
|
|
|
|
|
return new ApiKey("Authorization", "Authorization", "header");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
//JWT SecurityContext 구성
|
|
|
|
|
private SecurityContext securityContext() {
|
|
|
|
|
return SecurityContext.builder().securityReferences(defaultAuth()).build();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private List<SecurityReference> defaultAuth() {
|
|
|
|
|
AuthorizationScope authorizationScope = new AuthorizationScope("global", "accessEveryThing");
|
|
|
|
|
AuthorizationScope[] authorizationScopes = new AuthorizationScope[1];
|
|
|
|
|
authorizationScopes[0] = authorizationScope;
|
|
|
|
|
return Arrays.asList(new SecurityReference("Authorization", authorizationScopes));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|