-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Add Spring Boot example application
- Loading branch information
1 parent
397f77c
commit 11220dd
Showing
9 changed files
with
219 additions
and
0 deletions.
There are no files selected for viewing
97 changes: 97 additions & 0 deletions
97
kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/pom.xml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>kotlin-asyncapi-examples</artifactId> | ||
<groupId>org.openfolder</groupId> | ||
<version>3.0.3-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>kotlin-asyncapi-spring-boot-example</artifactId> | ||
<packaging>jar</packaging> | ||
|
||
<name>Kotlin AsyncAPI Spring Boot Example</name> | ||
<description>Example for Kotlin AsyncAPI Spring Boot Application</description> | ||
|
||
<properties> | ||
<java.version>17</java.version> | ||
<kotlin.version>1.8.22</kotlin.version> | ||
<spring-boot.version>2.7.6</spring-boot.version> | ||
</properties> | ||
|
||
<dependencyManagement> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-dependencies</artifactId> | ||
<version>${spring-boot.version}</version> | ||
<type>pom</type> | ||
<scope>import</scope> | ||
</dependency> | ||
</dependencies> | ||
</dependencyManagement> | ||
|
||
<dependencies> | ||
<dependency> | ||
<groupId>org.openfolder</groupId> | ||
<artifactId>kotlin-asyncapi-spring-web</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-web</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>com.fasterxml.jackson.module</groupId> | ||
<artifactId>jackson-module-kotlin</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-reflect</artifactId> | ||
</dependency> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-stdlib</artifactId> | ||
</dependency> | ||
|
||
<dependency> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-starter-test</artifactId> | ||
<scope>test</scope> | ||
</dependency> | ||
</dependencies> | ||
|
||
<build> | ||
<sourceDirectory>${project.basedir}/src/main/kotlin</sourceDirectory> | ||
<testSourceDirectory>${project.basedir}/src/test/kotlin</testSourceDirectory> | ||
<plugins> | ||
<plugin> | ||
<groupId>org.springframework.boot</groupId> | ||
<artifactId>spring-boot-maven-plugin</artifactId> | ||
<version>${spring-boot.version}</version> | ||
</plugin> | ||
<plugin> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-plugin</artifactId> | ||
<configuration> | ||
<jvmTarget>17</jvmTarget> | ||
<args> | ||
<arg>-Xjsr305=strict</arg> | ||
</args> | ||
<compilerPlugins> | ||
<plugin>spring</plugin> | ||
</compilerPlugins> | ||
</configuration> | ||
<dependencies> | ||
<dependency> | ||
<groupId>org.jetbrains.kotlin</groupId> | ||
<artifactId>kotlin-maven-allopen</artifactId> | ||
<version>${kotlin.version}</version> | ||
</dependency> | ||
</dependencies> | ||
</plugin> | ||
</plugins> | ||
</build> | ||
</project> |
24 changes: 24 additions & 0 deletions
24
...ple/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/AsyncApiConfiguration.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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") | ||
} | ||
} | ||
} | ||
} |
9 changes: 9 additions & 0 deletions
9
...-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ChatMessage.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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 | ||
) |
13 changes: 13 additions & 0 deletions
13
...xample/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/ExampleApplication.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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<String>) { | ||
runApplication<ExampleApplication>(*args) | ||
} |
39 changes: 39 additions & 0 deletions
39
...-boot-example/src/main/kotlin/org/openfolder/kotlinasyncapi/example/spring/RoomChannel.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -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() | ||
} |
2 changes: 2 additions & 0 deletions
2
...-asyncapi-examples/kotlin-asyncapi-spring-boot-example/src/main/resources/application.yml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
asyncapi: | ||
enabled: true |
13 changes: 13 additions & 0 deletions
13
...-asyncapi-spring-boot-example/src/test/kotlin/com/example/demo/ExampleApplicationTests.kt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,13 @@ | ||
package com.example.demo | ||
|
||
import org.junit.jupiter.api.Test | ||
import org.springframework.boot.test.context.SpringBootTest | ||
|
||
@SpringBootTest | ||
class ExampleApplicationTests { | ||
|
||
@Test | ||
fun contextLoads() { | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
<?xml version="1.0" encoding="UTF-8"?> | ||
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" | ||
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd"> | ||
<modelVersion>4.0.0</modelVersion> | ||
|
||
<parent> | ||
<artifactId>kotlin-asyncapi-parent</artifactId> | ||
<groupId>org.openfolder</groupId> | ||
<version>3.0.3-SNAPSHOT</version> | ||
</parent> | ||
|
||
<artifactId>kotlin-asyncapi-examples</artifactId> | ||
<packaging>pom</packaging> | ||
|
||
<name>Kotlin AsyncAPI Examples</name> | ||
<description>Example applications for Kotlin AsyncAPI</description> | ||
|
||
<modules> | ||
<module>kotlin-asyncapi-spring-boot-example</module> | ||
</modules> | ||
</project> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters