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

chore: Examples module #64

Merged
merged 10 commits into from
Oct 1, 2023
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>11</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>

Check warning on line 54 in kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/pom.xml

View workflow job for this annotation

GitHub Actions / Qodana

Library and maven plugin versions are different

Plugin version (1.8.22) is not the same as library version (null)
<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>

Check warning on line 75 in kotlin-asyncapi-examples/kotlin-asyncapi-spring-boot-example/pom.xml

View workflow job for this annotation

GitHub Actions / Qodana

Library and maven plugin versions are different

Plugin version (null) is not the same as library version (1.6.21)
<groupId>org.jetbrains.kotlin</groupId>
<artifactId>kotlin-maven-plugin</artifactId>
<configuration>
<jvmTarget>${java.version}</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>
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")
}
}
}
}
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
)
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)
}
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()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
asyncapi:
enabled: true
Original file line number Diff line number Diff line change
@@ -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() {
}
}
21 changes: 21 additions & 0 deletions kotlin-asyncapi-examples/pom.xml
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>
1 change: 1 addition & 0 deletions pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@
<module>kotlin-asyncapi-script</module>
<module>kotlin-asyncapi-maven-plugin</module>
<module>kotlin-asyncapi-annotation</module>
<module>kotlin-asyncapi-examples</module>
</modules>

<properties>
Expand Down
Loading