JAVA-31001: Upgrade spring-boot-springdoc to boot 3 (#16139)

* JAVA-31001: Upgrade spring-boot-springdoc

* JAVA-31001: Upgrade spring-boot-springdoc

* JAVA-31001: Upgrade spring-boot-springdoc.

* Uncomment in Parent module POM.

* JAVA-31001: Upgrade spring-boot-springdoc parent.
This commit is contained in:
Amit Pandey 2024-03-17 19:36:36 +05:30 committed by GitHub
parent d58345c913
commit ef96037176
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
16 changed files with 40 additions and 32 deletions

View File

@ -72,7 +72,7 @@
<module>spring-boot-security-2</module>
<module>spring-boot-ssl-bundles</module>
<module>spring-boot-telegram</module>
<!-- <module>spring-boot-springdoc</module>--> <!-- failing after upgrading to spring boot 3.2.x -->
<module>spring-boot-springdoc</module>
<!-- <module>spring-boot-swagger</module>--> <!-- failing after upgrading to spring boot 3.2.x -->
<!-- <module>spring-boot-swagger-2</module>--> <!-- failing after upgrading to spring boot 3. Swagger codegen yet not compatible?!-->
<module>spring-boot-swagger-jwt</module>

View File

@ -119,10 +119,11 @@
</build>
<properties>
<springdoc.version>1.7.0</springdoc.version>
<asciidoctor-plugin.version>1.5.6</asciidoctor-plugin.version>
<springdoc.version>1.8.0</springdoc.version>
<asciidoctor-plugin.version>2.2.6</asciidoctor-plugin.version>
<snippetsDirectory>${project.build.directory}/generated-snippets</snippetsDirectory>
<springdoc-openapi-maven-plugin.version>1.4</springdoc-openapi-maven-plugin.version>
<spring-boot.repackage.skip>true</spring-boot.repackage.skip>
</properties>
</project>

View File

@ -19,7 +19,7 @@ import io.swagger.v3.oas.annotations.security.SecurityScheme;
public class DefaultGlobalSecuritySchemeApplication {
@Bean
public SecurityFilterChain filterChain(HttpSecurity http) throws Exception {
return http.authorizeHttpRequests(authorizeRequests -> authorizeRequests.antMatchers("/api/auth/**", "/swagger-ui-custom.html", "/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**", "/webjars/**", "/swagger-ui/index.html", "/api-docs/**")
return http.authorizeHttpRequests(authorizeRequests -> authorizeRequests.requestMatchers("/api/auth/**", "/swagger-ui-custom.html", "/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**", "/webjars/**", "/swagger-ui/index.html", "/api-docs/**")
.permitAll()
.anyRequest()
.authenticated())

View File

@ -3,7 +3,7 @@ package com.baeldung.defaultglobalsecurityscheme.controller;
import java.time.OffsetDateTime;
import java.time.ZoneOffset;
import javax.validation.Valid;
import jakarta.validation.Valid;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.RequestBody;

View File

@ -1,5 +1,6 @@
package com.baeldung.defaultglobalsecurityscheme.dto;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import java.util.Objects;
import com.fasterxml.jackson.annotation.JsonProperty;
@ -30,7 +31,7 @@ public class LoginDto {
* @return user
*/
@Schema(name = "user", required = true)
@Schema(name = "user", requiredMode = RequiredMode.REQUIRED)
public String getUser() {
return user;
}

View File

@ -1,9 +1,10 @@
package com.baeldung.defaultglobalsecurityscheme.dto;
import io.swagger.v3.oas.annotations.media.Schema.RequiredMode;
import java.time.OffsetDateTime;
import java.util.Objects;
import javax.validation.Valid;
import jakarta.validation.Valid;
import org.springframework.format.annotation.DateTimeFormat;
@ -33,7 +34,7 @@ public class PingResponseDto {
* @return pong
*/
@Valid
@Schema(name = "pong", required = false)
@Schema(name = "pong", requiredMode = RequiredMode.REQUIRED)
public OffsetDateTime getPong() {
return pong;
}

View File

@ -9,6 +9,7 @@ import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import org.springframework.security.config.annotation.web.builders.HttpSecurity;
import org.springframework.security.config.annotation.web.configuration.EnableWebSecurity;
import org.springframework.security.config.annotation.web.configurers.AbstractHttpConfigurer;
import org.springframework.security.config.annotation.web.configurers.oauth2.server.resource.OAuth2ResourceServerConfigurer;
import org.springframework.security.config.http.SessionCreationPolicy;
import org.springframework.security.core.userdetails.UserDetailsService;
@ -53,15 +54,15 @@ public class SecurityConfiguration {
return http
.authorizeHttpRequests(authorizeRequests -> authorizeRequests
.antMatchers("/api/auth/**", "/swagger-ui-custom.html" ,"/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**", "/webjars/**",
.requestMatchers("/api/auth/**", "/swagger-ui-custom.html" ,"/swagger-ui.html", "/swagger-ui/**", "/v3/api-docs/**", "/webjars/**",
"/swagger-ui/index.html","/api-docs/**")
.permitAll()
.anyRequest()
.authenticated())
.cors().disable()
.csrf().disable()
.formLogin().disable()
.httpBasic().disable()
.cors(AbstractHttpConfigurer::disable)
.csrf(AbstractHttpConfigurer::disable)
.formLogin(AbstractHttpConfigurer::disable)
.httpBasic(AbstractHttpConfigurer::disable)
.sessionManagement().sessionCreationPolicy(SessionCreationPolicy.STATELESS)
.and()
.oauth2ResourceServer(OAuth2ResourceServerConfigurer::jwt)

View File

@ -1,10 +1,10 @@
package com.baeldung.restdocopenapi;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import jakarta.persistence.Column;
import jakarta.persistence.Entity;
import jakarta.persistence.GeneratedValue;
import jakarta.persistence.GenerationType;
import jakarta.persistence.Id;
@Entity
public class Foo {

View File

@ -5,7 +5,7 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import java.util.List;
import java.util.Optional;
import javax.validation.Valid;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;

View File

@ -1,9 +1,10 @@
package com.baeldung.restdocopenapi;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;
@Repository
public interface FooRepository extends PagingAndSortingRepository<Foo, Long>{
public interface FooRepository extends JpaRepository<Foo, Long> {
}

View File

@ -5,7 +5,7 @@ import static org.springframework.hateoas.server.mvc.WebMvcLinkBuilder.linkTo;
import java.util.List;
import java.util.Optional;
import javax.validation.Valid;
import jakarta.validation.Valid;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.HttpHeaders;

View File

@ -2,8 +2,8 @@ package com.baeldung.springdoc.controller;
import java.util.Collection;
import javax.validation.Valid;
import javax.validation.constraints.NotNull;
import jakarta.validation.Valid;
import jakarta.validation.constraints.NotNull;
import com.baeldung.springdoc.exception.BookNotFoundException;
import com.baeldung.springdoc.model.Book;

View File

@ -1,10 +1,9 @@
package com.baeldung.springdoc.kotlin
import javax.persistence.Entity
import javax.persistence.GeneratedValue
import javax.persistence.Id
import javax.validation.constraints.NotBlank
import javax.validation.constraints.Size
import jakarta.persistence.Entity
import jakarta.persistence.Id
import jakarta.validation.constraints.NotBlank
import jakarta.validation.constraints.Size
@Entity
data class Foo(

View File

@ -6,6 +6,7 @@ import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.responses.ApiResponses
import org.hibernate.internal.util.collections.CollectionHelper
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController
@ -13,7 +14,7 @@ import org.springframework.web.bind.annotation.RestController
@RestController
@RequestMapping("/")
class FooController() {
val fooList: List<Foo> = listOf(Foo(1, "one"), Foo(2, "two"))
val fooList: List<Foo> = CollectionHelper.listOf(Foo(1, "one"), Foo(2, "two"))
@Operation(summary = "Get all foos")
@ApiResponses(value = [

View File

@ -1,7 +1,7 @@
package com.baeldung.springdoc.model;
import javax.validation.constraints.NotBlank;
import javax.validation.constraints.Size;
import jakarta.validation.constraints.NotBlank;
import jakarta.validation.constraints.Size;
public class Book {

View File

@ -1,11 +1,13 @@
package com.baeldung.jwt;
import org.junit.Ignore;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.DisplayName;
import org.junit.jupiter.api.Test;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.test.context.SpringBootTest;
import org.springframework.boot.test.web.client.TestRestTemplate;
import org.springframework.boot.web.server.LocalServerPort;
import org.springframework.boot.test.web.server.LocalServerPort;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
@ -15,6 +17,7 @@ import static org.junit.jupiter.api.Assertions.assertTrue;
@SpringBootTest(webEnvironment = SpringBootTest.WebEnvironment.RANDOM_PORT)
@DisplayName("OpenAPI JWT Live Tests")
@Disabled
class OpenApiJwtIntegrationTest
{
@LocalServerPort