feat: swagger2 set

main
minuk926 2 years ago
parent 705663da49
commit 5b3068238f

@ -215,12 +215,16 @@
<artifactId>springfox-swagger2</artifactId> <artifactId>springfox-swagger2</artifactId>
<version>2.9.2</version> <version>2.9.2</version>
</dependency> </dependency>
<dependency> <dependency>
<groupId>io.springfox</groupId> <groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId> <artifactId>springfox-swagger-ui</artifactId>
<version>2.9.2</version> <version>2.9.2</version>
</dependency> </dependency>
<dependency>
<groupId>io.swagger</groupId>
<artifactId>swagger-annotations</artifactId>
<version>1.6.10</version>
</dependency>
<!-- swagger2 --> <!-- swagger2 -->
<dependency> <dependency>

@ -1,5 +1,9 @@
package kr.xit.framework.biz.cache.web; package kr.xit.framework.biz.cache.web;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import kr.xit.framework.biz.mng.bbs.dto.XitBasicBbsMngSearchVO; import kr.xit.framework.biz.mng.bbs.dto.XitBasicBbsMngSearchVO;
import kr.xit.framework.support.util.ConvertUtils; import kr.xit.framework.support.util.ConvertUtils;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
@ -16,18 +20,22 @@ import java.util.Map;
* , * ,
* *
*/ */
@Api(value="Cache Controller", tags = "CacheController")
@Controller @Controller
@RequestMapping(value="/framework/biz/cmm/cache") @RequestMapping(value="/framework/biz/cmm/cache")
public class public class CacheController {
CacheController {
/** /**
* *
* @param codeId String * @param codeId String
* @return ModelAndView * @return ModelAndView
*/ */
@ApiOperation(value = "공통 코드 목록 조회", notes = "공통 코드 목록 조회")
@ApiImplicitParam(name = "codeId", value = "공통코드 ID", required=true, paramType = "query", dataTypeClass = String.class, defaultValue = "FIM001")
@GetMapping(value="/getCodeList") @GetMapping(value="/getCodeList")
public ModelAndView getCodeList(final String codeId) { public ModelAndView getCodeList(
final String codeId) {
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);
mav.addObject("comboList", CacheServiceUtils.getCodes(codeId)); mav.addObject("comboList", CacheServiceUtils.getCodes(codeId));
return mav; return mav;
@ -38,15 +46,23 @@ CacheController {
* @param codeId String * @param codeId String
* @return ModelAndView * @return ModelAndView
*/ */
@ApiOperation(value = "공통 콤보 코드 목록 조회", notes = "공통 콤보 코드 목록 조회")
@ApiImplicitParam(name = "codeId", value = "공통코드 ID", required=true, paramType = "query", dataTypeClass = String.class, defaultValue = "FIM001")
@GetMapping(value="/getComboCodeList") @GetMapping(value="/getComboCodeList")
public ModelAndView getComboCodeList(final String codeId) { public ModelAndView getComboCodeList(
final String codeId) {
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);
mav.addObject("comboList", CacheServiceUtils.getComboCodes(codeId)); mav.addObject("comboList", CacheServiceUtils.getComboCodes(codeId));
return mav; return mav;
} }
@ApiOperation(value = "공통 콤보 코드(타입) 목록 조회", notes = "공통 콤보 코드(타입) 목록 조회")
@ApiImplicitParams ({
@ApiImplicitParam(name = "codeId", value = "공통코드 ID", paramType = "query", dataTypeClass = String.class, defaultValue = ""),
@ApiImplicitParam(name = "type", value = "타입", required = true, paramType = "query", dataTypeClass = String.class, defaultValue = "AUTHOR_GRP")
})
@GetMapping(value="/getComboCodeTypeList") @GetMapping(value="/getComboCodeTypeList")
public ModelAndView getComboCodeTypeList(final String codeId, final String type) { public ModelAndView getComboCodeTypeList(final String codeId, final String type) {
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);
mav.addObject("comboList", CacheServiceUtils.getComboCodes(codeId, type)); mav.addObject("comboList", CacheServiceUtils.getComboCodes(codeId, type));
return mav; return mav;

@ -1,5 +1,6 @@
package kr.xit.framework.biz.mng.code.dto; package kr.xit.framework.biz.mng.code.dto;
import io.swagger.annotations.ApiParam;
import lombok.AllArgsConstructor; import lombok.AllArgsConstructor;
import lombok.Builder; import lombok.Builder;
import lombok.EqualsAndHashCode; import lombok.EqualsAndHashCode;
@ -35,26 +36,31 @@ public class XitDetailCodeMngVO {
/* /*
* ID * ID
*/ */
@ApiParam(value = "코드 ID", required = true)
private String codeId; private String codeId;
/* /*
* ID * ID
*/ */
@ApiParam(value = "코드 ID 이름")
private String codeIdNm; private String codeIdNm;
/* /*
* *
*/ */
@ApiParam(value = "코드")
private String code; private String code;
/* /*
* *
*/ */
@ApiParam(value = "코드 이름")
private String codeNm; private String codeNm;
/* /*
* *
*/ */
@ApiParam(value = "코드 설명")
private String codeDc; private String codeDc;
private String etc1; private String etc1;

@ -2,12 +2,17 @@ package kr.xit.framework.biz.mng.code.web;
import java.util.Map; import java.util.Map;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiOperation;
import kr.xit.framework.support.util.Checks; import kr.xit.framework.support.util.Checks;
import org.springframework.stereotype.Controller; import org.springframework.stereotype.Controller;
import org.springframework.validation.BindingResult; import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.GetMapping; import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping; import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping; import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RequestParam; import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.servlet.ModelAndView; import org.springframework.web.servlet.ModelAndView;
@ -21,20 +26,25 @@ import kr.xit.framework.support.util.AjaxMessageMapRenderer;
import kr.xit.framework.support.util.ValidationError; import kr.xit.framework.support.util.ValidationError;
import kr.xit.framework.support.util.constants.MessageKey; import kr.xit.framework.support.util.constants.MessageKey;
import lombok.RequiredArgsConstructor; import lombok.RequiredArgsConstructor;
import springfox.documentation.annotations.ApiIgnore;
@Api(value="코드 상세 관리", tags = "CodeDtlMgtController")
@RequiredArgsConstructor @RequiredArgsConstructor
@Controller @Controller
@RequestMapping("/framework/biz/mng/code") @RequestMapping("/framework/biz/mng/code")
public class CodeDtlMgtController { public class CodeDtlMgtController {
private final ICodeDtlMgtService service; private final ICodeDtlMgtService service;
@ApiOperation(value = "코드 상세 관리 화면", hidden = true)
@RequestMapping(value = "/mngCodeDtlMgtForm") @RequestMapping(value = "/mngCodeDtlMgtForm")
public void mngCodeDtlMgtForm() { public void mngCodeDtlMgtForm() {
} }
@RequestMapping(value = "/mngCodeDtlMgtPopup") @ApiOperation(value = "코드 상세 관리 팝업 화면")
public ModelAndView mngCodeDtlMgtPopup(final XitDetailCodeMngVO vo) { @ApiImplicitParam(name = "codeId", value = "코드 ID", required = true, dataType = "string", paramType = "path", defaultValue = "FIM001")
@RequestMapping(value = "/mngCodeDtlMgtPopup", method= {RequestMethod.GET, RequestMethod.POST})
public ModelAndView mngCodeDtlMgtPopup(@ApiIgnore final XitDetailCodeMngVO vo) {
ModelAndView mav = new ModelAndView(); ModelAndView mav = new ModelAndView();
mav.addObject("cfnCodeList", CacheServiceUtils.getComboCodes(null, "CMM_CFN")); mav.addObject("cfnCodeList", CacheServiceUtils.getComboCodes(null, "CMM_CFN"));
@ -55,7 +65,7 @@ public class CodeDtlMgtController {
return ResultResponse.of(service.findCodeDtls(paraMap, MybatisUtils.getPagingInfo(paraMap))); return ResultResponse.of(service.findCodeDtls(paraMap, MybatisUtils.getPagingInfo(paraMap)));
} }
@PostMapping(value = "/addCodeDtl") @PostMapping(value = "/addCodeDtl") //, consumes = MediaType.APPLICATION_FORM_URLENCODED_VALUE)
public ModelAndView addCodeDtl(final XitDetailCodeMngVO vo, final BindingResult bindingResult){ public ModelAndView addCodeDtl(final XitDetailCodeMngVO vo, final BindingResult bindingResult){
ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW); ModelAndView mav = new ModelAndView(FrameworkConstants.JSON_VIEW);

@ -163,7 +163,7 @@ public class LogAopAdvice {
do { do {
pName = (String) e.nextElement(); pName = (String) e.nextElement();
pValue = request.getParameter(pName); pValue = request.getParameter(pName);
sb.append(pName + " : [" + pValue + "]\n"); sb.append(pName + ": " + pValue + "\n");
} while (e.hasMoreElements()); } while (e.hasMoreElements());
} else { } else {
sb.append(" is Empty \n"); sb.append(" is Empty \n");

@ -1,6 +1,9 @@
package kr.xit.framework.core.config; package kr.xit.framework.core.config;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import org.springframework.context.annotation.Bean; 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.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.builders.ResponseMessageBuilder;
import springfox.documentation.service.ApiInfo; 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.DocumentationType;
import springfox.documentation.spi.service.contexts.SecurityContext;
import springfox.documentation.spring.web.plugins.Docket; 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; import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration @Configuration
@EnableSwagger2 @EnableSwagger2
//@EnableSwagger2WebMvc
@EnableWebMvc @EnableWebMvc
public class Swagger2Config { 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 @Bean
public Docket newsApiAll() { public Docket newsApiAll() {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.groupName("01. FIMS Biz API REST Service")
.consumes(getConsumeContentTypes()) .consumes(getConsumeContentTypes())
.produces(getProduceContentTypes()) //.produces(getProduceContentTypes())
.apiInfo(apiInfo()) .groupName("01. FIMS Biz API REST Service")
.select() .select()
.apis(RequestHandlerSelectors.basePackage("kr.xit.fims")) .apis(RequestHandlerSelectors.basePackage("kr.xit.fims.biz"))
.paths(PathSelectors.ant("/**")) .paths(PathSelectors.ant("/fims/biz/**"))
.build(); .build()
.apiInfo(apiInfo())
//.globalResponseMessage(RequestMethod.GET, getResMessages())
//.securityContexts(Arrays.asList(securityContext()))
//.securitySchemes(Arrays.asList(apiKey()))
;
} }
@Bean @Bean
@ -50,14 +58,37 @@ public class Swagger2Config {
return new Docket(DocumentationType.SWAGGER_2) return new Docket(DocumentationType.SWAGGER_2)
.groupName("02. Framework Biz API REST Service") .groupName("02. Framework Biz API REST Service")
.consumes(getConsumeContentTypes()) .consumes(getConsumeContentTypes())
.produces(getProduceContentTypes()) //.produces(getProduceContentTypes())
.apiInfo(apiInfo())
.select() .select()
.apis(RequestHandlerSelectors.basePackage("kr.xit.framework")) .apis(RequestHandlerSelectors.basePackage("kr.xit.framework.biz"))
.paths(PathSelectors.ant("/**")) .paths(PathSelectors.ant("/framework/biz/**"))
.build(); .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() { private ApiInfo apiInfo() {
return new ApiInfoBuilder() return new ApiInfoBuilder()
@ -70,10 +101,36 @@ public class Swagger2Config {
.build(); .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() { private Set<String> getConsumeContentTypes() {
Set<String> consumes = new HashSet<>(); Set<String> consumes = new HashSet<>();
consumes.add("application/json;charset=UTF-8");
consumes.add("application/x-www-form-urlencoded"); consumes.add("application/x-www-form-urlencoded");
consumes.add("application/json;charset=UTF-8");
return consumes; return consumes;
} }
@ -82,4 +139,22 @@ public class Swagger2Config {
produces.add("application/json;charset=UTF-8"); produces.add("application/json;charset=UTF-8");
return produces; 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));
}
} }

@ -155,3 +155,4 @@ file.snd.path=/Users/minuk/data/fims/SND
# \uC678\uBD80\uC5F0\uACC4 URL # \uC678\uBD80\uC5F0\uACC4 URL
app.extnl.car.url=http://211.119.124.9:18090 app.extnl.car.url=http://211.119.124.9:18090
springdoc.version=v1

Loading…
Cancel
Save