Skip to content

Commit

Permalink
#27 [Add] Swagger 적용
Browse files Browse the repository at this point in the history
Swagger를 적용하고, Controller의 메서드 하나를 문서화하였습니다
  • Loading branch information
JSoi committed Jul 12, 2022
1 parent 22c4fd3 commit c30d958
Show file tree
Hide file tree
Showing 3 changed files with 49 additions and 0 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,9 @@ dependencies {
implementation 'com.fasterxml.jackson.core:jackson-databind:2.13.3'
//s3 파일 업로드
implementation 'io.awspring.cloud:spring-cloud-starter-aws:2.4.1'
//swagger
implementation 'io.springfox:springfox-boot-starter:3.0.0'

}
tasks.named('test') {
useJUnitPlatform()
Expand Down
39 changes: 39 additions & 0 deletions src/main/java/com/mpnp/baechelin/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
package com.mpnp.baechelin.config;


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 {

private static final String API_NAME = "Baechelin Project API";
private static final String API_VERSION = "0.0.1";
private static final String API_DESCRIPTION = "Baechelin 프로젝트 명세서";

@Bean
public Docket api() {
return new Docket(DocumentationType.SWAGGER_2)
.apiInfo(apiInfo())
.select()
.apis(RequestHandlerSelectors.any())
.paths(PathSelectors.any())
.build();
}

public ApiInfo apiInfo() {
return new ApiInfoBuilder()
.title(API_NAME)
.version(API_VERSION)
.description(API_DESCRIPTION)
.build();
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,10 @@
import com.mpnp.baechelin.store.dto.StoreResponseDto;
import com.mpnp.baechelin.store.repository.StoreQueryRepository;
import com.mpnp.baechelin.store.service.StoreService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiImplicitParam;
import io.swagger.annotations.ApiImplicitParams;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.data.domain.Pageable;
import org.springframework.data.web.PageableDefault;
Expand All @@ -16,6 +20,7 @@
import java.util.List;
import java.util.stream.Collectors;

@Api(tags = {"매장 리스트를 반환하는 Controller"})
@RestController
@RequiredArgsConstructor
@RequestMapping("/store")
Expand All @@ -24,6 +29,7 @@ public class StoreController {
private final StoreService storeService;
private final StoreQueryRepository storeQueryRepository;

@ApiOperation(value = "조건에 맞는 업장 목록을 반환하는 메소드")
@GetMapping("/near")
public List<StoreResponseDto> getStoreInRange(@RequestParam(required = false) BigDecimal latStart,
@RequestParam(required = false) BigDecimal latEnd,
Expand All @@ -35,6 +41,7 @@ public List<StoreResponseDto> getStoreInRange(@RequestParam(required = false) Bi
List<Store> betweenLngLat = storeQueryRepository.findBetweenLngLat(latStart, latEnd, lngStart, lngEnd, category, facility, pageable);
return betweenLngLat.parallelStream().map(storeService::storeToResDto).collect(Collectors.toList());// 순서보장
}

@GetMapping("/point")
public List<StoreResponseDto> getStoreInRangeHighPoint(@RequestParam(required = false) BigDecimal latStart,
@RequestParam(required = false) BigDecimal latEnd,
Expand Down

0 comments on commit c30d958

Please sign in to comment.