Skip to content

Commit

Permalink
Feat/echo server (#5)
Browse files Browse the repository at this point in the history
* add swagger & ktlinter

* /api/echo/{input} echo server
  • Loading branch information
endermaru authored Dec 25, 2024
1 parent 98030cd commit fa987fa
Show file tree
Hide file tree
Showing 9 changed files with 86 additions and 43 deletions.
45 changes: 26 additions & 19 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,39 +1,46 @@
plugins {
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
id("org.springframework.boot") version "3.4.1"
id("io.spring.dependency-management") version "1.1.7"
kotlin("jvm") version "1.9.25"
kotlin("plugin.spring") version "1.9.25"
id("org.springframework.boot") version "3.4.1"
id("io.spring.dependency-management") version "1.1.7"
id("org.jlleitschuh.gradle.ktlint") version "12.1.2"
}

group = "com.ToyProject"
version = "0.0.1-SNAPSHOT"

java {
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
toolchain {
languageVersion = JavaLanguageVersion.of(17)
}
}

repositories {
mavenCentral()
mavenCentral()
}

dependencies {
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
developmentOnly("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")
implementation("org.springframework.boot:spring-boot-starter-web")
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")
implementation("org.jetbrains.kotlin:kotlin-reflect")
developmentOnly("org.springframework.boot:spring-boot-devtools")
testImplementation("org.springframework.boot:spring-boot-starter-test")
testImplementation("org.jetbrains.kotlin:kotlin-test-junit5")
testRuntimeOnly("org.junit.platform:junit-platform-launcher")

implementation("org.hibernate.validator:hibernate-validator:8.0.0.Final")
testImplementation("org.glassfish:jakarta.el:5.0.0-M1")

implementation("org.springframework.boot:spring-boot-starter")
implementation("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.6.0")
}

kotlin {
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
compilerOptions {
freeCompilerArgs.addAll("-Xjsr305=strict")
}
}

tasks.withType<Test> {
useJUnitPlatform()
useJUnitPlatform()
}
6 changes: 6 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,12 @@ services:
SPRING_DATASOURCE_USERNAME: user
SPRING_DATASOURCE_PASSWORD: somepassword
SPRING_JPA_HIBERNATE_DDL_AUTO: update

SPRING_DOC_SWAGGER_UI_ENABLED: "true"
SPRING_DOC_SWAGGER_UI_PATH: "/swagger-ui"
SPRING_DOC_API_DOCS_ENABLED: "true"
SPRING_DOC_API_DOCS_PATH: "/v3/api-docs"

ports:
- "8080:8080" # 컨테이너를 호스트에 연결
networks:
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
package com.ToyProject.__5_team1_server
package com.waffletoy.team1server

import org.springframework.boot.autoconfigure.SpringBootApplication
import org.springframework.boot.runApplication
Expand All @@ -7,5 +7,5 @@ import org.springframework.boot.runApplication
class Application

fun main(args: Array<String>) {
runApplication<Application>(*args)
runApplication<Application>(*args)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
package com.waffletoy.team1server.echoserver.controller

import com.waffletoy.team1server.echoserver.service.EchoService
import io.swagger.v3.oas.annotations.Operation
import io.swagger.v3.oas.annotations.Parameter
import org.springframework.web.bind.annotation.GetMapping
import org.springframework.web.bind.annotation.PathVariable
import org.springframework.web.bind.annotation.RequestParam
import org.springframework.web.bind.annotation.RestController

@RestController
class EchoController(
private val echoService: EchoService,
) {
@Operation(
summary = "Echo endpoint",
description = "문자열을 받아 대문자로 변환합니다.",
)
@GetMapping("/api/echo/{input}")
fun echo(
@Parameter(description = "대문자로 변환할 문자열")
@PathVariable(required = false) input: String?,
): String {
val value = input ?: "no input"
return echoService.convertToUpperCase(value)
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
package com.waffletoy.team1server.echoserver.service

import org.springframework.stereotype.Service

@Service
class EchoService {
fun convertToUpperCase(input: String): String {
return input.uppercase()
}
}
1 change: 0 additions & 1 deletion src/main/resources/application.properties

This file was deleted.

11 changes: 11 additions & 0 deletions src/main/resources/application.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
spring:
application:
name: team1server

springdoc:
swagger-ui:
enabled: ${SPRING_DOC_SWAGGER_UI_ENABLED:true}
path: ${SPRING_DOC_SWAGGER_UI_PATH:/swagger-ui}
api-docs:
enabled: ${SPRING_DOC_API_DOCS_ENABLED:true}
path: ${SPRING_DOC_API_DOCS_PATH:/v3/api-docs}
Original file line number Diff line number Diff line change
@@ -1,13 +1,11 @@
package com.ToyProject.__5_team1_server
package com.waffletoy.team1server

import org.junit.jupiter.api.Test
import org.springframework.boot.test.context.SpringBootTest

@SpringBootTest
class ApplicationTests {

@Test
fun contextLoads() {
}

@Test
fun contextLoads() {
}
}

0 comments on commit fa987fa

Please sign in to comment.