-
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 #13 from Nexters/feature/12-swagger-docs
[#12] Swagger docs 추가
- Loading branch information
Showing
9 changed files
with
102 additions
and
19 deletions.
There are no files selected for viewing
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
32 changes: 32 additions & 0 deletions
32
src/main/kotlin/nexters/weski/common/config/SwaggerConfig.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,32 @@ | ||
package nexters.weski.common.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 | ||
import org.springframework.web.filter.ForwardedHeaderFilter | ||
|
||
@Configuration | ||
class SwaggerConfig { | ||
@Bean | ||
fun openAPI(): OpenAPI { | ||
return OpenAPI() | ||
.info( | ||
Info() | ||
.title("We-ski API") | ||
.description("we-ski server API") | ||
.version("1.0.0") | ||
) | ||
.servers( | ||
listOf( | ||
io.swagger.v3.oas.models.servers.Server().url("http://localhost:8080"), | ||
io.swagger.v3.oas.models.servers.Server().url("http://223.130.154.51:8080") | ||
) | ||
) | ||
} | ||
|
||
@Bean | ||
fun forwardedHeaderFilter(): ForwardedHeaderFilter { | ||
return ForwardedHeaderFilter() | ||
} | ||
} |
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,16 @@ | ||
package nexters.weski.common.config | ||
|
||
import org.springframework.context.annotation.Configuration | ||
import org.springframework.web.servlet.config.annotation.CorsRegistry | ||
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer | ||
|
||
@Configuration | ||
class WebConfig : WebMvcConfigurer { | ||
|
||
override fun addCorsMappings(registry: CorsRegistry) { | ||
registry.addMapping("/**") | ||
.allowedOrigins("*") | ||
.allowedMethods("GET", "POST", "PUT", "DELETE") | ||
.allowedHeaders("*") | ||
} | ||
} |
8 changes: 5 additions & 3 deletions
8
src/main/kotlin/nexters/weski/ski_resort/SkiResortController.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
2 changes: 2 additions & 0 deletions
2
src/main/kotlin/nexters/weski/ski_resort/SkiResortResponseDto.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
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,17 +1,23 @@ | ||
package nexters.weski.slope | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.Parameter | ||
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 | ||
|
||
@Tag(name = "스키장 별 슬로프&웹캠 정보 API", description = "슬로프&웹캠 관련") | ||
@RestController | ||
@RequestMapping("/api/slopes") | ||
class SlopeController( | ||
private val slopeService: SlopeService | ||
) { | ||
@GetMapping("/{resortId}") | ||
fun getSlopesAndWebcams(@PathVariable resortId: Long): SlopeResponseDto { | ||
@Operation(summary = "특정 스키장의 슬로프와 웹캠 정보를 조회하는 API") | ||
@GetMapping("/api/slopes/{resortId}") | ||
fun getSlopesAndWebcams( | ||
@Parameter(description = "스키장 ID", example = "1") | ||
@PathVariable resortId: Long | ||
): SlopeResponseDto { | ||
return slopeService.getSlopesAndWebcams(resortId) | ||
} | ||
} |
24 changes: 18 additions & 6 deletions
24
src/main/kotlin/nexters/weski/snow_maker/SnowMakerController.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,20 +1,32 @@ | ||
package nexters.weski.snow_maker | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.Parameter | ||
import io.swagger.v3.oas.annotations.tags.Tag | ||
import org.springframework.web.bind.annotation.* | ||
|
||
@Tag(name = "스키장 설질 관련 API", description = "설질 투표와 현황 조회 API") | ||
@RestController | ||
@RequestMapping("/api/snow-maker") | ||
|
||
class SnowMakerController( | ||
private val snowMakerService: SnowMakerService | ||
) { | ||
@GetMapping("/{resortId}") | ||
fun getSnowMaker(@PathVariable resortId: Long): SnowMakerDto { | ||
@Operation(summary = "스키장 설질 정보 조회 API") | ||
@GetMapping("/api/snow-maker/{resortId}") | ||
fun getSnowMaker( | ||
@Parameter(description = "스키장 ID", example = "1") | ||
@PathVariable resortId: Long | ||
): SnowMakerDto { | ||
return snowMakerService.getSnowMaker(resortId) | ||
} | ||
|
||
@PostMapping("/{resortId}/vote") | ||
fun voteSnowMaker(@PathVariable resortId: Long, @RequestParam isPositive: Boolean) { | ||
@Operation(summary = "스키장 설질 투표 API") | ||
@PostMapping("/api/snow-maker/{resortId}/vote") | ||
fun voteSnowMaker( | ||
@Parameter(description = "스키장 ID", example = "1") | ||
@PathVariable resortId: Long, | ||
@Parameter(description = "설질의 긍정/부정 boolean value", example = "true") | ||
@RequestParam isPositive: Boolean | ||
) { | ||
snowMakerService.voteSnowMaker(resortId, isPositive) | ||
} | ||
} |
14 changes: 10 additions & 4 deletions
14
src/main/kotlin/nexters/weski/weather/WeatherController.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,17 +1,23 @@ | ||
package nexters.weski.weather | ||
|
||
import io.swagger.v3.oas.annotations.Operation | ||
import io.swagger.v3.oas.annotations.Parameter | ||
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 | ||
|
||
@Tag(name = "스키장 별 날씨 API", description = "스키장 별 날씨 상세 정보 API") | ||
@RestController | ||
@RequestMapping("/api/weather") | ||
class WeatherController( | ||
private val weatherService: WeatherService | ||
) { | ||
@GetMapping("/{resortId}") | ||
fun getWeatherByResortId(@PathVariable resortId: Long): WeatherDto? { | ||
@Operation(summary = "특정 스키장의 날씨 정보를 조회하는 API") | ||
@GetMapping("/api/weather/{resortId}") | ||
fun getWeatherByResortId( | ||
@Parameter(description = "스키장 ID", example = "1") | ||
@PathVariable resortId: Long | ||
): WeatherDto? { | ||
return weatherService.getWeatherByResortId(resortId) | ||
} | ||
} |
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