Updated indentation
This commit is contained in:
parent
1d1791c90d
commit
31a9e429f1
|
@ -14,18 +14,17 @@ import springfox.documentation.swagger2.annotations.EnableSwagger2;
|
||||||
@EnableSwagger2
|
@EnableSwagger2
|
||||||
public class ArticleApplication {
|
public class ArticleApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
SpringApplication.run(ArticleApplication.class, args);
|
SpringApplication.run(ArticleApplication.class, args);
|
||||||
|
}
|
||||||
}
|
|
||||||
|
@Bean
|
||||||
@Bean
|
public Docket api() {
|
||||||
public Docket api() {
|
return new Docket(DocumentationType.SWAGGER_2)
|
||||||
return new Docket(DocumentationType.SWAGGER_2)
|
.select()
|
||||||
.select()
|
.apis(RequestHandlerSelectors.any())
|
||||||
.apis(RequestHandlerSelectors.any())
|
.paths(PathSelectors.any())
|
||||||
.paths(PathSelectors.any())
|
.build();
|
||||||
.build();
|
}
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -11,18 +11,18 @@ import com.baeldung.springboot.swagger.service.ArticleService;
|
||||||
@RestController
|
@RestController
|
||||||
@RequestMapping("/articles")
|
@RequestMapping("/articles")
|
||||||
public class ArticlesController {
|
public class ArticlesController {
|
||||||
|
|
||||||
@Autowired
|
@Autowired
|
||||||
private ArticleService articleService;
|
private ArticleService articleService;
|
||||||
|
|
||||||
@GetMapping("")
|
@GetMapping("")
|
||||||
public List<Article> getAllArticles(){
|
public List<Article> getAllArticles() {
|
||||||
return articleService.getAllArticles();
|
return articleService.getAllArticles();
|
||||||
}
|
}
|
||||||
|
|
||||||
@PostMapping("")
|
@PostMapping("")
|
||||||
public void addArticle(@RequestBody Article article) {
|
public void addArticle(@RequestBody Article article) {
|
||||||
articleService.addArticle(article);
|
articleService.addArticle(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -13,7 +13,7 @@ public class Article {
|
||||||
//@JsonIgnore
|
//@JsonIgnore
|
||||||
//@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
//@JsonProperty(access = JsonProperty.Access.READ_ONLY)
|
||||||
//@ApiModelProperty(hidden = true)
|
//@ApiModelProperty(hidden = true)
|
||||||
@ApiParam(hidden = true)
|
//@ApiParam(hidden = true)
|
||||||
//@ApiModelProperty(readOnly = true)
|
//@ApiModelProperty(readOnly = true)
|
||||||
private int id;
|
private int id;
|
||||||
private String title;
|
private String title;
|
||||||
|
|
|
@ -9,17 +9,17 @@ import com.baeldung.springboot.swagger.model.Article;
|
||||||
|
|
||||||
@Service
|
@Service
|
||||||
public class ArticleService {
|
public class ArticleService {
|
||||||
|
|
||||||
private List<Article> articles = new ArrayList<>();
|
private List<Article> articles = new ArrayList<>();
|
||||||
|
|
||||||
public List<Article> getAllArticles(){
|
public List<Article> getAllArticles() {
|
||||||
return articles;
|
return articles;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void addArticle(Article article) {
|
public void addArticle(Article article) {
|
||||||
article.setId(articles.size()+1);
|
article.setId(articles.size() + 1);
|
||||||
articles.add(article);
|
articles.add(article);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue