spring boot 3.0.6
springdoc-openapi v2.1.0
springfox는 최신화를 안하고 있기 때문에 spring boot 3.0.6에서 사용이 안됨
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'
@Configuration
public class SwaggerConfig {
@Bean
public GroupedOpenApi publicApi() { //경로 설정, 여러개 만들 수 있음
return GroupedOpenApi.builder()
.group("myApp")
.pathsToMatch("/**")
.build();
}
@Bean
public OpenAPI MyOpenApi() {
return new OpenAPI()
.info(new Info().title("SongGPT")
.description("미니프로젝트 API 명세서입니다.")
.version("v2.1.0")
.license(new License().name("Apache 2.0").url("http://springdoc.org")));
}
}
https://jeonyoungho.github.io/posts/Open-API-3.0-Swagger-v3-%EC%83%81%EC%84%B8%EC%84%A4%EC%A0%95/
public OpenAPI springShopOpenAPI() {
return new OpenAPI()
.info(new Info().title("SongGPT")
.description("미니프로젝트 API 명세서입니다.")
.version("v2.1.0")
.license(new License().name("Apache 2.0").url("http://springdoc.org")))
.components(new Components()
.addSecuritySchemes("Access_Token",new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT"))
.addSecuritySchemes("Refresh_Token",new SecurityScheme().type(SecurityScheme.Type.HTTP).scheme("bearer").bearerFormat("JWT")));
}
//swagger 부분 열어두기
.requestMatchers("/swagger*/**", "/v3/api-docs/**").permitAll()
@RequiredArgsConstructor
@RequestMapping("/member")
public class MemberController {
private final MemberService memberService;
@Operation(summary = "get member", description = "회원 정보 조회",
security = { @SecurityRequirement(name = "Access_Token"), @SecurityRequirement(name = "Refresh_Token")})
@GetMapping
public ResponseDto<MemberResponseDto> getMember(HttpServletRequest request) {
return memberService.getMember(request);
}
}