diff --git a/spring-boot-modules/spring-boot-mvc-4/pom.xml b/spring-boot-modules/spring-boot-mvc-4/pom.xml
index b1c079b715..800ca8e31e 100644
--- a/spring-boot-modules/spring-boot-mvc-4/pom.xml
+++ b/spring-boot-modules/spring-boot-mvc-4/pom.xml
@@ -32,11 +32,11 @@
spring-boot-devtools
true
-
- io.springfox
- springfox-boot-starter
- ${spring.fox.version}
-
+
+ org.springdoc
+ springdoc-openapi-ui
+ ${springdoc.version}
+
com.fasterxml.jackson.core
jackson-databind
@@ -70,7 +70,7 @@
- 3.0.0
+ 1.7.0
com.baeldung.springboot.swagger.ArticleApplication
diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java
index 8be380baa0..2b8388f914 100644
--- a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java
+++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java
@@ -5,14 +5,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.context.annotation.Bean;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
-import springfox.documentation.builders.PathSelectors;
-import springfox.documentation.builders.RequestHandlerSelectors;
-import springfox.documentation.spi.DocumentationType;
-import springfox.documentation.spring.web.plugins.Docket;
-import springfox.documentation.swagger2.annotations.EnableSwagger2;
+import io.swagger.v3.oas.models.OpenAPI;
+import io.swagger.v3.oas.models.info.Info;
@SpringBootApplication
-@EnableSwagger2
@EnableWebMvc
public class ArticleApplication {
@@ -21,12 +17,10 @@ public class ArticleApplication {
}
@Bean
- public Docket api() {
- return new Docket(DocumentationType.SWAGGER_2)
- .select()
- .apis(RequestHandlerSelectors.any())
- .paths(PathSelectors.any())
- .build();
+ public OpenAPI openAPI() {
+ return new OpenAPI().info(new Info().title("SpringDoc example")
+ .description("SpringDoc application")
+ .version("v0.0.1"));
}
}
diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java
index c4336a7cfe..96812e367a 100644
--- a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java
+++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java
@@ -21,7 +21,7 @@ public class ArticlesController {
}
@PostMapping("")
- public void addArticle(@ModelAttribute Article article) {
+ public void addArticle(@RequestBody Article article) {
articleService.addArticle(article);
}
diff --git a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java
index f6318c04b3..8a54e54427 100644
--- a/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java
+++ b/spring-boot-modules/spring-boot-mvc-4/src/main/java/com/baeldung/springboot/swagger/model/Article.java
@@ -1,21 +1,16 @@
package com.baeldung.springboot.swagger.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
-import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
-
import com.fasterxml.jackson.annotation.JsonProperty;
-import com.fasterxml.jackson.annotation.JsonView;
-import io.swagger.annotations.ApiModelProperty;
-import io.swagger.annotations.ApiParam;
-
+import io.swagger.v3.oas.annotations.Hidden;
+import io.swagger.v3.oas.annotations.media.Schema;
+import io.swagger.v3.oas.annotations.media.Schema.AccessMode;
public class Article {
- //@JsonIgnore
- //@JsonProperty(access = JsonProperty.Access.READ_ONLY)
- //@ApiModelProperty(hidden = true)
- //@ApiParam(hidden = true)
- //@ApiModelProperty(readOnly = true)
- @ApiParam(hidden = true)
+ // @JsonIgnore
+ // @JsonProperty(access = JsonProperty.Access.READ_ONLY)
+ // @Schema(accessMode = AccessMode.READ_ONLY)
+ @Hidden
private int id;
private String title;
private int numOfWords;