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

feat: Implement annotation processing #50

Merged
merged 8 commits into from
Apr 10, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions kotlin-asyncapi-annotation/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
<?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 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>

<parent>
<groupId>org.openfolder</groupId>
<artifactId>kotlin-asyncapi-parent</artifactId>
<version>2.1.4-SNAPSHOT</version>
</parent>

<artifactId>kotlin-asyncapi-annotation</artifactId>
<packaging>jar</packaging>

<name>Kotlin AsyncAPI Annotation</name>
<description>AsyncAPI annotations for meta-documentation</description>
</project>
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
package org.openfolder.kotlinasyncapi.annotation

@Target(AnnotationTarget.ANNOTATION_CLASS)
annotation class AsyncApiAnnotation
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.openfolder.kotlinasyncapi.annotation

annotation class CorrelationID(
val isDefault: kotlin.Boolean = false,
val location: String,
val description: String = ""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
package org.openfolder.kotlinasyncapi.annotation

annotation class ExternalDocumentation(
val isDefault: kotlin.Boolean = false,
val url: String,
val description: String = ""
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
package org.openfolder.kotlinasyncapi.annotation

annotation class Int(
val value: kotlin.Int = 0,
val isDefault: kotlin.Boolean = false
)

annotation class Boolean(
val value: kotlin.Boolean = false,
val isDefault: kotlin.Boolean = false
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package org.openfolder.kotlinasyncapi.annotation

import kotlin.reflect.KClass

@Target(
AnnotationTarget.CLASS,
AnnotationTarget.ANNOTATION_CLASS
)
@AsyncApiAnnotation
annotation class Schema(
val value: KClass<*> = Void::class,
val isDefault: kotlin.Boolean = false,
val title: String = "",
val description: String = "",
val default: String = "",
val readOnly: Boolean = Boolean(isDefault = true),
val writeOnly: Boolean = Boolean(isDefault = true),
val examples: Array<String> = [],
val contentEncoding: String = "",
val contentMediaType: String = "",
val type: String = "",
val enum: Array<String> = [],
val const: String = "",
val multipleOf: Int = Int(isDefault = true),
val maximum: Int = Int(isDefault = true),
val exclusiveMaximum: Int = Int(isDefault = true),
val minimum: Int = Int(isDefault = true),
val exclusiveMinimum: Int = Int(isDefault = true),
val maxLength: Int = Int(isDefault = true),
val minLength: Int = Int(isDefault = true),
val pattern: String = "",
val items: Array<Schema> = [],
val additionalItems: Array<Schema> = [],
val maxItems: Int = Int(isDefault = true),
val minItems: Int = Int(isDefault = true),
val uniqueItems: Boolean = Boolean(isDefault = true),
val contains: Array<Schema> = [],
val maxProperties: Int = Int(isDefault = true),
val minProperties: Int = Int(isDefault = true),
val required: Array<String> = [],
val properties: Array<SchemaMapEntry> = [],
val additionalProperties: Array<SchemaMapEntry> = [],
val patternProperties: Array<SchemaMapEntry> = [],
val dependencies: Array<SchemaMapEntry> = [],
val propertyNames: Array<Schema> = [],
val `if`: Array<Schema> = [],
val then: Array<Schema> = [],
val `else`: Array<Schema> = [],
val allOf: Array<Schema> = [],
val anyOf: Array<Schema> = [],
val oneOf: Array<Schema> = [],
val not: Array<Schema> = [],
val format: String = "",
val discriminator: String = "",
val externalDocs: ExternalDocumentation = ExternalDocumentation(isDefault = true, url = ""),
val deprecated: Boolean = Boolean(isDefault = true)
)

annotation class SchemaMapEntry(
val isDefault: kotlin.Boolean = true,
val key: String = "",
val value: Schema = Schema(isDefault = true)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
package org.openfolder.kotlinasyncapi.annotation

annotation class Tag(
val isDefault: kotlin.Boolean = false,
val name: String,
val description: String = "",
val externalDocs: ExternalDocumentation = ExternalDocumentation(isDefault = true, url = "")
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
package org.openfolder.kotlinasyncapi.annotation.channel

import org.openfolder.kotlinasyncapi.annotation.AsyncApiAnnotation

@Target(
AnnotationTarget.CLASS,
AnnotationTarget.ANNOTATION_CLASS
)
@AsyncApiAnnotation
annotation class Channel(
val value: String = "",
val isDefault: Boolean = false,
val description: String = "",
val servers: Array<String> = [],
val subscribe: Subscribe = Subscribe(isDefault = true),
val publish: Publish = Publish(isDefault = true),
val parameters: Array<Parameter> = [],
val bindings: ChannelBindings = ChannelBindings(isDefault = true)
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,121 @@
package org.openfolder.kotlinasyncapi.annotation.channel

import org.openfolder.kotlinasyncapi.annotation.Boolean
import org.openfolder.kotlinasyncapi.annotation.Int
import org.openfolder.kotlinasyncapi.annotation.Schema

annotation class ChannelBindings(
val isDefault: kotlin.Boolean = false,
val http: ChannelBinding.HTTP = ChannelBinding.HTTP(isDefault = true),
val ws: ChannelBinding.WebSockets = ChannelBinding.WebSockets(isDefault = true),
val kafka: ChannelBinding.Kafka = ChannelBinding.Kafka(isDefault = true),
val anypointmq: ChannelBinding.AnypointMQ = ChannelBinding.AnypointMQ(isDefault = true),
val amqp: ChannelBinding.AMQP = ChannelBinding.AMQP(isDefault = true),
val amqp1: ChannelBinding.AMQP1 = ChannelBinding.AMQP1(isDefault = true),
val mqtt: ChannelBinding.MQTT = ChannelBinding.MQTT(isDefault = true),
val mqtt5: ChannelBinding.MQTT5 = ChannelBinding.MQTT5(isDefault = true),
val nats: ChannelBinding.NATS = ChannelBinding.NATS(isDefault = true),
val jms: ChannelBinding.JMS = ChannelBinding.JMS(isDefault = true),
val sns: ChannelBinding.SNS = ChannelBinding.SNS(isDefault = true),
val solace: ChannelBinding.Solace = ChannelBinding.Solace(isDefault = true),
val sqs: ChannelBinding.SQS = ChannelBinding.SQS(isDefault = true),
val stomp: ChannelBinding.STOMP = ChannelBinding.STOMP(isDefault = true),
val redis: ChannelBinding.Redis = ChannelBinding.Redis(isDefault = true),
val mercure: ChannelBinding.Mercure = ChannelBinding.Mercure(isDefault = true),
val ibmmq: ChannelBinding.IBMMQ = ChannelBinding.IBMMQ(isDefault = true)
)

sealed interface ChannelBinding {

annotation class AnypointMQ(
val isDefault: kotlin.Boolean = false,
val destination: String = "",
val destinationType: String = "",
val bindingVersion: String = ""
)

annotation class AMQP(
val isDefault: kotlin.Boolean = false,
val `is`: String = "",
val bindingVersion: String = "",
val exchange: AMQPExchange = AMQPExchange(isDefault = true),
val queue: AMQPQueue = AMQPQueue(isDefault = true)
)

annotation class AMQPExchange(
val isDefault: kotlin.Boolean = false,
val name: String = "",
val type: String = "",
val durable: Boolean = Boolean(isDefault = true),
val autoDelete: Boolean = Boolean(isDefault = true),
val vhost: String = ""
)

annotation class AMQPQueue(
val isDefault: kotlin.Boolean = false,
val name: String = "",
val type: String = "",
val durable: Boolean = Boolean(isDefault = true),
val exclusive: Boolean = Boolean(isDefault = true),
val autoDelete: Boolean = Boolean(isDefault = true),
val vhost: String = ""
)

annotation class IBMMQ(
val isDefault: kotlin.Boolean = false,
val destinationType: String = "",
val bindingVersion: String = "",
val maxMsgLength: Int = Int(isDefault = true),
val queue: IBMMQQueue = IBMMQQueue(isDefault = true, objectName = ""),
val topic: IBMMQTopic = IBMMQTopic(isDefault = true)
)

annotation class IBMMQQueue(
val isDefault: kotlin.Boolean = false,
val objectName: String,
val isPartitioned: Boolean = Boolean(isDefault = true),
val exclusive: Boolean = Boolean(isDefault = true)
)

annotation class IBMMQTopic(
val isDefault: kotlin.Boolean = false,
val string: String = "",
val objectName: String = "",
val durablePermitted: Boolean = Boolean(isDefault = true),
val lastMsgRetained: Boolean = Boolean(isDefault = true)
)

annotation class WebSockets(
val isDefault: kotlin.Boolean = false,
val method: String = "",
val bindingVersion: String = "",
val query: Schema = Schema(isDefault = true),
val headers: Schema = Schema(isDefault = true)
)

annotation class HTTP(val isDefault: kotlin.Boolean = false)

annotation class Kafka(val isDefault: kotlin.Boolean = false)

annotation class AMQP1(val isDefault: kotlin.Boolean = false)

annotation class MQTT(val isDefault: kotlin.Boolean = false)

annotation class MQTT5(val isDefault: kotlin.Boolean = false)

annotation class NATS(val isDefault: kotlin.Boolean = false)

annotation class JMS(val isDefault: kotlin.Boolean = false)

annotation class SNS(val isDefault: kotlin.Boolean = false)

annotation class Solace(val isDefault: kotlin.Boolean = false)

annotation class SQS(val isDefault: kotlin.Boolean = false)

annotation class STOMP(val isDefault: kotlin.Boolean = false)

annotation class Redis(val isDefault: kotlin.Boolean = false)

annotation class Mercure(val isDefault: kotlin.Boolean = false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
package org.openfolder.kotlinasyncapi.annotation.channel

import org.openfolder.kotlinasyncapi.annotation.AsyncApiAnnotation
import org.openfolder.kotlinasyncapi.annotation.CorrelationID
import org.openfolder.kotlinasyncapi.annotation.ExternalDocumentation
import org.openfolder.kotlinasyncapi.annotation.Schema
import org.openfolder.kotlinasyncapi.annotation.Tag
import kotlin.reflect.KClass

@Target(
AnnotationTarget.CLASS,
AnnotationTarget.ANNOTATION_CLASS
)
@AsyncApiAnnotation
annotation class Message(
val value: KClass<*> = Void::class,
val isDefault: Boolean = false,
val messageId: String = "",
val schemaFormat: String = "",
val contentType: String = "",
val name: String = "",
val title: String = "",
val summary: String = "",
val description: String = "",
val headers: Schema = Schema(isDefault = true),
val payload: Schema = Schema(isDefault = true),
val correlationId: CorrelationID = CorrelationID(isDefault = true, location = ""),
val tags: Array<Tag> = [],
val externalDocs: ExternalDocumentation = ExternalDocumentation(isDefault = true, url = ""),
val examples: Array<MessageExample> = [],
val bindings: MessageBindings = MessageBindings(isDefault = true),
val traits: Array<MessageTrait> = []
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,89 @@
package org.openfolder.kotlinasyncapi.annotation.channel

import org.openfolder.kotlinasyncapi.annotation.Int
import org.openfolder.kotlinasyncapi.annotation.Schema

annotation class MessageBindings(
val isDefault: Boolean = false,
val http: MessageBinding.HTTP = MessageBinding.HTTP(isDefault = true),
val ws: MessageBinding.WebSockets = MessageBinding.WebSockets(isDefault = true),
val kafka: MessageBinding.Kafka = MessageBinding.Kafka(isDefault = true),
val anypointmq: MessageBinding.AnypointMQ = MessageBinding.AnypointMQ(isDefault = true),
val amqp: MessageBinding.AMQP = MessageBinding.AMQP(isDefault = true),
val amqp1: MessageBinding.AMQP1 = MessageBinding.AMQP1(isDefault = true),
val mqtt: MessageBinding.MQTT = MessageBinding.MQTT(isDefault = true),
val mqtt5: MessageBinding.MQTT5 = MessageBinding.MQTT5(isDefault = true),
val nats: MessageBinding.NATS = MessageBinding.NATS(isDefault = true),
val jms: MessageBinding.JMS = MessageBinding.JMS(isDefault = true),
val sns: MessageBinding.SNS = MessageBinding.SNS(isDefault = true),
val solace: MessageBinding.Solace = MessageBinding.Solace(isDefault = true),
val sqs: MessageBinding.SQS = MessageBinding.SQS(isDefault = true),
val stomp: MessageBinding.STOMP = MessageBinding.STOMP(isDefault = true),
val redis: MessageBinding.Redis = MessageBinding.Redis(isDefault = true),
val mercure: MessageBinding.Mercure = MessageBinding.Mercure(isDefault = true),
val ibmmq: MessageBinding.IBMMQ = MessageBinding.IBMMQ(isDefault = true)
)

sealed interface MessageBinding {

annotation class HTTP(
val isDefault: Boolean = false,
val headers: Schema = Schema(isDefault = true),
val bindingVersion: String = ""
)

annotation class Kafka(
val isDefault: Boolean = false,
val key: Schema = Schema(isDefault = true),
val bindingVersion: String = ""
)

annotation class AnypointMQ(
val isDefault: Boolean = false,
val headers: Schema = Schema(isDefault = true),
val bindingVersion: String = ""
)

annotation class AMQP(
val isDefault: Boolean = false,
val contentEncoding: String = "",
val messageType: String = "",
val bindingVersion: String = ""
)

annotation class MQTT(
val isDefault: Boolean = false,
val bindingVersion: String = ""
)

annotation class IBMMQ(
val isDefault: Boolean = false,
val type: String = "",
val headers: String = "",
val description: String = "",
val expiry: Int = Int(isDefault = true),
val bindingVersion: String = ""
)

annotation class WebSockets(val isDefault: Boolean = false)

annotation class AMQP1(val isDefault: Boolean = false)

annotation class MQTT5(val isDefault: Boolean = false)

annotation class NATS(val isDefault: Boolean = false)

annotation class JMS(val isDefault: Boolean = false)

annotation class SNS(val isDefault: Boolean = false)

annotation class Solace(val isDefault: Boolean = false)

annotation class SQS(val isDefault: Boolean = false)

annotation class STOMP(val isDefault: Boolean = false)

annotation class Redis(val isDefault: Boolean = false)

annotation class Mercure(val isDefault: Boolean = false)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
package org.openfolder.kotlinasyncapi.annotation.channel

annotation class MessageExample(
val isDefault: Boolean = false,
val headers: String = "",
val payload: String = "",
val name: String = "",
val summary: String = ""
)
Loading