-
Spring Boot : Spring DocSpring Boot 🍃 2023. 12. 9. 00:01
Spring Boot v2.*
gradle
implementation "org.springdoc:springdoc-openapi-ui:1.7.0" // spring-boot-starter-data-rest 사용시 추가 implementation "org.springdoc:springdoc-openapi-data-rest:1.7.0"
maven
<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-ui</artifactId> <version>1.7.0</version> </dependency> <!-- spring-boot-starter-data-rest 사용시 추가 --> <dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-data-rest</artifactId> <version>1.7.0</version> </dependency>
시큐리티 인증 하지 않을 리소스 등록
httpSecurity .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() .mvcMatchers( "/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html" ).permitAll()
Spring Boot v3.*
gradle
implementation "org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0"
maven
<dependency> <groupId>org.springdoc</groupId> <artifactId>springdoc-openapi-starter-webmvc-ui</artifactId> <version>2.1.0</version> </dependency>
시큐리티 인증 하지 않을 리소스 등록
httpSecurity .authorizeHttpRequests( auth -> auth .requestMatchers(PathRequest.toStaticResources().atCommonLocations()).permitAll() .requestMatchers( "/v3/api-docs/**", "/swagger-ui/**", "/swagger-ui.html" ).permitAll() )
실행 경로
http://localhost:8080/swagger-ui/index.html http://localhost:8080/v3/api-docs
springDoc custom
'Spring Boot 🍃' 카테고리의 다른 글
csrf (0) 2023.12.09 Fixture (0) 2023.12.09 Spring Boot: OAuth2 kakao 로그인 연동 (0) 2023.12.08 Spring Data JPA N+1 문제에 대한 링크 (0) 2023.12.08 Spring boot : JPA OSIV Open Session In View (0) 2023.12.08