Skip to content

Commit

Permalink
Merge pull request #14 from mash-up-kr/yaeoni/swagger
Browse files Browse the repository at this point in the history
[feat] 스웨거 설정을 적용해요
  • Loading branch information
yaeoni authored Jun 29, 2024
2 parents 88ae9d2 + 6c81c6b commit 3374932
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
22 changes: 20 additions & 2 deletions api/src/main/kotlin/com/mashup/dojo/SampleController.kt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,11 @@ package com.mashup.dojo

import com.mashup.dojo.common.DojoApiResponse
import com.mashup.dojo.usecase.SampleUseCase
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.tags.Tag
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestMapping
import org.springframework.web.bind.annotation.RestController

Expand All @@ -11,8 +15,22 @@ import org.springframework.web.bind.annotation.RestController
class SampleController(
private val sampleUseCase: SampleUseCase,
) {
@GetMapping
fun test(): DojoApiResponse<Long> {
/**
* 스웨거 예시
* http://localhost:8080/swagger-ui/index.html
*/
@GetMapping("/{id}")
@Tag(name = "Sample", description = "Sample입니다.")
@Operation(
summary = "Sample API",
description = "Sample API 입니다요",
responses = [
ApiResponse(responseCode = "200", description = "샘플 API 성공하면 어쩌구 데이터가 내려갑니다.")
]
)
fun test(
@PathVariable id: Long,
): DojoApiResponse<Long> {
return DojoApiResponse.success(sampleUseCase.getSampleId())
}
}
1 change: 1 addition & 0 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ springBoot {
project(":api") {
dependencies {
api(project(":service"))
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.5.0")
implementation("org.springframework.boot:spring-boot-starter-web")
}
}
Expand Down

0 comments on commit 3374932

Please sign in to comment.