diff --git a/spring-boot-modules/spring-boot-mvc-2/README.md b/spring-boot-modules/spring-boot-mvc-2/README.md index 30e6d71a30..1d89726b71 100644 --- a/spring-boot-modules/spring-boot-mvc-2/README.md +++ b/spring-boot-modules/spring-boot-mvc-2/README.md @@ -5,8 +5,6 @@ This module contains articles about Spring Web MVC in Spring Boot projects. ### Relevant Articles: - [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) -- [Specify an Array of Strings as Body Parameters in Swagger](https://www.baeldung.com/swagger-body-array-of-strings) -- [Swagger @ApiParam vs @ApiModelProperty](https://www.baeldung.com/swagger-apiparam-vs-apimodelproperty) - [Testing REST with multiple MIME types](https://www.baeldung.com/testing-rest-api-with-multiple-media-types) - [Testing Web APIs with Postman Collections](https://www.baeldung.com/postman-testing-collections) - [Spring Boot Consuming and Producing JSON](https://www.baeldung.com/spring-boot-json) diff --git a/spring-boot-modules/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml index f303171df8..bcc0cb68a0 100644 --- a/spring-boot-modules/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -28,22 +28,6 @@ spring-boot-devtools true - - - io.springfox - springfox-swagger2 - ${spring.fox.version} - - - io.springfox - springfox-swagger-ui - ${spring.fox.version} - - - io.springfox - springfox-spring-webmvc - ${spring.fox.version} - org.apache.commons commons-lang3 @@ -90,8 +74,7 @@ 3.0.0 - com.baeldung.swagger2boot.SpringBootSwaggerApplication - + com.baeldung.springbootmvc.SpringBootMvcFnApplication 1.4.11.1 diff --git a/spring-boot-modules/spring-boot-swagger-2/README.md b/spring-boot-modules/spring-boot-swagger-2/README.md index e607b56299..242f3d3385 100644 --- a/spring-boot-modules/spring-boot-swagger-2/README.md +++ b/spring-boot-modules/spring-boot-swagger-2/README.md @@ -1,3 +1,5 @@ ### Relevant Articles: - [Swagger: Specify Two Responses with the Same Response Code](https://www.baeldung.com/swagger-two-responses-one-response-code) +- [Specify an Array of Strings as Body Parameters in Swagger](https://www.baeldung.com/swagger-body-array-of-strings) +- [Swagger @ApiParam vs @ApiModelProperty](https://www.baeldung.com/swagger-apiparam-vs-apimodelproperty) \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-2/pom.xml b/spring-boot-modules/spring-boot-swagger-2/pom.xml index 055d8ce3eb..a054773731 100644 --- a/spring-boot-modules/spring-boot-swagger-2/pom.xml +++ b/spring-boot-modules/spring-boot-swagger-2/pom.xml @@ -39,6 +39,16 @@ javax.validation validation-api + + io.springfox + springfox-swagger2 + ${springfox.version} + + + io.springfox + springfox-spring-webmvc + ${springfox.version} + @@ -63,6 +73,13 @@ + + org.springframework.boot + spring-boot-maven-plugin + + ${start-class} + + @@ -70,6 +87,8 @@ 3.0.0 3.0.34 1.6.10 + 3.1.1 + com.baeldung.tworesponses.Application \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java similarity index 89% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java rename to spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java index 0f68f75d16..e166d28e7c 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java @@ -1,4 +1,4 @@ -package com.baeldung.swagger2boot; +package com.baeldung.swagger2bootmvc; import org.springframework.boot.SpringApplication; import org.springframework.boot.autoconfigure.SpringBootApplication; diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java similarity index 88% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java rename to spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java index 6f3557d597..d4a7774510 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java @@ -1,7 +1,8 @@ -package com.baeldung.swagger2boot.config; +package com.baeldung.swagger2bootmvc.config; import org.springframework.context.annotation.Bean; import org.springframework.context.annotation.Configuration; +import org.springframework.web.servlet.config.annotation.EnableWebMvc; import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.PathSelectors; @@ -9,10 +10,12 @@ import springfox.documentation.builders.RequestHandlerSelectors; import springfox.documentation.service.ApiInfo; import springfox.documentation.spi.DocumentationType; import springfox.documentation.spring.web.plugins.Docket; -import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; +import springfox.documentation.swagger2.annotations.EnableSwagger2; + @Configuration -@EnableSwagger2WebMvc +@EnableWebMvc +@EnableSwagger2 public class Swagger2Config { @Bean public Docket api() { diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java similarity index 91% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java rename to spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java index ac6d99c40c..5edf610154 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java @@ -1,4 +1,4 @@ -package com.baeldung.swagger2boot.controller; +package com.baeldung.swagger2bootmvc.controller; import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; @@ -10,7 +10,7 @@ import org.springframework.web.bind.annotation.RequestMethod; import org.springframework.web.bind.annotation.ResponseBody; import org.springframework.web.bind.annotation.ResponseStatus; -import com.baeldung.swagger2boot.model.Foo; +import com.baeldung.swagger2bootmvc.model.Foo; import io.swagger.annotations.ApiImplicitParam; import io.swagger.annotations.ApiImplicitParams; diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/UserController.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java similarity index 68% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/UserController.java rename to spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java index d8102a8407..fa879f3bea 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/UserController.java +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java @@ -1,19 +1,17 @@ -package com.baeldung.swagger2boot.controller; +package com.baeldung.swagger2bootmvc.controller; -import com.baeldung.swagger2boot.model.Foo; -import com.baeldung.swagger2boot.model.User; -import io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; -import io.swagger.annotations.ApiOperation; -import io.swagger.annotations.ApiParam; import org.springframework.http.HttpStatus; import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.*; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.RequestParam; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; -import javax.validation.Valid; -import javax.websocket.server.PathParam; +import com.baeldung.swagger2bootmvc.model.User; -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; @Controller public class UserController { diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java similarity index 94% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java rename to spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java index e48c2016c0..f3fe56e07d 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java @@ -1,4 +1,4 @@ -package com.baeldung.swagger2boot.model; +package com.baeldung.swagger2bootmvc.model; import java.util.List; diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/User.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java similarity index 92% rename from spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/User.java rename to spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java index d4a6479f4e..b4ec55f564 100644 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/User.java +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java @@ -1,4 +1,4 @@ -package com.baeldung.swagger2boot.model; +package com.baeldung.swagger2bootmvc.model; import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModelProperty; diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/swagger-description.yml similarity index 100% rename from spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml rename to spring-boot-modules/spring-boot-swagger-2/src/main/resources/swagger-description.yml