Skip to content

Commit a43d182

Browse files
committed
Integrating swagger
1 parent 5604f1b commit a43d182

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed

todo-app-rest/pom.xml

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,18 @@
2525
<artifactId>spring-boot-actuator</artifactId>
2626
</dependency>
2727

28+
<dependency>
29+
<groupId>io.springfox</groupId>
30+
<artifactId>springfox-swagger2</artifactId>
31+
<version>2.5.0</version>
32+
</dependency>
33+
34+
<dependency>
35+
<groupId>io.springfox</groupId>
36+
<artifactId>springfox-swagger-ui</artifactId>
37+
<version>2.5.0</version>
38+
</dependency>
39+
2840
<!-- <dependency> <groupId>com.aj.todoapp.data</groupId> <artifactId>todo-app-data</artifactId>
2941
</dependency> -->
3042

@@ -40,6 +52,8 @@
4052
</dependency>
4153

4254

55+
56+
4357
</dependencies>
4458

4559
<build>
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
1+
package com.aj.todoapp.docs;
2+
3+
import org.springframework.context.annotation.Bean;
4+
import org.springframework.context.annotation.ComponentScan;
5+
import org.springframework.context.annotation.Configuration;
6+
7+
import com.google.common.base.Predicates;
8+
9+
import springfox.documentation.builders.ApiInfoBuilder;
10+
import springfox.documentation.builders.PathSelectors;
11+
import springfox.documentation.builders.RequestHandlerSelectors;
12+
import springfox.documentation.service.ApiInfo;
13+
import springfox.documentation.spi.DocumentationType;
14+
import springfox.documentation.spring.web.plugins.Docket;
15+
import springfox.documentation.swagger2.annotations.EnableSwagger2;
16+
17+
@Configuration
18+
@EnableSwagger2
19+
@ComponentScan("com.aj.todoapp.rest")
20+
public class SwaggerConfig {
21+
22+
@Bean
23+
public Docket api() {
24+
return new Docket(DocumentationType.SWAGGER_2).select().apis(RequestHandlerSelectors.any())
25+
.paths(Predicates.not(PathSelectors.regex("/error"))).build().apiInfo(apiInfo());
26+
}
27+
28+
private ApiInfo apiInfo() {
29+
return new ApiInfoBuilder().title("REST example").description("REST example").termsOfServiceUrl("github")
30+
.license("Aditya").licenseUrl("").version("1.0").build();
31+
}
32+
33+
}

0 commit comments

Comments
 (0)