From 8727f678d08cc3620a7c6e6ff691b61110761655 Mon Sep 17 00:00:00 2001 From: panagiotiskakos Date: Thu, 29 Sep 2022 08:10:58 +0300 Subject: [PATCH 1/2] [JAVA-14985] Moved code related to articles from spring-boot-mvc-2 to spring-boot-swagger-2 --- .../spring-boot-mvc-2/README.md | 2 - spring-boot-modules/spring-boot-mvc-2/pom.xml | 3 +- .../spring-boot-swagger-2/README.md | 2 + .../spring-boot-swagger-2/pom.xml | 42 ++++++++++++++++++ .../SpringBootSwaggerApplication.java | 13 ++++++ .../config/Swagger2Config.java | 38 ++++++++++++++++ .../controller/FooController.java | 35 +++++++++++++++ .../controller/UserController.java | 37 ++++++++++++++++ .../baeldung/swagger2bootmvc/model/Foo.java | 44 +++++++++++++++++++ .../baeldung/swagger2bootmvc/model/User.java | 28 ++++++++++++ .../main/resources/swagger-description.yml | 33 ++++++++++++++ 11 files changed, 273 insertions(+), 4 deletions(-) create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java create mode 100644 spring-boot-modules/spring-boot-swagger-2/src/main/resources/swagger-description.yml 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..01d89a87b0 100644 --- a/spring-boot-modules/spring-boot-mvc-2/pom.xml +++ b/spring-boot-modules/spring-boot-mvc-2/pom.xml @@ -90,8 +90,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..1bd05a7677 100644 --- a/spring-boot-modules/spring-boot-swagger-2/pom.xml +++ b/spring-boot-modules/spring-boot-swagger-2/pom.xml @@ -39,6 +39,47 @@ javax.validation validation-api + + io.springfox + springfox-swagger2 + ${springfox.version} + + + io.springfox + springfox-spring-webmvc + ${springfox.version} + + + org.springframework.boot + spring-boot-starter-web + + + org.springframework.boot + spring-boot-starter-validation + + + org.springframework.boot + spring-boot-devtools + true + + + + org.apache.commons + commons-lang3 + + + org.springframework.boot + spring-boot-starter-data-jpa + + + com.fasterxml.jackson.core + jackson-databind + + + com.h2database + h2 + + @@ -70,6 +111,7 @@ 3.0.0 3.0.34 1.6.10 + 3.1.1 \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java new file mode 100644 index 0000000000..e166d28e7c --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/SpringBootSwaggerApplication.java @@ -0,0 +1,13 @@ +package com.baeldung.swagger2bootmvc; + +import org.springframework.boot.SpringApplication; +import org.springframework.boot.autoconfigure.SpringBootApplication; + +@SpringBootApplication +public class SpringBootSwaggerApplication { + + public static void main(String[] args) { + SpringApplication.run(SpringBootSwaggerApplication.class, args); + } + +} diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java new file mode 100644 index 0000000000..d4a7774510 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/config/Swagger2Config.java @@ -0,0 +1,38 @@ +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; +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.EnableSwagger2; + + +@Configuration +@EnableWebMvc +@EnableSwagger2 +public class Swagger2Config { + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build() + .apiInfo(apiEndPointsInfo()); + } + + private ApiInfo apiEndPointsInfo() { + return new ApiInfoBuilder().title("Swagger Array") + .description("This is a sample Swagger description for an Array server") + .license("Apache 2.0") + .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") + .version("1.0.0") + .build(); + } +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java new file mode 100644 index 0000000000..5edf610154 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/FooController.java @@ -0,0 +1,35 @@ +package com.baeldung.swagger2bootmvc.controller; + +import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +import org.springframework.web.bind.annotation.RequestBody; +import org.springframework.web.bind.annotation.RequestMapping; +import org.springframework.web.bind.annotation.RequestMethod; +import org.springframework.web.bind.annotation.ResponseBody; +import org.springframework.web.bind.annotation.ResponseStatus; + +import com.baeldung.swagger2bootmvc.model.Foo; + +import io.swagger.annotations.ApiImplicitParam; +import io.swagger.annotations.ApiImplicitParams; + +@Controller +public class FooController { + + public FooController() { + super(); + } + + // API - write + @RequestMapping(method = RequestMethod.POST, value = "/foos") + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + @ApiImplicitParams({ @ApiImplicitParam(name = "foo", value = "List of strings", paramType = "body", dataType = "Foo") }) + public Foo create(@RequestBody final Foo foo) { + foo.setId(Long.parseLong(randomNumeric(2))); + return foo; + } + +} diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java new file mode 100644 index 0000000000..fa879f3bea --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/controller/UserController.java @@ -0,0 +1,37 @@ +package com.baeldung.swagger2bootmvc.controller; + +import org.springframework.http.HttpStatus; +import org.springframework.stereotype.Controller; +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 com.baeldung.swagger2bootmvc.model.User; + +import io.swagger.annotations.ApiOperation; +import io.swagger.annotations.ApiParam; + +@Controller +public class UserController { + + public UserController() { + super(); + } //@formatter:off + + @RequestMapping(method = RequestMethod.POST, value = "/createUser", produces = "application/json; charset=UTF-8") + @ResponseStatus(HttpStatus.CREATED) + @ResponseBody + @ApiOperation(value = "Create user", + notes = "This method creates a new user") + public User createUser(@ApiParam( + name = "firstName", + type = "String", + value = "First Name of the user", + example = "Vatsal", + required = true) @RequestParam String firstName) { //@formatter:on + User user = new User(firstName); + return user; + } +} diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java new file mode 100644 index 0000000000..f3fe56e07d --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/Foo.java @@ -0,0 +1,44 @@ +package com.baeldung.swagger2bootmvc.model; + +import java.util.List; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class Foo { + private long id; + + @ApiModelProperty(name = "name", dataType = "List", example = "[\"str1\", \"str2\", \"str3\"]") + private List name; + + public Foo() { + super(); + } + + public Foo(final long id, final List name) { + super(); + + this.id = id; + this.name = name; + } + + // + + public long getId() { + return id; + } + + public void setId(final long id) { + this.id = id; + } + + public List getName() { + return name; + } + + public void setName(final List name) { + this.name = name; + } + +} \ No newline at end of file diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java new file mode 100644 index 0000000000..b4ec55f564 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/java/com/baeldung/swagger2bootmvc/model/User.java @@ -0,0 +1,28 @@ +package com.baeldung.swagger2bootmvc.model; + +import io.swagger.annotations.ApiModel; +import io.swagger.annotations.ApiModelProperty; + +@ApiModel +public class User { + + @ApiModelProperty(value = "first name of the user", name = "firstName", dataType = "String", example = "Vatsal") + String firstName; + + public User() { + super(); + } + + public User(final String firstName) { + super(); + this.firstName = firstName; + } + + public String getFirstName() { + return firstName; + } + + public void setFirstName(String firstName) { + this.firstName = firstName; + } +} diff --git a/spring-boot-modules/spring-boot-swagger-2/src/main/resources/swagger-description.yml b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/swagger-description.yml new file mode 100644 index 0000000000..b40ddc80f0 --- /dev/null +++ b/spring-boot-modules/spring-boot-swagger-2/src/main/resources/swagger-description.yml @@ -0,0 +1,33 @@ +swagger: "2.0" +info: + description: "This is a sample Swagger description for an Array server" + version: "1.0.0" + title: "Swagger Array" + license: + name: "Apache 2.0" + url: "http://www.apache.org/licenses/LICENSE-2.0.html" +basePath: "/localhost:8080/" +tags: +- name: "foo-controller" + description: "Foo controller" + +paths: + /foos: + post: + tags: + - "foo-controller" + summary: "create" + description: "" + parameters: + - in: body + description: "" + required: true + name: name + schema: + type: array + items: + type: string + example: ["str1", "str2", "str3"] + responses: + default: + description: OK \ No newline at end of file From 29cb48607525f9b12bf890654db1f99408a2fd6d Mon Sep 17 00:00:00 2001 From: panagiotiskakos Date: Thu, 29 Sep 2022 21:16:16 +0300 Subject: [PATCH 2/2] [JAVA-14985] Clean up --- spring-boot-modules/spring-boot-mvc-2/pom.xml | 16 ------- .../SpringBootSwaggerApplication.java | 13 ------ .../swagger2boot/config/Swagger2Config.java | 35 --------------- .../controller/FooController.java | 35 --------------- .../controller/UserController.java | 39 ---------------- .../com/baeldung/swagger2boot/model/Foo.java | 44 ------------------- .../com/baeldung/swagger2boot/model/User.java | 28 ------------ .../main/resources/swagger-description.yml | 33 -------------- .../spring-boot-swagger-2/pom.xml | 39 ++++------------ 9 files changed, 8 insertions(+), 274 deletions(-) delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/UserController.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/User.java delete mode 100644 spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml diff --git a/spring-boot-modules/spring-boot-mvc-2/pom.xml b/spring-boot-modules/spring-boot-mvc-2/pom.xml index 01d89a87b0..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 diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java b/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java deleted file mode 100644 index 0f68f75d16..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/SpringBootSwaggerApplication.java +++ /dev/null @@ -1,13 +0,0 @@ -package com.baeldung.swagger2boot; - -import org.springframework.boot.SpringApplication; -import org.springframework.boot.autoconfigure.SpringBootApplication; - -@SpringBootApplication -public class SpringBootSwaggerApplication { - - public static void main(String[] args) { - SpringApplication.run(SpringBootSwaggerApplication.class, args); - } - -} 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-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java deleted file mode 100644 index 6f3557d597..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/config/Swagger2Config.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.swagger2boot.config; - -import org.springframework.context.annotation.Bean; -import org.springframework.context.annotation.Configuration; - -import springfox.documentation.builders.ApiInfoBuilder; -import springfox.documentation.builders.PathSelectors; -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; - -@Configuration -@EnableSwagger2WebMvc -public class Swagger2Config { - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build() - .apiInfo(apiEndPointsInfo()); - } - - private ApiInfo apiEndPointsInfo() { - return new ApiInfoBuilder().title("Swagger Array") - .description("This is a sample Swagger description for an Array server") - .license("Apache 2.0") - .licenseUrl("http://www.apache.org/licenses/LICENSE-2.0.html") - .version("1.0.0") - .build(); - } -} \ No newline at end of file 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-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java deleted file mode 100644 index ac6d99c40c..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/FooController.java +++ /dev/null @@ -1,35 +0,0 @@ -package com.baeldung.swagger2boot.controller; - -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; - -import org.springframework.http.HttpStatus; -import org.springframework.stereotype.Controller; -import org.springframework.web.bind.annotation.RequestBody; -import org.springframework.web.bind.annotation.RequestMapping; -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 io.swagger.annotations.ApiImplicitParam; -import io.swagger.annotations.ApiImplicitParams; - -@Controller -public class FooController { - - public FooController() { - super(); - } - - // API - write - @RequestMapping(method = RequestMethod.POST, value = "/foos") - @ResponseStatus(HttpStatus.CREATED) - @ResponseBody - @ApiImplicitParams({ @ApiImplicitParam(name = "foo", value = "List of strings", paramType = "body", dataType = "Foo") }) - public Foo create(@RequestBody final Foo foo) { - foo.setId(Long.parseLong(randomNumeric(2))); - return foo; - } - -} 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-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/UserController.java deleted file mode 100644 index d8102a8407..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/controller/UserController.java +++ /dev/null @@ -1,39 +0,0 @@ -package com.baeldung.swagger2boot.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 javax.validation.Valid; -import javax.websocket.server.PathParam; - -import static org.apache.commons.lang3.RandomStringUtils.randomNumeric; - -@Controller -public class UserController { - - public UserController() { - super(); - } //@formatter:off - - @RequestMapping(method = RequestMethod.POST, value = "/createUser", produces = "application/json; charset=UTF-8") - @ResponseStatus(HttpStatus.CREATED) - @ResponseBody - @ApiOperation(value = "Create user", - notes = "This method creates a new user") - public User createUser(@ApiParam( - name = "firstName", - type = "String", - value = "First Name of the user", - example = "Vatsal", - required = true) @RequestParam String firstName) { //@formatter:on - User user = new User(firstName); - return user; - } -} 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-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java deleted file mode 100644 index e48c2016c0..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/Foo.java +++ /dev/null @@ -1,44 +0,0 @@ -package com.baeldung.swagger2boot.model; - -import java.util.List; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel -public class Foo { - private long id; - - @ApiModelProperty(name = "name", dataType = "List", example = "[\"str1\", \"str2\", \"str3\"]") - private List name; - - public Foo() { - super(); - } - - public Foo(final long id, final List name) { - super(); - - this.id = id; - this.name = name; - } - - // - - public long getId() { - return id; - } - - public void setId(final long id) { - this.id = id; - } - - public List getName() { - return name; - } - - public void setName(final List name) { - this.name = name; - } - -} \ No newline at end of file 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-mvc-2/src/main/java/com/baeldung/swagger2boot/model/User.java deleted file mode 100644 index d4a6479f4e..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/java/com/baeldung/swagger2boot/model/User.java +++ /dev/null @@ -1,28 +0,0 @@ -package com.baeldung.swagger2boot.model; - -import io.swagger.annotations.ApiModel; -import io.swagger.annotations.ApiModelProperty; - -@ApiModel -public class User { - - @ApiModelProperty(value = "first name of the user", name = "firstName", dataType = "String", example = "Vatsal") - String firstName; - - public User() { - super(); - } - - public User(final String firstName) { - super(); - this.firstName = firstName; - } - - public String getFirstName() { - return firstName; - } - - public void setFirstName(String firstName) { - this.firstName = firstName; - } -} diff --git a/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml b/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml deleted file mode 100644 index b40ddc80f0..0000000000 --- a/spring-boot-modules/spring-boot-mvc-2/src/main/resources/swagger-description.yml +++ /dev/null @@ -1,33 +0,0 @@ -swagger: "2.0" -info: - description: "This is a sample Swagger description for an Array server" - version: "1.0.0" - title: "Swagger Array" - license: - name: "Apache 2.0" - url: "http://www.apache.org/licenses/LICENSE-2.0.html" -basePath: "/localhost:8080/" -tags: -- name: "foo-controller" - description: "Foo controller" - -paths: - /foos: - post: - tags: - - "foo-controller" - summary: "create" - description: "" - parameters: - - in: body - description: "" - required: true - name: name - schema: - type: array - items: - type: string - example: ["str1", "str2", "str3"] - responses: - default: - description: OK \ 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 1bd05a7677..a054773731 100644 --- a/spring-boot-modules/spring-boot-swagger-2/pom.xml +++ b/spring-boot-modules/spring-boot-swagger-2/pom.xml @@ -49,37 +49,6 @@ springfox-spring-webmvc ${springfox.version} - - org.springframework.boot - spring-boot-starter-web - - - org.springframework.boot - spring-boot-starter-validation - - - org.springframework.boot - spring-boot-devtools - true - - - - org.apache.commons - commons-lang3 - - - org.springframework.boot - spring-boot-starter-data-jpa - - - com.fasterxml.jackson.core - jackson-databind - - - com.h2database - h2 - - @@ -104,6 +73,13 @@ + + org.springframework.boot + spring-boot-maven-plugin + + ${start-class} + + @@ -112,6 +88,7 @@ 3.0.34 1.6.10 3.1.1 + com.baeldung.tworesponses.Application \ No newline at end of file