-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #17 from LeeSM0518/DVK-61-apply-swagger-to-categor…
…y-api [DVK-61] fix: 카테고리 API에 Swagger 적용
- Loading branch information
Showing
4 changed files
with
22 additions
and
21 deletions.
There are no files selected for viewing
18 changes: 4 additions & 14 deletions
18
src/main/kotlin/com/devooks/backend/category/v1/controller/CategoryController.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,31 +1,21 @@ | ||
package com.devooks.backend.category.v1.controller | ||
|
||
import com.devooks.backend.category.v1.dto.GetCategoriesRequest | ||
import com.devooks.backend.category.v1.dto.GetCategoriesResponse | ||
import com.devooks.backend.category.v1.dto.GetCategoriesResponse.Companion.toResponse | ||
import com.devooks.backend.category.v1.service.CategoryService | ||
import org.springframework.web.bind.annotation.GetMapping | ||
import org.springframework.web.bind.annotation.RequestMapping | ||
import org.springframework.web.bind.annotation.RequestParam | ||
import org.springframework.web.bind.annotation.RestController | ||
|
||
@RestController | ||
@RequestMapping("/api/v1/categories") | ||
class CategoryController( | ||
private val categoryService: CategoryService, | ||
) { | ||
): CategoryControllerDocs { | ||
|
||
@GetMapping | ||
suspend fun getCategories( | ||
@RequestParam(required = false, defaultValue = "") | ||
name: String, | ||
@RequestParam(required = false, defaultValue = "") | ||
page: String, | ||
@RequestParam(required = false, defaultValue = "") | ||
count: String, | ||
): GetCategoriesResponse { | ||
val request = GetCategoriesRequest(name, page, count) | ||
return categoryService.get(request).toResponse() | ||
override suspend fun getCategories(): GetCategoriesResponse { | ||
return categoryService.getAll().toResponse() | ||
} | ||
|
||
} | ||
} |
15 changes: 15 additions & 0 deletions
15
src/main/kotlin/com/devooks/backend/category/v1/controller/CategoryControllerDocs.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
package com.devooks.backend.category.v1.controller | ||
|
||
import com.devooks.backend.category.v1.dto.GetCategoriesResponse | ||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.responses.ApiResponse | ||
import io.swagger.v3.oas.annotations.responses.ApiResponses | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
|
||
@Tag(name = "카테고리 API") | ||
interface CategoryControllerDocs { | ||
|
||
@Operation(summary = "카테고리 목록 조회") | ||
@ApiResponses(value = [ApiResponse(responseCode = "200", description = "OK")]) | ||
suspend fun getCategories(): GetCategoriesResponse | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters