[JAVA-14985] Clean up
This commit is contained in:
parent
8727f678d0
commit
29cb486075
@ -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>
|
||||||
|
@ -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);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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();
|
|
||||||
}
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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<String> name;
|
|
||||||
|
|
||||||
public Foo() {
|
|
||||||
super();
|
|
||||||
}
|
|
||||||
|
|
||||||
public Foo(final long id, final List<String> name) {
|
|
||||||
super();
|
|
||||||
|
|
||||||
this.id = id;
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
//
|
|
||||||
|
|
||||||
public long getId() {
|
|
||||||
return id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setId(final long id) {
|
|
||||||
this.id = id;
|
|
||||||
}
|
|
||||||
|
|
||||||
public List<String> getName() {
|
|
||||||
return name;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setName(final List<String> name) {
|
|
||||||
this.name = name;
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
|
@ -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;
|
|
||||||
}
|
|
||||||
}
|
|
@ -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
|
|
@ -49,37 +49,6 @@
|
|||||||
<artifactId>springfox-spring-webmvc</artifactId>
|
<artifactId>springfox-spring-webmvc</artifactId>
|
||||||
<version>${springfox.version}</version>
|
<version>${springfox.version}</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-web</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-validation</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-devtools</artifactId>
|
|
||||||
<optional>true</optional>
|
|
||||||
</dependency>
|
|
||||||
<!-- Swagger dependencies for REST documentation -->
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.apache.commons</groupId>
|
|
||||||
<artifactId>commons-lang3</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>org.springframework.boot</groupId>
|
|
||||||
<artifactId>spring-boot-starter-data-jpa</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.fasterxml.jackson.core</groupId>
|
|
||||||
<artifactId>jackson-databind</artifactId>
|
|
||||||
</dependency>
|
|
||||||
<dependency>
|
|
||||||
<groupId>com.h2database</groupId>
|
|
||||||
<artifactId>h2</artifactId>
|
|
||||||
</dependency>
|
|
||||||
|
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
<build>
|
<build>
|
||||||
@ -104,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>
|
||||||
|
|
||||||
@ -112,6 +88,7 @@
|
|||||||
<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>
|
<swagger-maven-plugin.version>3.1.1</swagger-maven-plugin.version>
|
||||||
|
<start-class>com.baeldung.tworesponses.Application</start-class>
|
||||||
</properties>
|
</properties>
|
||||||
|
|
||||||
</project>
|
</project>
|
Loading…
x
Reference in New Issue
Block a user