AsyncAPI β Java DTO Generator for Gradle
β
Multi-spec β
AsyncAPI v2.6/v3.0 β
Lombok β
Polymorphism β
Validation β
Enums with Descriptions
| Specification | Status | Notes |
|---|---|---|
| AsyncAPI v2.0 / v2.6 | β Full | Primary target |
| AsyncAPI v3.0 (RC) | β Experimental | Supports operations, channels, messages, payload: { schema: ... } |
| OpenAPI 3.x | β Not supported | Planned no earlier than 2026 |
π‘ Yojo is AsyncAPI-only. For OpenAPI, use OpenAPI Generator.
plugins {
id 'io.github.yojo-generator.gradle-plugin' version '1.0.3'
}plugins {
id("io.github.yojo-generator.gradle-plugin") version "1.0.3"
}yojo {
configurations {
create("main") {
specificationProperties {
register("api") {
specName("test.yaml")
inputDirectory(layout.projectDirectory.dir("contract").asFile.absolutePath)
outputDirectory(layout.buildDirectory.dir("generated/sources/yojo/com/example/api").get().asFile.absolutePath)
packageLocation("com.example.api")
}
register("one-more-api") {
specName("test.yaml")
inputDirectory(layout.projectDirectory.dir("contract").asFile.absolutePath)
outputDirectory(layout.buildDirectory.dir("generated/sources/yojo/oneMoreApi").get().asFile.absolutePath)
packageLocation("oneMoreApi")
}
}
springBootVersion("3.2.0")
lombok {
enable(true)
allArgsConstructor(true)
noArgsConstructor(true)
accessors {
enable(true)
fluent(false)
chain(true)
}
equalsAndHashCode {
enable(true)
callSuper(false)
}
}
}
}
}
sourceSets {
main.java.srcDir(layout.buildDirectory.dir("generated/sources/yojo"))
}
tasks.compileJava {
dependsOn("generateClasses")
}yojo {
configurations {
create("main") {
specificationProperties {
register("api") {
specName.set("api.yaml")
inputDirectory.set(layout.projectDirectory.dir("contract").asFile.absolutePath)
outputDirectory.set(layout.buildDirectory.dir("generated/sources/yojo/api/com/example/api").get().asFile.absolutePath)
packageLocation.set("com.example.api")
}
register("events-api") {
specName.set("events.yaml")
inputDirectory.set(layout.projectDirectory.dir("contract").asFile.absolutePath)
outputDirectory.set(layout.buildDirectory.dir("generated/sources/yojo/events").get().asFile.absolutePath)
packageLocation.set("events")
}
}
springBootVersion.set("3.2.0")
lombok {
enable.set(true)
allArgsConstructor.set(true)
noArgsConstructor.set(true)
accessors {
enable.set(true)
fluent.set(false)
chain.set(true)
}
equalsAndHashCode {
enable.set(true)
callSuper.set(false)
}
}
}
}
}
sourceSets {
main {
java {
srcDir(layout.buildDirectory.dir("generated/sources/yojo"))
}
}
}
tasks.compileJava {
dependsOn("generateClasses")
}β Output structure:
build/generated/sources/yojo/
βββ api/
β βββ common/ # DTOs, enums, interfaces
β βββ messages/ # message payloads
βββ events-api/ # same structure
| Attribute | Type | Description |
|---|---|---|
configurations |
NamedDomainObjectContainer<YojoConfig> |
Container for independent generation configs |
| Attribute | Type | Required | Description | Example |
|---|---|---|---|---|
specificationProperties |
NamedDomainObjectContainer<SpecificationProperties> |
β | List of AsyncAPI specs to generate | register("api") { ... } |
springBootVersion(...) |
String |
β | Selects jakarta (β₯3.0) or javax (β€2.7) validation |
springBootVersion("3.2.0") |
lombok { ... } |
closure | β | Lombok configuration | see below |
| Attribute | Type | Required | Description | Example |
|---|---|---|---|---|
specName(...) |
String |
β | Filename of AsyncAPI spec (.yaml, .yml) |
specName("asyncapi.yaml") |
inputDirectory(...) |
String |
β | Absolute path to spec directory | layout.projectDirectory.dir("contract").asFile.absolutePath |
outputDirectory(...) |
String |
β | Absolute path to output root | layout.buildDirectory.dir("generated/sources/yojo/api").get().asFile.absolutePath |
packageLocation(...) |
String |
β | Base Java package (without .common/.messages) |
packageLocation("com.example.api") |
π Generated packages:
com.example.api.common.*com.example.api.messages.*
| Attribute | Type | Default | Description | Java Effect |
|---|---|---|---|---|
enable(...) |
boolean |
true |
Enable Lombok annotations | @Data |
allArgsConstructor(...) |
boolean |
false |
Generate @AllArgsConstructor |
@AllArgsConstructor |
noArgsConstructor(...) |
boolean |
true |
Generate @NoArgsConstructor |
@NoArgsConstructor |
accessors { ... } |
closure | β | Configure @Accessors |
see below |
equalsAndHashCode { ... } |
closure | β | Configure @EqualsAndHashCode |
see below |
| Attribute | Type | Default | Description |
|---|---|---|---|
enable(...) |
boolean |
false |
Enable @Accessors |
fluent(...) |
boolean |
false |
fluent = true β obj.field(val) instead of obj.setField(val) |
chain(...) |
boolean |
false |
chain = true β setters return this |
β @Accessors(fluent = false, chain = true)
| Attribute | Type | Default | Description |
|---|---|---|---|
enable(...) |
boolean |
false |
Enable @EqualsAndHashCode |
callSuper(...) |
boolean |
null |
callSuper = true/false β @EqualsAndHashCode(callSuper = true) |
| Feature | YAML Example | β Java |
|---|---|---|
multipleOf: 0.01 |
multipleOf: 0.01 |
@Digits(integer = 1, fraction = 2) |
realization: ArrayList |
items: { ..., realization: ArrayList } |
List<T> field = new ArrayList<>(); |
Enum + x-enumNames |
x-enumNames: { SUCCESS: "Ok" } |
SUCCESS("Ok") + String getValue() |
| Enum case conversion | enum: [success-case, "\r\n"] |
SUCCESS_CASE, CARRIAGE_RETURN_LINE_FEED |
pathForGenerateMessage |
pathForGenerateMessage: 'io.github.events' |
package io.github.events; |
removeSchema: true |
payload: { $ref: X, removeSchema: true } |
Only fields in message, no X.java |
| Inheritance | extends: { fromClass: BaseEntity } |
class Dto extends BaseEntity { ... } |
| Interfaces | format: interface, methods: [...] |
interface Service { Type method(...); } |
format: existing |
format: existing, name: User, package: com.domain |
private User user; + import com.domain.User; |
| Feature | Status |
|---|---|
Jackson annotations (@JsonProperty, @JsonFormat) |
β In development |
| AsyncAPI spec validation (pre-generation) | β In development |
Lombok extensions (@Builder, @SuperBuilder) |
β In development |
| OpenAPI 3.1 support | π§ Planned Q2 2026 |
- Author: Vladimir Morozkin
- π§ Email:
jvmorozkin@gmail.com - π Telegram:
@vmorozkin - GitHub: yojo-generator/gradle-plugin
π Send your AsyncAPI spec β Iβll help you integrate.
π PRs and issues are welcome!
Distributed under the Apache License 2.0.
See LICENSE.md.
π AsyncAPI β Java β fast, precise, zero manual work.
Letβs generate some code!
