Skip to content

Commit

Permalink
[#33] Springdoc OpenAPI 적용을 통한 API 문서화 (#34)
Browse files Browse the repository at this point in the history
  • Loading branch information
Srltas authored Oct 7, 2024
1 parent c126c51 commit 0daf894
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 1 deletion.
3 changes: 3 additions & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,9 @@ dependencies {
testImplementation 'org.springframework.boot:spring-boot-starter-test'
testRuntimeOnly 'org.junit.platform:junit-platform-launcher'

// OpenAPI
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0'

// Lombok
compileOnly 'org.projectlombok:lombok:1.18.34'
annotationProcessor 'org.projectlombok:lombok:1.18.34'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -13,19 +13,29 @@
import com.srltas.runtogether.application.port.in.NeighborhoodVerificationResponse;
import com.srltas.runtogether.application.port.in.NeighborhoodVerificationUseCase;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.Parameter;
import io.swagger.v3.oas.annotations.responses.ApiResponse;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;

@Tag(name = "동네 인증", description = "동네 인증과 관련된 API")
@RestController
@RequiredArgsConstructor
public class NeighborhoodVerificationController {

private final NeighborhoodVerificationUseCase neighborhoodVerificationUseCase;

@Operation(
summary = "동네 인증",
description = "사용자의 현재 위치를 기반으로 인증받고자 하는 동네 범위 안에 있는지 검증하고, 성공 시 해당 동네를 인증 동네로 등록합니다."
)
@ApiResponse(responseCode = "200", description = "동네 인증 성공")
@PostMapping("/neighborhood/verification")
public ResponseEntity<NeighborhoodVerificationResponse> verifyNeighborhood(
@RequestBody @Valid NeighborhoodVerificationRequest neighborhoodVerificationRequest,
@SessionAttribute(name = "login_user_id", required = false) Long userId) {
@Parameter(hidden = true) @SessionAttribute(name = "login_user_id", required = false) Long userId) {
NeighborhoodVerificationCommand neighborhoodVerificationCommand = toCommand(neighborhoodVerificationRequest);

NeighborhoodVerificationResponse response = neighborhoodVerificationUseCase.verifyAndRegisterNeighborhood(
Expand Down
20 changes: 20 additions & 0 deletions src/main/java/com/srltas/runtogether/config/OpenAPIConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
package com.srltas.runtogether.config;

import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.info.Info;

@Configuration
public class OpenAPIConfig {

@Bean
public OpenAPI openAPI() {
return new OpenAPI()
.info(new Info()
.title("Run Together API")
.description("Run Together 프로젝트에서 사용되는 API 명세서")
.version("0.0.1"));
}
}

0 comments on commit 0daf894

Please sign in to comment.