🔻Download, Tool
[Tool] Swagger(API 문서 자동화) 2.9.2 사용하기
_니지
2022. 12. 3. 17:36
❗build.gradle에 swagger 설정 추가
implementation 'io.springfox:springfox-swagger2:2.9.2'
implementation 'io.springfox:springfox-swagger-ui:2.9.2'
❗SwaggerConfig 작성
SwaggerConfig라는 설정클래스를 만들고 아래처럼 적어주면 된다
@Configuration
@EnableSwagger2
public class SwaggerConfig {
@Bean
public Docket apiV1() {
return new Docket(DocumentationType.SWAGGER_2)
.useDefaultResponseMessages(false)
.groupName("[그룹이름]")
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.ant("/[requestMapping한 주소]/**")).build();
}
}
❗서버 실행
서버를 실행하고 http://localhost:[포트번호]/swagger-ui.html에 접속하면
728x90
반응형