Merge pull request #12789 from panos-kakos/JAVA-14985

[JAVA-14985] Moved code related to articles from spring-boot-mvc-2 to…
This commit is contained in:
Loredana Crusoveanu 2022-09-30 11:09:02 +03:00 committed by GitHub
commit 2d40c9c71d
11 changed files with 42 additions and 39 deletions

View File

@ -5,8 +5,6 @@ This module contains articles about Spring Web MVC in Spring Boot projects.
### Relevant Articles: ### Relevant Articles:
- [Functional Controllers in Spring MVC](https://www.baeldung.com/spring-mvc-functional-controllers) - [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 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) - [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) - [Spring Boot Consuming and Producing JSON](https://www.baeldung.com/spring-boot-json)

View File

@ -28,22 +28,6 @@
<artifactId>spring-boot-devtools</artifactId> <artifactId>spring-boot-devtools</artifactId>
<optional>true</optional> <optional>true</optional>
</dependency> </dependency>
<!-- Swagger dependencies for REST documentation -->
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${spring.fox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger-ui</artifactId>
<version>${spring.fox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webmvc</artifactId>
<version>${spring.fox.version}</version>
</dependency>
<dependency> <dependency>
<groupId>org.apache.commons</groupId> <groupId>org.apache.commons</groupId>
<artifactId>commons-lang3</artifactId> <artifactId>commons-lang3</artifactId>
@ -90,8 +74,7 @@
<properties> <properties>
<spring.fox.version>3.0.0</spring.fox.version> <spring.fox.version>3.0.0</spring.fox.version>
<start-class>com.baeldung.swagger2boot.SpringBootSwaggerApplication</start-class> <start-class>com.baeldung.springbootmvc.SpringBootMvcFnApplication</start-class>
<!-- <start-class>com.baeldung.springbootmvc.SpringBootMvcFnApplication</start-class> -->
<xstream.version>1.4.11.1</xstream.version> <xstream.version>1.4.11.1</xstream.version>
</properties> </properties>

View File

@ -1,3 +1,5 @@
### Relevant Articles: ### Relevant Articles:
- [Swagger: Specify Two Responses with the Same Response Code](https://www.baeldung.com/swagger-two-responses-one-response-code) - [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)

View File

@ -39,6 +39,16 @@
<groupId>javax.validation</groupId> <groupId>javax.validation</groupId>
<artifactId>validation-api</artifactId> <artifactId>validation-api</artifactId>
</dependency> </dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-swagger2</artifactId>
<version>${springfox.version}</version>
</dependency>
<dependency>
<groupId>io.springfox</groupId>
<artifactId>springfox-spring-webmvc</artifactId>
<version>${springfox.version}</version>
</dependency>
</dependencies> </dependencies>
<build> <build>
@ -63,6 +73,13 @@
</execution> </execution>
</executions> </executions>
</plugin> </plugin>
<plugin>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-maven-plugin</artifactId>
<configuration>
<mainClass>${start-class}</mainClass>
</configuration>
</plugin>
</plugins> </plugins>
</build> </build>
@ -70,6 +87,8 @@
<springfox.version>3.0.0</springfox.version> <springfox.version>3.0.0</springfox.version>
<swagger-codegen-maven-plugin.version>3.0.34</swagger-codegen-maven-plugin.version> <swagger-codegen-maven-plugin.version>3.0.34</swagger-codegen-maven-plugin.version>
<springdoc.version>1.6.10</springdoc.version> <springdoc.version>1.6.10</springdoc.version>
<swagger-maven-plugin.version>3.1.1</swagger-maven-plugin.version>
<start-class>com.baeldung.tworesponses.Application</start-class>
</properties> </properties>
</project> </project>

View File

@ -1,4 +1,4 @@
package com.baeldung.swagger2boot; package com.baeldung.swagger2bootmvc;
import org.springframework.boot.SpringApplication; import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication; import org.springframework.boot.autoconfigure.SpringBootApplication;

View File

@ -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.Bean;
import org.springframework.context.annotation.Configuration; import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.EnableWebMvc;
import springfox.documentation.builders.ApiInfoBuilder; import springfox.documentation.builders.ApiInfoBuilder;
import springfox.documentation.builders.PathSelectors; import springfox.documentation.builders.PathSelectors;
@ -9,10 +10,12 @@ import springfox.documentation.builders.RequestHandlerSelectors;
import springfox.documentation.service.ApiInfo; import springfox.documentation.service.ApiInfo;
import springfox.documentation.spi.DocumentationType; import springfox.documentation.spi.DocumentationType;
import springfox.documentation.spring.web.plugins.Docket; import springfox.documentation.spring.web.plugins.Docket;
import springfox.documentation.swagger2.annotations.EnableSwagger2WebMvc; import springfox.documentation.swagger2.annotations.EnableSwagger2;
@Configuration @Configuration
@EnableSwagger2WebMvc @EnableWebMvc
@EnableSwagger2
public class Swagger2Config { public class Swagger2Config {
@Bean @Bean
public Docket api() { public Docket api() {

View File

@ -1,4 +1,4 @@
package com.baeldung.swagger2boot.controller; package com.baeldung.swagger2bootmvc.controller;
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; 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.ResponseBody;
import org.springframework.web.bind.annotation.ResponseStatus; 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.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams; import io.swagger.annotations.ApiImplicitParams;

View File

@ -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.http.HttpStatus;
import org.springframework.stereotype.Controller; 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 com.baeldung.swagger2bootmvc.model.User;
import javax.websocket.server.PathParam;
import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
@Controller @Controller
public class UserController { public class UserController {

View File

@ -1,4 +1,4 @@
package com.baeldung.swagger2boot.model; package com.baeldung.swagger2bootmvc.model;
import java.util.List; import java.util.List;

View File

@ -1,4 +1,4 @@
package com.baeldung.swagger2boot.model; package com.baeldung.swagger2bootmvc.model;
import io.swagger.annotations.ApiModel; import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty; import io.swagger.annotations.ApiModelProperty;