diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/pom.xml b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/pom.xml new file mode 100644 index 0000000..433e5e3 --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/pom.xml @@ -0,0 +1,97 @@ + + + 4.0.0 + + + kotlin-asyncapi-examples + org.openfolder + 3.0.3-SNAPSHOT + + + kotlin-asyncapi-spring-boot-example + jar + + Kotlin AsyncAPI Spring Boot Example + Example for Kotlin AsyncAPI Spring Boot Application + + + 11 + 1.8.22 + 2.7.6 + + + + + + org.springframework.boot + spring-boot-dependencies + ${spring-boot.version} + pom + import + + + + + + + org.openfolder + kotlin-asyncapi-spring-web + + + + org.springframework.boot + spring-boot-starter-web + + + com.fasterxml.jackson.module + jackson-module-kotlin + + + org.jetbrains.kotlin + kotlin-reflect + + + org.jetbrains.kotlin + kotlin-stdlib + + + + org.springframework.boot + spring-boot-starter-test + test + + + + + ${project.basedir}/src/main/kotlin + ${project.basedir}/src/test/kotlin + + + org.springframework.boot + spring-boot-maven-plugin + ${spring-boot.version} + + + org.jetbrains.kotlin + kotlin-maven-plugin + + ${java.version} + + -Xjsr305=strict + + + spring + + + + + org.jetbrains.kotlin + kotlin-maven-allopen + ${kotlin.version} + + + + + + diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/AsyncApiConfiguration.kt b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/AsyncApiConfiguration.kt new file mode 100644 index 0000000..dbb5f02 --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/AsyncApiConfiguration.kt @@ -0,0 +1,24 @@ +package org.openfolder.kotlinasyncapi.example.spring + +import org.openfolder.kotlinasyncapi.springweb.service.AsyncApiExtension +import org.springframework.context.annotation.Bean +import org.springframework.context.annotation.Configuration + +@Configuration +internal class AsyncApiConfiguration { + + @Bean + fun asyncApiExtension() = AsyncApiExtension.builder { + info { + title("Gitter Streaming API") + version("1.0.0") + } + servers { + server("production") { + url("https://stream.gitter.im/v1") + protocol("https") + protocolVersion("1.1") + } + } + } +} diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ChatMessage.kt b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ChatMessage.kt new file mode 100644 index 0000000..d7d9459 --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ChatMessage.kt @@ -0,0 +1,9 @@ +package org.openfolder.kotlinasyncapi.example.spring + +import org.openfolder.kotlinasyncapi.annotation.channel.Message + +@Message +data class ChatMessage( + val id: String, + val text: String +) diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplication.kt b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplication.kt new file mode 100644 index 0000000..e249a5a --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplication.kt @@ -0,0 +1,13 @@ +package org.openfolder.kotlinasyncapi.example.spring + +import org.openfolder.kotlinasyncapi.springweb.EnableAsyncApi +import org.springframework.boot.autoconfigure.SpringBootApplication +import org.springframework.boot.runApplication + +@SpringBootApplication +@EnableAsyncApi +class ExampleApplication + +fun main(args: Array) { + runApplication(*args) +} diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/RoomChannel.kt b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/RoomChannel.kt new file mode 100644 index 0000000..350b1a4 --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/RoomChannel.kt @@ -0,0 +1,39 @@ +package org.openfolder.kotlinasyncapi.example.spring + +import org.openfolder.kotlinasyncapi.annotation.Schema +import org.openfolder.kotlinasyncapi.annotation.channel.Channel +import org.openfolder.kotlinasyncapi.annotation.channel.Message +import org.openfolder.kotlinasyncapi.annotation.channel.Parameter +import org.openfolder.kotlinasyncapi.annotation.channel.Subscribe +import org.springframework.stereotype.Component + +@Component +@Channel( + value = "/rooms/{roomId}", + parameters = [ + Parameter( + value = "roomId", + schema = Schema( + type = "string", + examples = [""""53307860c3599d1de448e19d""""] + ) + ) + ] +) +class RoomsChannel { + + @Subscribe( + messages = [ + Message(ChatMessage::class), + Message( + name = "heartbeat", + summary = "Its purpose is to keep the connection alive.", + payload = Schema( + type = "string", + enum = [""""\r\n""""], + ), + ), + ] + ) + fun publish(message: String): Nothing = TODO() +} diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/resources/application.yml b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/resources/application.yml new file mode 100644 index 0000000..80a9ec1 --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/resources/application.yml @@ -0,0 +1,2 @@ +asyncapi: + enabled: true diff --git a/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/test/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplicationTests.kt b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/test/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplicationTests.kt new file mode 100644 index 0000000..2c269a6 --- /dev/null +++ b/kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/test/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplicationTests.kt @@ -0,0 +1,12 @@ +package org.openfolder.kotlinasyncapi.example.spring + +import org.junit.jupiter.api.Test +import org.springframework.boot.test.context.SpringBootTest + +@SpringBootTest +class ExampleApplicationTests { + + @Test + fun contextLoads() { + } +} diff --git a/kotlin-asyncapi-examples/pom.xml b/kotlin-asyncapi-examples/pom.xml new file mode 100644 index 0000000..30d1ccc --- /dev/null +++ b/kotlin-asyncapi-examples/pom.xml @@ -0,0 +1,21 @@ + + + 4.0.0 + + + kotlin-asyncapi-parent + org.openfolder + 3.0.3-SNAPSHOT + + + kotlin-asyncapi-examples + pom + + Kotlin AsyncAPI Examples + Example applications for Kotlin AsyncAPI + + + kotlin-asyncapi-spring-boot-example + + diff --git a/pom.xml b/pom.xml index f4d132d..90d160c 100644 --- a/pom.xml +++ b/pom.xml @@ -44,6 +44,7 @@ kotlin-asyncapi-script kotlin-asyncapi-maven-plugin kotlin-asyncapi-annotation + kotlin-asyncapi-examples