Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-web:2.0.5.RELEASE'
implementation 'org.mybatis.spring.boot:mybatis-spring-boot-starter:2.0.0'
implementation 'com.h2database:h2:1.4.197'
implementation 'io.springfox:springfox-swagger2:2.6.1'
implementation 'io.springfox:springfox-swagger-ui:2.6.1'

testImplementation 'org.springframework.boot:spring-boot-starter-test:2.0.5.RELEASE'

Expand Down
48 changes: 48 additions & 0 deletions src/main/java/banking/api/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
package banking.api.config;

import com.google.common.base.Predicate;
import com.google.common.base.Predicates;
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.EnableSwagger2;


@Configuration
@EnableSwagger2
public class SwaggerConfig {

@Bean
public Docket produceApi() {

return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.basePackage("banking.api.controllers"))
.paths(paths())
.build();
}

// Describe your apis
private ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title("Banking Rest APIs")
.description("This page lists all the rest apis for Banking API")
.version("1.0-SNAPSHOT")
.build();
}

// Only select apis that matches the given Predicates.
private Predicate<String> paths() {
// Match all paths except /error
return Predicates.and(
PathSelectors.regex("/customer.*"),
Predicates.not(PathSelectors.regex("/error.*"))
);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,13 @@
import banking.api.response.models.GenericResponse;
import banking.api.services.CustomerOperationsService;

import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;

@RestController
@Api(value="/customer",description="Customer Profile",produces ="application/json")
public class CustomerOperationsController {

@Autowired
Expand All @@ -33,8 +39,15 @@ public class CustomerOperationsController {
public String welcomeMessage() {
return Messages.WELCOME_MSG;
}





@ApiOperation(value="get balance",response=Customer.class)
@ApiResponses(value={
@ApiResponse(code=200,message="Customer Details Retrieved",response=GenericResponse.class),
@ApiResponse(code=500,message="Internal Server Error"),
@ApiResponse(code=404,message="Customer not found")
})
@GetMapping("/customer/balance/{nationalIdNum}")
public GenericResponse checkBalance(@PathVariable("nationalIdNum") Long nationalIdNum ) {
BigDecimal accountBalance = null;
Expand Down