โ ์คํ๋ง ๋ถํธ swagger๋ฅผ ์ค์ ํด๋ณด์
gradle ๋ํ๋์ ์ฐธ๊ณ ์ ๋ค์ด๊ฐ์ ์ํ๋ ๋ฒ์ ์ผ๋ก ์ ํํด์ ๋ค์ด๊ฐ๋ค.
๊ฐ์ฅ ๋ง์ด ์ฌ์ฉํ๋ฏ ํ 2.9.2๋ฅผ ๊ณจ๋๋ค.
์ถ๊ฐ๋ก ์์ ์์กด์ฑ์ ๋ณต์ฌํด swagger2๋ ์ํฌํธ ํด์ค๋ค.
//https://mvnrepository.com/artifact/io.springfox/springfox-swagger-ui
implementation group: 'io.springfox', name: 'springfox-swagger-ui', version: '2.9.2'
implementation group: 'io.springfox', name: 'springfox-swagger2', version: '2.9.2'
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
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
public class SwaggerConfig {
@Bean
public Docket restAPI() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("com.hobbybee"))
.paths(PathSelectors.any())
.build();
}
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("hobbybee Spring Boot REST API")
.version("1.0.0")
.description("์ทจ๋ฏธ ์ํ ์ปค๋ฎค๋ํฐ hobbybee์ swagger api ์
๋๋ค.")
.build();
}
}
http://localhost:8090/swagger-ui.html
@RestController
@RequestMapping(value = "/member/v1")
@Api(tags = {"ํ์๊ฐ์
API"})
@RequiredArgsConstructor
public class JoinController {
@PostMapping(value = "/join")
@ApiOperation(value = "ํ์๊ฐ์
", response = Join.class)
public ResponseEntity<T> signUp() {
}
}