Skip to content

Commit

Permalink
feat: swagger
Browse files Browse the repository at this point in the history
  • Loading branch information
jbj338033 committed Aug 1, 2024
1 parent 4ac5914 commit d20d7c7
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import net.dv8tion.jda.api.JDA
import org.springframework.boot.context.event.ApplicationStartedEvent
import org.springframework.context.ApplicationListener
import org.springframework.stereotype.Component
import java.time.Instant

@Component
class StartListener(
Expand All @@ -16,6 +17,7 @@ class StartListener(
EmbedBuilder()
.setTitle("서버가 시작되었습니다.")
.setColor(0x00FF00)
.setTimestamp(Instant.now())
.build()
)?.queue()
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
package com.open3r.openmusic.global.config.discord

import net.dv8tion.jda.api.EmbedBuilder
import net.dv8tion.jda.api.JDA
import org.springframework.context.ApplicationListener
import org.springframework.context.event.ContextClosedEvent
import org.springframework.stereotype.Component
import java.time.Instant

@Component
class StopListener(
private val jda: JDA,
private val discordProperties: DiscordProperties
): ApplicationListener<ContextClosedEvent> {
override fun onApplicationEvent(event: ContextClosedEvent) {
jda.getTextChannelById(discordProperties.channelId)?.sendMessageEmbeds(
EmbedBuilder()
.setTitle("서버가 종료되었습니다.")
.setColor(0xFF0000)
.setTimestamp(Instant.now())
.build()
)?.queue()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import io.swagger.v3.oas.models.info.Info
import io.swagger.v3.oas.models.info.License
import io.swagger.v3.oas.models.security.SecurityRequirement
import io.swagger.v3.oas.models.security.SecurityScheme
import io.swagger.v3.oas.models.servers.Server
import org.springframework.context.annotation.Bean
import org.springframework.context.annotation.Configuration
import org.springframework.http.HttpHeaders
Expand Down Expand Up @@ -34,6 +35,7 @@ class SwaggerConfig {
)
.termsOfService("https://open3r.com/terms")
)
.servers(listOf(Server().apply { url = "https://api.openmusic.kr" }))
.addSecurityItem(SecurityRequirement().addList("Authorization"))
.components(
Components()
Expand Down

0 comments on commit d20d7c7

Please sign in to comment.