JAVA-21456 Upgrade spring-boot-mvc-4 to use SpringDoc in place of SpringFox (#14139)
* JAVA-21456 Upgrade spring-boot-mvc-4 to use SpringDoc in place of SpringFox * JAVA-21456 Replace no longer needed ModelAttribute with RequestBody * JAVA-21456 Review comments changes * JAVA-21456 Formatting changes pom * JAVA-21456 Correct formatting pom
This commit is contained in:
parent
f0124dcca0
commit
3f9bddc9ab
|
@ -32,11 +32,11 @@
|
|||
<artifactId>spring-boot-devtools</artifactId>
|
||||
<optional>true</optional>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>io.springfox</groupId>
|
||||
<artifactId>springfox-boot-starter</artifactId>
|
||||
<version>${spring.fox.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.springdoc</groupId>
|
||||
<artifactId>springdoc-openapi-ui</artifactId>
|
||||
<version>${springdoc.version}</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>com.fasterxml.jackson.core</groupId>
|
||||
<artifactId>jackson-databind</artifactId>
|
||||
|
@ -70,7 +70,7 @@
|
|||
</build>
|
||||
|
||||
<properties>
|
||||
<spring.fox.version>3.0.0</spring.fox.version>
|
||||
<springdoc.version>1.7.0</springdoc.version>
|
||||
<start-class>com.baeldung.springboot.swagger.ArticleApplication</start-class>
|
||||
</properties>
|
||||
|
||||
|
|
|
@ -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"));
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -21,7 +21,7 @@ public class ArticlesController {
|
|||
}
|
||||
|
||||
@PostMapping("")
|
||||
public void addArticle(@ModelAttribute Article article) {
|
||||
public void addArticle(@RequestBody Article article) {
|
||||
articleService.addArticle(article);
|
||||
}
|
||||
|
||||
|
|
|
@ -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;
|
||||
|
|
Loading…
Reference in New Issue