Skip to content

Commit

Permalink
Merge pull request #4 from KTB-HACKATHON-TEAM-FLIGHT/chore/swagger-co…
Browse files Browse the repository at this point in the history
…nfig

Chore: 스웨거 및 기초 환경 설정
  • Loading branch information
Youthhing authored Sep 5, 2024
2 parents 91d7547 + f8938e7 commit d100c04
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 2 deletions.
1 change: 1 addition & 0 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ dependencies {
implementation 'org.springframework.boot:spring-boot-starter-validation'
implementation 'org.springframework.boot:spring-boot-starter-web'
implementation 'org.springframework.boot:spring-boot-starter-webflux'
implementation 'org.springdoc:springdoc-openapi-starter-webmvc-ui:2.2.0'

compileOnly 'org.projectlombok:lombok'
runtimeOnly 'com.mysql:mysql-connector-j'
Expand Down
27 changes: 27 additions & 0 deletions src/main/java/team/flight/backend/config/SwaggerConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package team.flight.backend.config;

import io.swagger.v3.oas.annotations.OpenAPIDefinition;
import io.swagger.v3.oas.annotations.info.Info;
import io.swagger.v3.oas.models.OpenAPI;
import io.swagger.v3.oas.models.servers.Server;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

@OpenAPIDefinition(
info = @Info(title = "Team-Flight API 명세서"
, description = "서버 api 문서입니다.", version = "v1")
)
@Configuration
public class SwaggerConfig {

@Value("${server.domain}")
private String serverDomain;

@Bean
public OpenAPI customOpenAPI() {
return new OpenAPI()
.addServersItem(new Server().url(serverDomain).description("Server Domain"))
.addServersItem(new Server().url("http://localhost:8080").description("Local Server"));
}
}
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package team.flight.backend.controller;

import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.PostMapping;
Expand All @@ -8,14 +10,16 @@
import team.flight.backend.dto.SessionIdResponse;
import team.flight.backend.service.UserService;

@Tag(name = "유저 API")
@RestController
@RequiredArgsConstructor
@RequestMapping("/api/users")
public class UserController {

private final UserService userService;

@PostMapping
@Operation(summary = "최초 세션 발급 요청 API", description = "사용자가 최초 세션ID를 발급 받는다.")
@PostMapping("/session")
public ResponseEntity<SessionIdResponse> createSessionId() {
return ResponseEntity.ok().body(SessionIdResponse.from(userService.createSessionId()));
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package team.flight.backend.global.exception;

import org.springframework.web.bind.annotation.RestControllerAdvice;
import org.springframework.web.servlet.mvc.method.annotation.ResponseEntityExceptionHandler;

@RestControllerAdvice
public class GlobalExceptionHandler extends ResponseEntityExceptionHandler {

}
5 changes: 4 additions & 1 deletion src/main/resources/application.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,7 @@ spring:

ai:
server:
endpoint: ${AI_SERVER_ENDPOINT}
endpoint: ${AI_SERVER_ENDPOINT}

server:
domain: ${SERVER_DOMAIN}

0 comments on commit d100c04

Please sign in to comment.