Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[refactor] Swagger UI 라이브러리 변경: Spring REST docs -> Springdoc #75

Merged
merged 15 commits into from
Jan 4, 2024
Merged
31 changes: 17 additions & 14 deletions build.gradle.kts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import com.epages.restdocs.apispec.gradle.OpenApi3Task
//import com.epages.restdocs.apispec.gradle.OpenApi3Task
import org.jetbrains.kotlin.gradle.tasks.KotlinCompile
import org.jooq.meta.jaxb.Logging
import org.springframework.boot.gradle.tasks.bundling.BootJar
Expand All @@ -7,7 +7,7 @@ plugins {
id("org.springframework.boot")
id("io.spring.dependency-management")
id("org.jlleitschuh.gradle.ktlint")
id("com.epages.restdocs-api-spec")
// id("com.epages.restdocs-api-spec")
id("nu.studer.jooq")
kotlin("jvm")
kotlin("plugin.spring")
Expand Down Expand Up @@ -53,6 +53,9 @@ dependencies {
implementation("org.springframework.boot:spring-boot-starter-validation")
implementation("org.springframework.boot:spring-boot-starter-web")

// springDoc
implementation ("org.springdoc:springdoc-openapi-starter-webmvc-ui:2.3.0")

// convert
implementation("com.fasterxml.jackson.module:jackson-module-kotlin")

Expand Down Expand Up @@ -137,18 +140,18 @@ tasks.register<Copy>("copyOasToSwagger") {
into("src/main/resources/static/swagger-ui/.")
dependsOn("openapi3")
}

dojinyou marked this conversation as resolved.
Show resolved Hide resolved
tasks.withType<OpenApi3Task> {
finalizedBy("copyOasToSwagger")
}

openapi3 {
setServer("http://localhost:8080")
title = "Eatda API Documentation"
description = "Eatda(잇다) 서비스의 API 명세서입니다."
version = "0.0.1"
format = "yaml"
}
//
//tasks.withType<OpenApi3Task> {
// finalizedBy("copyOasToSwagger")
//}

//openapi3 {
// setServer("http://localhost:8080")
// title = "Eatda API Documentation"
// description = "Eatda(잇다) 서비스의 API 명세서입니다."
// version = "0.0.1"
// format = "yaml"
//}

jacoco {
toolVersion = jacocoVersion
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
package com.mjucow.eatda.common.config

import org.springframework.context.annotation.Configuration
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class StaticRoutingConfiguration : WebMvcConfigurer {
override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/")
registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/static/swagger-ui/")
}
}
//package com.mjucow.eatda.common.config
//
//import org.springframework.context.annotation.Configuration
//import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry
//import org.springframework.web.servlet.config.annotation.WebMvcConfigurer
//
//@Configuration
//class StaticRoutingConfiguration : WebMvcConfigurer {
// override fun addResourceHandlers(registry: ResourceHandlerRegistry) {
// registry.addResourceHandler("/static/**").addResourceLocations("classpath:/static/")
// registry.addResourceHandler("swagger-ui.html").addResourceLocations("classpath:/static/swagger-ui/")
// }
//}
21 changes: 21 additions & 0 deletions src/main/kotlin/com/mjucow/eatda/common/config/SwaggerConfig.kt
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
package com.mjucow.eatda.common.config

import io.swagger.v3.oas.models.Components
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.servlet.config.annotation.ViewControllerRegistry
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer

@Configuration
class SwaggerConfig {
@Bean
fun swaggerApi(): OpenAPI = OpenAPI()
dojinyou marked this conversation as resolved.
Show resolved Hide resolved
.components(Components())
.info(Info()
.title("Eatda API Documentation")
.description("Eatda(잇다) 서비스의 API 명세서입니다.")
.version("0.0.1"))

}
11 changes: 9 additions & 2 deletions src/main/kotlin/com/mjucow/eatda/common/vo/Point.kt
Original file line number Diff line number Diff line change
@@ -1,10 +1,17 @@
package com.mjucow.eatda.common.vo

import io.swagger.v3.oas.annotations.media.Schema
import jakarta.persistence.Column
import jakarta.persistence.Embeddable

@Embeddable
data class Point(
@Column(name = "location_latitude") val latitude: Double,
@Column(name = "location_longitude") val longitude: Double,

@Column(name = "location_latitude")
@Schema(name = "latitude", example = "37.5802219")
val latitude: Double,

@Column(name = "location_longitude")
@Schema(name = "longitude", example = "126.9226047")
val longitude: Double,
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.mjucow.eatda.domain.banner.service.command.dto

import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant

data class CreateBannerCommand(
@Schema(name = "link", example = "https://career.programmers.co.kr/competitions/3353")
val link: String,
@Schema(name = "imageAddress", example = "banner/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.png")
val imageAddress: String,
@Schema(name = "expiredAt", example = "2023-11-21T14:11:34.639184Z")
val expiredAt: Instant? = null,
)
Original file line number Diff line number Diff line change
@@ -1,9 +1,13 @@
package com.mjucow.eatda.domain.banner.service.command.dto

import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant

data class UpdateBannerCommand(
@Schema(name = "link", example = "https://career.programmers.co.kr/competitions/3353")
val link: String,
@Schema(name = "imageAddress", example = "banner/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.png")
val imageAddress: String,
@Schema(name = "expiredAt", example = "2023-11-21T14:11:34.639184Z")
val expiredAt: Instant?,
)
Original file line number Diff line number Diff line change
@@ -1,13 +1,19 @@
package com.mjucow.eatda.domain.banner.service.query.dto

import com.mjucow.eatda.domain.banner.entity.Banner
import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant

data class BannerDto(
@Schema(name = "id", example = "1")
dojinyou marked this conversation as resolved.
Show resolved Hide resolved
val id: Long,
@Schema(name = "link", example = "https://career.programmers.co.kr/competitions/3353")
val link: String,
@Schema(name = "imageAddress", example = "banner/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.png")
val imageAddress: String,
@Schema(name = "expiredAt", example = "2023-11-21T14:11:34.639184Z")
val expiredAt: Instant?,
@Schema(name = "createdAt", example = "2023-11-20T14:11:52.114906Z")
val createdAt: Instant,
) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,10 @@
package com.mjucow.eatda.domain.notice.service.command.dto

import io.swagger.v3.oas.annotations.media.Schema

data class UpdateNoticeCommand(
@Schema(name = "title", example = "newTitle")
val title: String,
@Schema(name = "content", example = "newContent")
val content: String,
)
Original file line number Diff line number Diff line change
@@ -1,12 +1,17 @@
package com.mjucow.eatda.domain.notice.service.query.dto

import com.mjucow.eatda.domain.notice.entity.Notice
import io.swagger.v3.oas.annotations.media.Schema
import java.time.Instant

data class NoticeDto(
@Schema(name = "id", example = "1")
val id: Long,
@Schema(name = "title", example = "공지사항 제목")
val title: String,
@Schema(name = "content", example = "공지사항 내용")
val content: String,
@Schema(name = "createdAt", example = "2023-11-20T14:11:53.025126Z")
val createdAt: Instant,
) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,18 @@ import com.mjucow.eatda.common.vo.PhoneNumber
import com.mjucow.eatda.common.vo.Point
import com.mjucow.eatda.domain.poplarstore.entity.PopularStore
import com.mjucow.eatda.domain.store.entity.Store
import io.swagger.v3.oas.annotations.media.Schema

data class PopularStoreDto(
@Schema(name = "id", example = "3")
val id: Long,
@Schema(name = "displayedName", example = "명지대학교")
val displayedName: String,
@Schema(name = "address", example = "서울특별시 서대문구 거북골로 34")
val address: String,
@Schema(name = "phoneNumber", example = "02-300-1656")
@JsonUnwrapped val phoneNumber: PhoneNumber? = null,
@Schema(name = "imageAddress", example = "/eatda/public/store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.jpg")
val imageAddress: String? = null,
val location: Point? = null,
val count: Long,
dojinyou marked this conversation as resolved.
Show resolved Hide resolved
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
package com.mjucow.eatda.domain.poplarstore.service.dto


data class PopularStoreDtos(val popularStores: List<PopularStoreDto>)
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package com.mjucow.eatda.domain.store.service.command.dto

data class CreateCommand(val name: String)
import io.swagger.v3.oas.annotations.media.Schema

data class CreateCommand(
@Schema(description = "생성할 카테고리 이름", example = "validName")
val name: String)
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.mjucow.eatda.domain.store.service.command.dto

import io.swagger.v3.oas.annotations.media.Schema

data class MenuCreateCommand(
@Schema(name = "name", example = "고추바사삭")
val name: String,
@Schema(name = "price", example = "20000")
val price: Int,
@Schema(name = "imageAddress", example = "null")
val imageAddress: String? = null,
)
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
package com.mjucow.eatda.domain.store.service.command.dto

import io.swagger.v3.oas.annotations.media.Schema

data class MenuUpdateCommand(
@Schema(name = "name", example = "뿌링클")
val name: String,
@Schema(name = "price", example = "18000")
val price: Int,
@Schema(name = "imageAddress", example = "null")
val imageAddress: String? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ package com.mjucow.eatda.domain.store.service.command.dto

import com.mjucow.eatda.common.vo.PhoneNumber
import com.mjucow.eatda.common.vo.Point
import io.swagger.v3.oas.annotations.media.Schema

data class StoreCreateCommand(
@Schema(name = "name", example = "명지대학교")
val name: String,
@Schema(name = "address", example = "서울특별시 서대문구 거북골로 34")
val address: String,
@Schema(name = "displayName", example = "띵지대")
val displayName: String? = null,
@Schema(name = "phoneNumber", example = "02-123-4567")
val phoneNumber: PhoneNumber? = null,
@Schema(name = "imageAddress", example = "/eatda/public/store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.jpg")
val imageAddress: String? = null,
@Schema(name = "location", example = "null")
val location: Point? = null,
)
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,19 @@ package com.mjucow.eatda.domain.store.service.command.dto

import com.mjucow.eatda.common.vo.PhoneNumber
import com.mjucow.eatda.common.vo.Point
import io.swagger.v3.oas.annotations.media.Schema

data class StoreUpdateCommand(
@Schema(name = "Store Name", example = "명지대학교")
val name: String,
@Schema(name = "address", example = "서울특별시 서대문구 거북골로 34")
val address: String,
@Schema(name = "displayName", example = "띵지대")
val displayName: String?,
@Schema(name = "phoneNumber", example = "02-300-1656")
val phoneNumber: PhoneNumber?,
@Schema(name = "imageAddress", example = "/eatda/public/store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.jpg")
val imageAddress: String?,
@Schema(name = "location")
val location: Point?,
)
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
package com.mjucow.eatda.domain.store.service.command.dto

data class UpdateNameCommand(val name: String)
import io.swagger.v3.oas.annotations.media.Schema

data class UpdateNameCommand(
@Schema(name = "name", description = "수정할 카테고리 이름", example = "newName")
dojinyou marked this conversation as resolved.
Show resolved Hide resolved
val name: String)
Original file line number Diff line number Diff line change
@@ -1,11 +1,16 @@
package com.mjucow.eatda.domain.store.service.query

import com.mjucow.eatda.domain.store.entity.Menu
import io.swagger.v3.oas.annotations.media.Schema

data class MenuDto(
@Schema(name = "id", example = "25")
val id: Long,
@Schema(name = "name", example = "뿌링클")
val name: String,
@Schema(name = "price", example = "16000")
val price: Int,
@Schema(name = "imageAddress", example = "null")
val imageAddress: String? = null,
) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
package com.mjucow.eatda.domain.store.service.query.dto

import com.mjucow.eatda.domain.store.entity.Category
import io.swagger.v3.oas.annotations.media.Schema

data class CategoryDto(
@Schema(name = "id", description = "카테고리 식별자", example = "10")
val id: Long,
@Schema(name = "name", description = "카테고리 이름은 String 타입이어야 합니다.", example = "치킨")
val name: String,
) {
companion object {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ import com.fasterxml.jackson.annotation.JsonUnwrapped
import com.mjucow.eatda.common.vo.PhoneNumber
import com.mjucow.eatda.common.vo.Point
import com.mjucow.eatda.domain.store.entity.Store
import io.swagger.v3.oas.annotations.media.Schema

data class StoreDetailDto(
@Schema(name = "id", example = "5")
val id: Long,
@Schema(name = "displayedName", example = "명지대학교")
val displayedName: String,
@Schema(name = "address", example = "서울특별시 서대문구 거북골로 34")
val address: String,
@JsonUnwrapped val phoneNumber: PhoneNumber? = null,
@Schema(name = "phoneNumber", example = "02-300-1656")
@JsonUnwrapped
val phoneNumber: PhoneNumber? = null,
dojinyou marked this conversation as resolved.
Show resolved Hide resolved
@Schema(name = "imageAddress", example = "/eatda/public/store/232D8241-C6A9-4AD9-B0EA-56F6DD24BADF.jpg")
val imageAddress: String? = null,
val location: Point? = null,
@JsonUnwrapped val categories: Categories? = null,
Expand Down
Loading
Loading