swagger 정보 커스터마이징

This commit is contained in:
haerong22
2020-11-28 16:51:55 +09:00
parent e064d5eda8
commit eafe96b914
2 changed files with 26 additions and 1 deletions

View File

@@ -2,16 +2,33 @@ package com.example.restfulwebservice.config;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import springfox.documentation.service.ApiInfo;
import springfox.documentation.service.Contact;
import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashSet;
import java.util.Set;
@Configuration
@EnableSwagger2
public class SwaggerConfig {
private static final Contact DEFAULT_CONTACT = new Contact("Kim",
"http://www.joneconsulting.co.kr", "email@naver.com");
private static final ApiInfo DEFAULT_API_INFO = new ApiInfo("Awesome Api Title",
"My User management REST API service", "1.0", "uri:tos",
DEFAULT_CONTACT, "Apache 2.0", "http://www.apache.org/licenses/LICENSE-2.0", new ArrayList<>());
private static final Set<String> DEFAULT_PRODUCES_AND_CONSUMES = new HashSet<>(
Arrays.asList("application/json", "application/xml"));
@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2);
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(DEFAULT_API_INFO)
.produces(DEFAULT_PRODUCES_AND_CONSUMES)
.consumes(DEFAULT_PRODUCES_AND_CONSUMES);
}
}

View File

@@ -3,6 +3,8 @@ package com.example.restfulwebservice.user;
import com.fasterxml.jackson.annotation.JsonFilter;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;
@@ -15,13 +17,19 @@ import java.util.Date;
@AllArgsConstructor
@NoArgsConstructor
//@JsonFilter("UserInfo")
@ApiModel(description = "사용자 상세정보를 위한 도메인 객체")
public class User {
private Integer id;
@Size(min = 2, message = "Name은 2글자 이상 입력해 주세요.")
@ApiModelProperty(notes = "사용자의 이름을 입력해 주세요")
private String name;
@Past
@ApiModelProperty(notes = "사용자의 등록일을 입력해 주세요")
private Date joinDate;
@ApiModelProperty(notes = "사용자의 패스워드을 입력해 주세요")
private String password;
@ApiModelProperty(notes = "사용자의 주민번호을 입력해 주세요")
private String ssn;
}