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
|
@ -33,9 +33,9 @@
|
||||||
<optional>true</optional>
|
<optional>true</optional>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>io.springfox</groupId>
|
<groupId>org.springdoc</groupId>
|
||||||
<artifactId>springfox-boot-starter</artifactId>
|
<artifactId>springdoc-openapi-ui</artifactId>
|
||||||
<version>${spring.fox.version}</version>
|
<version>${springdoc.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
<groupId>com.fasterxml.jackson.core</groupId>
|
||||||
|
@ -70,7 +70,7 @@
|
||||||
</build>
|
</build>
|
||||||
|
|
||||||
<properties>
|
<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>
|
<start-class>com.baeldung.springboot.swagger.ArticleApplication</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
|
|
|
@ -5,14 +5,10 @@ import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
import org.springframework.context.annotation.Bean;
|
import org.springframework.context.annotation.Bean;
|
||||||
|
|
||||||
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
|
||||||
import springfox.documentation.builders.PathSelectors;
|
import io.swagger.v3.oas.models.OpenAPI;
|
||||||
import springfox.documentation.builders.RequestHandlerSelectors;
|
import io.swagger.v3.oas.models.info.Info;
|
||||||
import springfox.documentation.spi.DocumentationType;
|
|
||||||
import springfox.documentation.spring.web.plugins.Docket;
|
|
||||||
import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
@EnableSwagger2
|
|
||||||
@EnableWebMvc
|
@EnableWebMvc
|
||||||
public class ArticleApplication {
|
public class ArticleApplication {
|
||||||
|
|
||||||
|
@ -21,12 +17,10 @@ public class ArticleApplication {
|
||||||
}
|
}
|
||||||
|
|
||||||
@Bean
|
@Bean
|
||||||
public Docket api() {
|
public OpenAPI openAPI() {
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
return new OpenAPI().info(new Info().title("SpringDoc example")
|
||||||
.select()
|
.description("SpringDoc application")
|
||||||
.apis(RequestHandlerSelectors.any())
|
.version("v0.0.1"));
|
||||||
.paths(PathSelectors.any())
|
|
||||||
.build();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -21,7 +21,7 @@ public class ArticlesController {
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
public void addArticle(@ModelAttribute Article article) {
|
public void addArticle(@RequestBody Article article) {
|
||||||
articleService.addArticle(article);
|
articleService.addArticle(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1,21 +1,16 @@
|
||||||
package com.baeldung.springboot.swagger.model;
|
package com.baeldung.springboot.swagger.model;
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnore;
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
||||||
import com.fasterxml.jackson.annotation.JsonIgnoreProperties;
|
|
||||||
|
|
||||||
import com.fasterxml.jackson.annotation.JsonProperty;
|
import com.fasterxml.jackson.annotation.JsonProperty;
|
||||||
import com.fasterxml.jackson.annotation.JsonView;
|
import io.swagger.v3.oas.annotations.Hidden;
|
||||||
import io.swagger.annotations.ApiModelProperty;
|
import io.swagger.v3.oas.annotations.media.Schema;
|
||||||
import io.swagger.annotations.ApiParam;
|
import io.swagger.v3.oas.annotations.media.Schema.AccessMode;
|
||||||
|
|
||||||
public class Article {
|
public class Article {
|
||||||
|
|
||||||
//@JsonIgnore
|
// @JsonIgnore
|
||||||
//@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
// @JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
//@ApiModelProperty(hidden = true)
|
// @Schema(accessMode = AccessMode.READ_ONLY)
|
||||||
//@ApiParam(hidden = true)
|
@Hidden
|
||||||
//@ApiModelProperty(readOnly = true)
|
|
||||||
@ApiParam(hidden = true)
|
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
private int numOfWords;
|
private int numOfWords;
|
||||||
|
|
Loading…
Reference in New Issue