Skip to content

Commit

Permalink
Merge pull request #11 from dnd-side-project/feat/#9
Browse files Browse the repository at this point in the history
#9 feat: Swagger Setting
  • Loading branch information
min-0 authored Aug 22, 2024
2 parents f3ebe38 + 986e0b6 commit d601d58
Show file tree
Hide file tree
Showing 8 changed files with 44 additions and 34 deletions.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,9 @@ dependencies {
annotationProcessor 'org.projectlombok:lombok'
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// Swagger
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.1.0'
}

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

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@Configuration
public class SwaggerConfig {
@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info()
.title("MAPDDANG API")
.description("맵땅 앱 관련 API")
.version("1.0.0"));

}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package com.dnd.dndtravel.map.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

Expand All @@ -14,6 +16,8 @@ public class MapController {

private final MapService mapService;

@Tag(name = "MAP", description = "지도 API")
@Operation(summary = "전체 지역 조회", description = "전체 지역 방문 횟수를 조회합니다.")
@GetMapping("/maps")
public RegionResponse map() {
return mapService.allRegions();
Expand Down
10 changes: 4 additions & 6 deletions src/main/java/com/dnd/dndtravel/map/service/MapService.java
Original file line number Diff line number Diff line change
@@ -1,16 +1,14 @@
package com.dnd.dndtravel.map.service;

import java.util.List;

import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.dnd.dndtravel.map.domain.Region;
import com.dnd.dndtravel.map.repository.MapRepository;
import com.dnd.dndtravel.map.service.dto.RegionDto;
import com.dnd.dndtravel.map.service.dto.response.RegionResponse;

import lombok.RequiredArgsConstructor;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import java.util.List;

@RequiredArgsConstructor
@Service
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
package com.dnd.dndtravel.map.service.dto.response;

import java.util.List;

import com.dnd.dndtravel.map.service.dto.RegionDto;

import java.util.List;

public record RegionResponse(
List<RegionDto> regions,
int visitCount,
Expand Down
12 changes: 0 additions & 12 deletions src/main/java/com/dnd/dndtravel/test/TestController.java

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
package com.dnd.dndtravel.map.controller;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import com.dnd.dndtravel.map.service.MapService;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.Test;
Expand All @@ -11,7 +9,8 @@
import org.springframework.boot.test.mock.mockito.MockBean;
import org.springframework.test.web.servlet.MockMvc;

import com.dnd.dndtravel.map.service.MapService;
import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
@WebMvcTest(MapController.class)
Expand Down
19 changes: 9 additions & 10 deletions src/test/java/com/dnd/dndtravel/map/service/MapServiceTest.java
Original file line number Diff line number Diff line change
@@ -1,11 +1,9 @@
package com.dnd.dndtravel.map.service;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;

import java.util.List;
import java.util.stream.Stream;

import com.dnd.dndtravel.map.domain.Region;
import com.dnd.dndtravel.map.domain.VisitOpacity;
import com.dnd.dndtravel.map.repository.MapRepository;
import com.dnd.dndtravel.map.service.dto.response.RegionResponse;
import org.junit.jupiter.api.DisplayNameGeneration;
import org.junit.jupiter.api.DisplayNameGenerator;
import org.junit.jupiter.api.extension.ExtendWith;
Expand All @@ -16,10 +14,11 @@
import org.mockito.Mock;
import org.mockito.junit.jupiter.MockitoExtension;

import com.dnd.dndtravel.map.domain.VisitOpacity;
import com.dnd.dndtravel.map.domain.Region;
import com.dnd.dndtravel.map.repository.MapRepository;
import com.dnd.dndtravel.map.service.dto.response.RegionResponse;
import java.util.List;
import java.util.stream.Stream;

import static org.assertj.core.api.Assertions.assertThat;
import static org.mockito.BDDMockito.given;

@DisplayNameGeneration(DisplayNameGenerator.ReplaceUnderscores.class)
@ExtendWith(MockitoExtension.class)
Expand Down

0 comments on commit d601d58

Please sign in to comment.