Springfox - PR review fix
This commit is contained in:
parent
7fefb0ff18
commit
3b4e9585d5
@ -12,7 +12,9 @@ import org.springframework.context.annotation.Bean;
|
||||
import org.springframework.context.annotation.ComponentScan;
|
||||
import org.springframework.context.annotation.Import;
|
||||
import org.springframework.data.jpa.repository.config.EnableJpaRepositories;
|
||||
|
||||
import com.baeldung.springfox.plugin.EmailAnnotationPlugin;
|
||||
|
||||
import springfox.bean.validators.configuration.BeanValidatorPluginsConfiguration;
|
||||
import springfox.documentation.service.ApiInfo;
|
||||
import springfox.documentation.spi.DocumentationType;
|
||||
@ -36,11 +38,11 @@ public class SpringfoxApplication {
|
||||
@Bean
|
||||
public Docket springfoxAppInfo() {
|
||||
return new Docket(DocumentationType.SWAGGER_2)
|
||||
.groupName("baeldung-springfox-api")
|
||||
.select()
|
||||
.paths(paths())
|
||||
.build()
|
||||
.apiInfo(apiInfo());
|
||||
.groupName("baeldung-springfox-api")
|
||||
.select()
|
||||
.paths(paths())
|
||||
.build()
|
||||
.apiInfo(apiInfo());
|
||||
}
|
||||
|
||||
private Predicate<String> paths() {
|
||||
@ -48,13 +50,8 @@ public class SpringfoxApplication {
|
||||
}
|
||||
|
||||
private ApiInfo apiInfo() {
|
||||
return new ApiInfo(
|
||||
"Springfox API specification",
|
||||
"User REST and Spring Data APIs",
|
||||
"",
|
||||
"",
|
||||
null,
|
||||
"License of API", "API license URL", Collections.emptyList());
|
||||
return new ApiInfo("Springfox API specification", "User REST and Spring Data APIs",
|
||||
"", "", null, "License of API", "API license URL", Collections.emptyList());
|
||||
}
|
||||
|
||||
@Bean
|
||||
|
@ -1,8 +1,5 @@
|
||||
package com.baeldung.springfox.controller;
|
||||
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.GET;
|
||||
import static org.springframework.web.bind.annotation.RequestMethod.POST;
|
||||
|
||||
import java.util.Optional;
|
||||
|
||||
import org.springframework.beans.factory.annotation.Autowired;
|
||||
@ -10,6 +7,8 @@ import org.springframework.http.HttpStatus;
|
||||
import org.springframework.http.MediaType;
|
||||
import org.springframework.http.ResponseEntity;
|
||||
import org.springframework.stereotype.Controller;
|
||||
import org.springframework.web.bind.annotation.GetMapping;
|
||||
import org.springframework.web.bind.annotation.PostMapping;
|
||||
import org.springframework.web.bind.annotation.RequestBody;
|
||||
import org.springframework.web.bind.annotation.RequestMapping;
|
||||
import org.springframework.web.bind.annotation.RequestParam;
|
||||
@ -25,16 +24,14 @@ public class UserController {
|
||||
@Autowired
|
||||
private UserRepository userRepository;
|
||||
|
||||
@RequestMapping(method = POST)
|
||||
@ResponseBody
|
||||
public ResponseEntity<User> createUser(@RequestBody User user) {
|
||||
@PostMapping
|
||||
public @ResponseBody ResponseEntity<User> createUser(@RequestBody User user) {
|
||||
userRepository.save(user);
|
||||
return new ResponseEntity<>(user, HttpStatus.OK);
|
||||
}
|
||||
|
||||
@RequestMapping(method = GET)
|
||||
@ResponseBody
|
||||
public ResponseEntity<User> getUser(@RequestParam Long id) {
|
||||
@GetMapping
|
||||
public @ResponseBody ResponseEntity<User> getUser(@RequestParam Long id) {
|
||||
Optional<User> user = userRepository.findById(id);
|
||||
return new ResponseEntity<>(user.get(), HttpStatus.OK);
|
||||
}
|
||||
|
@ -16,8 +16,6 @@ public class User{
|
||||
@NotNull(message = "First Name cannot be null")
|
||||
private String firstName;
|
||||
|
||||
private String lastName;
|
||||
|
||||
@Min(value = 15, message = "Age should not be less than 15")
|
||||
@Max(value = 65, message = "Age should not be greater than 65")
|
||||
private int age;
|
||||
@ -41,14 +39,6 @@ public class User{
|
||||
this.firstName = firstName;
|
||||
}
|
||||
|
||||
public String getLastName() {
|
||||
return lastName;
|
||||
}
|
||||
|
||||
public void setLastName(String lastName) {
|
||||
this.lastName = lastName;
|
||||
}
|
||||
|
||||
public String getEmail() {
|
||||
return email;
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user