Skip to content

Commit 507996d

Browse files
committed
feat: Added AsyncAPI internal implementation
1 parent fe51942 commit 507996d

File tree

198 files changed

+8012
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

198 files changed

+8012
-0
lines changed
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
name: springwolf-asyncapi
2+
3+
on:
4+
push:
5+
branches:
6+
- master
7+
pull_request:
8+
types: [ opened, synchronize, ready_for_review ]
9+
10+
jobs:
11+
build:
12+
13+
runs-on: ubuntu-latest
14+
timeout-minutes: 10
15+
16+
steps:
17+
- uses: actions/checkout@v4
18+
19+
- name: Set up JDK
20+
uses: actions/setup-java@v4
21+
with:
22+
distribution: 'temurin'
23+
java-version: '17'
24+
25+
- name: Setup Gradle
26+
uses: gradle/gradle-build-action@v2
27+
28+
- name: Check formatting (before running tests)
29+
run: ./gradlew -p springwolf-asyncapi spotlessCheck
30+
31+
- name: Build with Gradle
32+
run: ./gradlew -p springwolf-asyncapi build
33+
34+
- name: Publish package
35+
if: github.ref == 'refs/heads/master'
36+
run: ./gradlew -p springwolf-asyncapi publish
37+
env:
38+
ORG_GRADLE_PROJECT_SNAPSHOT: true
39+
40+
ORG_GRADLE_PROJECT_SIGNINGKEY: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGKEY}}
41+
ORG_GRADLE_PROJECT_SIGNINGPASSWORD: ${{secrets.ORG_GRADLE_PROJECT_SIGNINGPASSWORD}}
42+
43+
ORG_GRADLE_PROJECT_MAVEN_URL: https://s01.oss.sonatype.org/content/repositories/snapshots/
44+
ORG_GRADLE_PROJECT_MAVEN_USERNAME: ${{ secrets.MAVEN_USERNAME }}
45+
ORG_GRADLE_PROJECT_MAVEN_PASSWORD: ${{ secrets.MAVEN_PASSWORD }}

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
![Last Version](https://img.shields.io/github/tag-pre/springwolf/springwolf-core.svg)
66
[![License](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://opensource.org/licenses/Apache-2.0)
77
[![springwolf-core](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-core.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-core.yml)
8+
[![springwolf-asyncapi](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-asyncapi.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-asyncapi.yml)
89
[![springwolf-ui](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-ui.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-ui.yml)
910
[![springwolf-plugins](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-plugins.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-plugins.yml)
1011
[![springwolf-addons](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-addons.yml/badge.svg)](https://github.com/springwolf/springwolf-core/actions/workflows/springwolf-addons.yml)

build.gradle

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,7 @@ allprojects {
117117
}
118118

119119
var publishingEnabled = (
120+
project.name == 'springwolf-asyncapi' ||
120121
project.name == 'springwolf-core' ||
121122
project.name == 'springwolf-amqp' ||
122123
project.name == 'springwolf-cloud-stream' ||

settings.gradle

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,15 @@
1+
pluginManagement {
2+
plugins {
3+
id 'org.jetbrains.kotlin.jvm' version '1.9.21'
4+
}
5+
}
6+
plugins {
7+
id 'org.gradle.toolchains.foojay-resolver-convention' version '0.5.0'
8+
}
19
rootProject.name = 'springwolf-core'
210

311
include(
12+
'springwolf-asyncapi',
413
'springwolf-core',
514
'springwolf-plugins:springwolf-amqp-plugin',
615
'springwolf-plugins:springwolf-cloud-stream-plugin',

springwolf-asyncapi/README.md

Lines changed: 55 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,55 @@
1+
# Springwolf AsyncAPI
2+
3+
### About
4+
5+
This library provides a JVM-friendly binding to generate [AsyncAPI document](https://www.asyncapi.com/).
6+
It allows to create specifications for AsyncAPI from code.
7+
8+
Even when this library can be use by any JVM system, it's main goal is to support Springwolf-Core.
9+
10+
### Usage
11+
12+
Add the following dependencies and configuration class to enable this plugin.
13+
14+
#### Dependencies
15+
16+
```groovy
17+
dependencies {
18+
// Provides the JVM Builders to create an AsyncAPI Spec file
19+
implementation 'io.github.springwolf:springwolf-asyncapi:<springwolf-version>'
20+
}
21+
```
22+
23+
### Configuration class
24+
25+
```java
26+
AsyncAPI asyncAPI = AsyncAPI.builder()
27+
.info(Info.builder()
28+
.title("Account Service")
29+
.version("1.0.0")
30+
.description("This service is in charge of processing user signups")
31+
.build())
32+
.channels(Map.of(
33+
"userSignedup",
34+
Channel.builder().build()))
35+
.operations(Map.of(
36+
"sendUserSignedup",
37+
Operation.builder().build()))
38+
.build();
39+
```
40+
41+
## TODO:
42+
43+
* Test that the serialization is always respecting the case format
44+
* Test that the validations are applied
45+
* Finish to implement and test all the Bindings
46+
* Deserialize a JSON/YAML file to Java instances
47+
48+
## PENDING:
49+
50+
* [[Docs Bug 🐞 report]: JMS Server Binding Example doesn't match AsyncAPI v3 specification #232](https://github.com/asyncapi/bindings/issues/232) - In Review
51+
* [Confusing Operation Object Example #1007](https://github.com/asyncapi/spec/issues/1007) - In Review
52+
53+
## Convert AsyncAPI v2.x to v3.0.0
54+
55+
See https://github.com/asyncapi/converter-js#conversion-2xx-to-3xx

springwolf-asyncapi/build.gradle

Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
plugins {
2+
id 'java'
3+
id 'java-library'
4+
5+
id 'org.springframework.boot'
6+
id 'io.spring.dependency-management'
7+
id 'ca.cutterslade.analyze'
8+
}
9+
10+
dependencies {
11+
implementation "io.swagger.core.v3:swagger-core-jakarta:${swaggerVersion}"
12+
implementation "jakarta.validation:jakarta.validation-api"
13+
14+
implementation "com.fasterxml.jackson.core:jackson-core:${jacksonVersion}"
15+
implementation "com.fasterxml.jackson.core:jackson-annotations:${jacksonVersion}"
16+
implementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
17+
implementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"
18+
19+
compileOnly "org.projectlombok:lombok:${lombokVersion}"
20+
21+
annotationProcessor "org.projectlombok:lombok:${lombokVersion}"
22+
23+
testAnnotationProcessor "org.projectlombok:lombok:${lombokVersion}"
24+
25+
testImplementation "org.junit.jupiter:junit-jupiter-api:${junitJupiterVersion}"
26+
testImplementation "com.fasterxml.jackson.core:jackson-databind:${jacksonVersion}"
27+
testImplementation "com.fasterxml.jackson.dataformat:jackson-dataformat-yaml:${jacksonVersion}"
28+
testImplementation "io.swagger.core.v3:swagger-core-jakarta:${swaggerVersion}"
29+
testImplementation "net.javacrumbs.json-unit:json-unit-assertj:3.2.2"
30+
31+
testRuntimeOnly "org.junit.jupiter:junit-jupiter:${junitJupiterVersion}"
32+
}
33+
34+
jar {
35+
enabled = true
36+
archiveClassifier = ''
37+
}
38+
bootJar.enabled = false
39+
40+
java {
41+
withJavadocJar()
42+
withSourcesJar()
43+
}
44+
45+
publishing {
46+
publications {
47+
mavenJava(MavenPublication) {
48+
pom {
49+
name = 'springwolf-asyncapi'
50+
description = 'AsyncAPI schema generator'
51+
}
52+
}
53+
}
54+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package io.github.stavshamir.springwolf.asyncapi.core.v3.bindings;
3+
4+
import io.github.stavshamir.springwolf.asyncapi.core.v3.model.ExtendableObject;
5+
import lombok.EqualsAndHashCode;
6+
7+
/**
8+
* Describes AsyncAPI channel binding.
9+
*/
10+
@EqualsAndHashCode(callSuper = true)
11+
public abstract class ChannelBinding extends ExtendableObject {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package io.github.stavshamir.springwolf.asyncapi.core.v3.bindings;
3+
4+
import io.github.stavshamir.springwolf.asyncapi.core.v3.model.ExtendableObject;
5+
import lombok.EqualsAndHashCode;
6+
7+
@EqualsAndHashCode(callSuper = true)
8+
public class MessageBinding extends ExtendableObject {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package io.github.stavshamir.springwolf.asyncapi.core.v3.bindings;
3+
4+
import io.github.stavshamir.springwolf.asyncapi.core.v3.model.ExtendableObject;
5+
import lombok.EqualsAndHashCode;
6+
7+
/**
8+
* Describes AsyncAPI operation binding.
9+
*/
10+
@EqualsAndHashCode(callSuper = true)
11+
public abstract class OperationBinding extends ExtendableObject {}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
// SPDX-License-Identifier: Apache-2.0
2+
package io.github.stavshamir.springwolf.asyncapi.core.v3.bindings;
3+
4+
import io.github.stavshamir.springwolf.asyncapi.core.v3.model.ExtendableObject;
5+
import lombok.EqualsAndHashCode;
6+
7+
/**
8+
* Describes AsyncAPI operation binding.
9+
*/
10+
@EqualsAndHashCode(callSuper = true)
11+
public abstract class ServerBinding extends ExtendableObject {}

0 commit comments

Comments
 (0)