Skip to content

Commit

Permalink
๐Ÿ“docs: ๋ฌธ์„œ ์ˆ˜์ •
Browse files Browse the repository at this point in the history
- api ๊ฐ€์ด๋“œ ์ถ”๊ฐ€
  • Loading branch information
daehyeon authored and kohmlab committed Mar 8, 2023
1 parent c9f2786 commit 6562328
Showing 1 changed file with 304 additions and 0 deletions.
304 changes: 304 additions & 0 deletions src/main/kotlin/com/nexters/pimo/feed/adapter/in/web/FeedRouter.kt
Original file line number Diff line number Diff line change
@@ -1,8 +1,24 @@
package com.nexters.pimo.feed.adapter.`in`.web

import com.nexters.pimo.common.dto.BaseResponse
import com.nexters.pimo.feed.adapter.`in`.web.dto.ContentInput
import com.nexters.pimo.feed.adapter.`in`.web.dto.FeedInput
import com.nexters.pimo.feed.application.dto.FeedDto
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import io.swagger.v3.oas.annotations.enums.ParameterIn
import io.swagger.v3.oas.annotations.media.ArraySchema
import io.swagger.v3.oas.annotations.media.Content
import io.swagger.v3.oas.annotations.media.Schema
import io.swagger.v3.oas.annotations.parameters.RequestBody
import io.swagger.v3.oas.annotations.responses.ApiResponse
import io.swagger.v3.oas.annotations.security.SecurityRequirement
import org.springdoc.core.annotations.RouterOperation
import org.springdoc.core.annotations.RouterOperations
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.MediaType
import org.springframework.web.bind.annotation.RequestMethod
import org.springframework.web.reactive.function.server.RouterFunction
import org.springframework.web.reactive.function.server.ServerResponse
import org.springframework.web.reactive.function.server.router
Expand All @@ -12,6 +28,294 @@ class FeedRouter (
private val feedHandler: FeedHandler
){
@Bean
@RouterOperations(
value = [
RouterOperation(
path = "/users/{userId}/feeds",
method = [RequestMethod.GET],
beanClass = FeedHandler::class,
beanMethod = "findByUserId",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํŠน์ • ์œ ์ €์˜ ํ”ผ๋“œ ๋ชฉ๋ก ์กฐํšŒ",
operationId = "findByUserId",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ”ผ๋“œ ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๋ ค๋Š” ์œ ์ €์˜ ID"
),
Parameter(name = "start", description = "ํŽ˜์ด์ง• ์‹œ์ž‘ Index (๋ฐ˜์˜์•ˆ๋จ)", example = "0"),
Parameter(name = "size", description = "ํŽ˜์ด์ง• ์กฐํšŒํ•  ๊ฐฏ์ˆ˜ (๋ฐ˜์˜์•ˆ๋จ)", example = "10")
],
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "ํ”ผ๋“œ ๋‚ด์šฉ",
responseCode = "200",
content = [Content(schema = Schema(implementation = FeedDto::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
RouterOperation(
path = "/users/{userId}/feeds/{feedId}",
method = [RequestMethod.GET],
beanClass = FeedHandler::class,
beanMethod = "findById",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํŠน์ • ํ”ผ๋“œ ์กฐํšŒ (1๊ฑด)",
operationId = "findById",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ”ผ๋“œ ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๋ ค๋Š” ์œ ์ €์˜ ID"
),
Parameter(
name = "feedId",
`in` = ParameterIn.PATH,
description = "์กฐํšŒํ•˜๋ ค๋Š” ํ”ผ๋“œ์˜ ID"
),
],
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "ํ”ผ๋“œ ๋‚ด์šฉ",
responseCode = "200",
content = [Content(schema = Schema(implementation = FeedDto::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
RouterOperation(
path = "/users/{userId}/home",
method = [RequestMethod.GET],
beanClass = FeedHandler::class,
beanMethod = "home",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํ”ผ๋“œ ํ™ˆ ์กฐํšŒ",
operationId = "home",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ™ˆ์„ ์กฐํšŒํ•˜๋ ค๋Š” ์œ ์ €์˜ ID"
),
Parameter(name = "start", description = "ํŽ˜์ด์ง• ์‹œ์ž‘ Index (๋ฐ˜์˜์•ˆ๋จ)", example = "0"),
Parameter(name = "size", description = "ํŽ˜์ด์ง• ์กฐํšŒํ•  ๊ฐฏ์ˆ˜ (๋ฐ˜์˜์•ˆ๋จ)", example = "10")
],
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "ํ”ผ๋“œ ๋‚ด์šฉ",
responseCode = "200",
content = [Content(schema = Schema(implementation = FeedDto::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)

),
RouterOperation(
path = "/users/{userId}/feeds",
method = [RequestMethod.POST],
beanClass = FeedHandler::class,
beanMethod = "save",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํ”ผ๋“œ ์ €์žฅ",
operationId = "save",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ”ผ๋“œ๋ฅผ ์ €์žฅํ•˜๋ ค๋Š” ์œ ์ €์˜ id"
),
],
requestBody = RequestBody(
content = [Content(schema = Schema(implementation = FeedInput::class, required = true))]
),
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "์„ฑ๊ณต์‹œ true",
responseCode = "200",
content = [Content(schema = Schema(implementation = Boolean::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
RouterOperation(
path = "/users/{userId}/feeds/{feedId}",
method = [RequestMethod.PATCH],
beanClass = FeedHandler::class,
beanMethod = "update",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํ”ผ๋“œ ์ˆ˜์ • (์ด๋ฏธ์ง€ ๋ฐ ํ…์ŠคํŠธ ์ˆ˜์ •, ๋ณธ์ธ๊ฒƒ๋งŒ ์ˆ˜์ • ๊ฐ€๋Šฅ)",
operationId = "update",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "์ˆ˜์ •ํ•˜๋ ค๋Š” ํ”ผ๋“œ๋ฅผ ์†Œ์œ ํ•œ ์œ ์ €์˜ ID"
),
Parameter(
name = "feedId",
`in` = ParameterIn.PATH,
description = "์ˆ˜์ •ํ•˜๋ ค๋Š” ํ”ผ๋“œ์˜ ID"
),
],
requestBody = RequestBody(
content = [Content(array = ArraySchema(schema = Schema(implementation = ContentInput::class, required = true)))]
),
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "์ˆ˜์ •๋œ ํ”ผ๋“œ ์ •๋ณด",
responseCode = "200",
content = [Content(schema = Schema(implementation = FeedDto::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
RouterOperation(
path = "/users/{userId}/feeds/{feedId}",
method = [RequestMethod.DELETE],
beanClass = FeedHandler::class,
beanMethod = "delete",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํ”ผ๋“œ ์‚ญ์ œ (๋ณธ์ธ์˜ ํ”ผ๋“œ๋งŒ ์‚ญ์ œ ๊ฐ€๋Šฅ)",
operationId = "delete",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ”ผ๋“œ ๋ชฉ๋ก์„ ์กฐํšŒํ•˜๋ ค๋Š” ์œ ์ €์˜ ID"
),
Parameter(
name = "feedId",
`in` = ParameterIn.PATH,
description = "์‚ญ์ œํ•˜๋ ค๋Š” ํ”ผ๋“œ์˜ ID"
),
],
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "์„ฑ๊ณต์‹œ true",
responseCode = "200",
content = [Content(schema = Schema(implementation = Boolean::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
RouterOperation(
path = "/users/{userId}/feeds/{feedId}/clap",
method = [RequestMethod.POST],
beanClass = FeedHandler::class,
beanMethod = "clap",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํ”ผ๋“œ ๋ฐ•์ˆ˜ ์ถ”๊ฐ€",
operationId = "clap",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ”ผ๋“œ์— ๋ฐ•์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜๋Š” ์ฃผ์ฒด์˜ userId"
),
Parameter(
name = "feedId",
`in` = ParameterIn.PATH,
description = "๋ฐ•์ˆ˜๋ฅผ ์ถ”๊ฐ€ํ•˜๋ ค๋Š” ํ”ผ๋“œ์˜ ID"
),
],
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "์„ฑ๊ณต์‹œ true",
responseCode = "200",
content = [Content(schema = Schema(implementation = Boolean::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
RouterOperation(
path = "/users/{userId}/feeds/{feedId}/reports",
method = [RequestMethod.POST],
beanClass = FeedHandler::class,
beanMethod = "report",
operation = Operation(
tags = ["ํ”ผ๋“œ ๊ด€๋ฆฌ"],
summary = "ํ”ผ๋“œ ์‹ ๊ณ  (์‹ ๊ณ ํ•œ ํ”ผ๋“œ์— ๋Œ€ํ•œ ๋ณ„๋„ ์ฒ˜๋ฆฌ๋Š” ์—†์Œ)",
operationId = "report",
parameters = [
Parameter(
name = "userId",
`in` = ParameterIn.PATH,
description = "ํ”ผ๋“œ ์‹ ๊ณ ํ•˜๋Š” ์ฃผ์ฒด์˜ userId"
),
Parameter(
name = "feedId",
`in` = ParameterIn.PATH,
description = "์‹ ๊ณ ํ•˜๋ ค๋Š” ํ”ผ๋“œ์˜ ID"
),
],
responses = [
ApiResponse(
responseCode = "0",
description = "๊ณตํ†ต Response",
content = [Content(schema = Schema(implementation = BaseResponse::class))]
),
ApiResponse(
description = "์„ฑ๊ณต์‹œ true",
responseCode = "200",
content = [Content(schema = Schema(implementation = Boolean::class))]
)
],
security = [SecurityRequirement(name = "Bearer Authentication")]
)
),
]
)
fun feedRouterFunction(): RouterFunction<ServerResponse> =
router{
accept(MediaType.APPLICATION_JSON).nest {
Expand Down

0 comments on commit 6562328

Please sign in to comment.