diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java index fd03efa695..568d31e8bc 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/ArticleApplication.java @@ -14,18 +14,17 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2; @EnableSwagger2 public class ArticleApplication { - public static void main(String[] args) { - SpringApplication.run(ArticleApplication.class, args); - - } - - @Bean - public Docket api() { - return new Docket(DocumentationType.SWAGGER_2) - .select() - .apis(RequestHandlerSelectors.any()) - .paths(PathSelectors.any()) - .build(); - } + public static void main(String[] args) { + SpringApplication.run(ArticleApplication.class, args); + } + + @Bean + public Docket api() { + return new Docket(DocumentationType.SWAGGER_2) + .select() + .apis(RequestHandlerSelectors.any()) + .paths(PathSelectors.any()) + .build(); + } } diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java index 380f40dbd5..96812e367a 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/controller/ArticlesController.java @@ -11,18 +11,18 @@ import com.baeldung.springboot.swagger.service.ArticleService; @RestController @RequestMapping("/articles") public class ArticlesController { - - @Autowired - private ArticleService articleService; - - @GetMapping("") - public List
getAllArticles(){ - return articleService.getAllArticles(); - } - - @PostMapping("") - public void addArticle(@RequestBody Article article) { - articleService.addArticle(article); - } + + @Autowired + private ArticleService articleService; + + @GetMapping("") + public List
getAllArticles() { + return articleService.getAllArticles(); + } + + @PostMapping("") + public void addArticle(@RequestBody Article article) { + articleService.addArticle(article); + } } diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java index ba927d5b4f..6512b4e1a7 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/model/Article.java @@ -13,7 +13,7 @@ public class Article { //@JsonIgnore //@JsonProperty(access = JsonProperty.Access.READ_ONLY) //@ApiModelProperty(hidden = true) - @ApiParam(hidden = true) + //@ApiParam(hidden = true) //@ApiModelProperty(readOnly = true) private int id; private String title; diff --git a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java index b41bfabb29..04f6e6c6e3 100644 --- a/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java +++ b/spring-boot-modules/spring-boot-mvc/src/main/java/com/baeldung/springboot/swagger/service/ArticleService.java @@ -9,17 +9,17 @@ import com.baeldung.springboot.swagger.model.Article; @Service public class ArticleService { - - private List
articles = new ArrayList<>(); - - public List
getAllArticles(){ - return articles; - } - - public void addArticle(Article article) { - article.setId(articles.size()+1); - articles.add(article); - } + + private List
articles = new ArrayList<>(); + + public List
getAllArticles() { + return articles; + } + + public void addArticle(Article article) { + article.setId(articles.size() + 1); + articles.add(article); + } }