Skip to content

Commit 7ba4f7a

Browse files
authored
API Docs를 수정한다. (#55)
* fix * fix: doFirst * fix: remove gradle properties
1 parent afa84de commit 7ba4f7a

File tree

4 files changed

+47
-7
lines changed

4 files changed

+47
-7
lines changed

api/build.gradle.kts

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,6 @@
11
import com.epages.restdocs.apispec.gradle.OpenApi3Task
2+
import groovy.lang.Closure
3+
import io.swagger.v3.oas.models.servers.Server
24

35
plugins {
46
alias(libs.plugins.restdocs.api.spec)
@@ -47,17 +49,36 @@ tasks {
4749
finalizedBy(withType<OpenApi3Task>())
4850
}
4951

52+
withType<OpenApi3Task> {
53+
doFirst {
54+
val outputDir = file("src/main/resources/static/docs")
55+
if (!outputDir.exists()) {
56+
outputDir.mkdirs()
57+
}
58+
}
59+
}
60+
5061
jib {
5162
from {
5263
image = "amazoncorretto:21-alpine"
5364
}
5465
}
66+
}
5567

56-
openapi3 {
57-
title = "Gotchai API"
58-
version = "v1"
59-
format = "yml"
60-
outputFileNamePrefix = "api"
61-
outputDirectory = "src/main/resources/static/docs"
62-
}
68+
openapi3 {
69+
title = "Gotchai API"
70+
version = "v1"
71+
format = "yml"
72+
outputFileNamePrefix = "api"
73+
outputDirectory = "src/main/resources/static/docs"
74+
setServers(
75+
listOf(
76+
"https://dev-api.gotchai-ai.com",
77+
"http://localhost:8080",
78+
).map { url ->
79+
object : Closure<Server>(this) {
80+
fun doCall(): Server = Server().apply { this.url = url }
81+
}
82+
},
83+
)
6384
}

api/src/test/kotlin/com/gotchai/api/presentation/v1/exam/ExamControllerTest.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ import com.gotchai.domain.global.exception.NotFoundDataException
1818
import com.ninjasquad.springmockk.MockkBean
1919
import io.mockk.every
2020
import org.springframework.boot.test.autoconfigure.web.servlet.WebMvcTest
21+
import org.springframework.restdocs.payload.PayloadDocumentation.responseBody
2122
import org.springframework.test.web.reactive.server.expectBody
2223

2324
@WebMvcTest(ExamController::class)
@@ -49,6 +50,20 @@ class ExamControllerTest : ControllerTest() {
4950
}
5051
}
5152
}
53+
54+
context("시험 목록이 비어있는 경우") {
55+
every { examQueryUseCase.getExams() } returns emptyList()
56+
57+
it("상태 코드 200과 빈 리스트를 반환한다.") {
58+
webClient
59+
.get()
60+
.uri("/api/v1/exams")
61+
.exchange()
62+
.expectStatus()
63+
.isOk
64+
.expectBody<ApiResponse<ExamListResponse>>()
65+
}
66+
}
5267
}
5368

5469
describe("getExamById()는") {

api/src/testFixtures/kotlin/com/gotchai/api/docs/CommonDocs.kt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ val apiResponseFields =
99
fieldsOf(
1010
ApiResponse<*>::isSuccess bodyDesc "처리 성공 여부",
1111
ApiResponse<*>::status bodyDesc "상태 코드",
12+
ApiResponse<*>::data bodyDesc "응답 데이터",
1213
ApiResponse<*>::timestamp bodyDesc "타임 스탬프"
1314
)
1415

build.gradle.kts

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -77,4 +77,7 @@ subprojects {
7777
classpath += files(sourceSets.main.map { it.output })
7878
}
7979
}
80+
81+
82+
8083
}

0 commit comments

Comments
 (0)