Skip to content

greenhalos/j2asyncapi

Folders and files

NameName
Last commit message
Last commit date
Mar 21, 2022
Jan 28, 2022
Feb 11, 2022
Feb 18, 2022
Feb 18, 2022
Feb 18, 2022
Apr 11, 2022
Feb 16, 2022
Feb 9, 2022
Feb 9, 2022
Jan 28, 2022
Jan 28, 2022
Feb 9, 2022
Feb 3, 2022
Apr 5, 2022
Jan 30, 2022

Repository files navigation

j2asyncapi

A lib which helps you generate asyncapi.yaml from your Java code based on annotations.

How to use

  1. Include the dependencies in your pom.xml
<dependencies>
    <dependency>
        <groupId>lu.greenhalos</groupId>
        <artifactId>j2asyncapi-annotation</artifactId>
        <version>${j2asyncapi.version}</version>
    </dependency>

    <dependency>
        <groupId>lu.greenhalos</groupId>
        <artifactId>j2asyncapi-processor</artifactId>
        <version>${j2asyncapi.version}</version>
        <scope>test</scope>
    </dependency>
</dependencies>
  1. Copy this test from this Repository to your code base
  2. Change ExampleBaseApplication.class with a valid base class of yours e.g. your SpringBootApplication class with the main method.
  3. Change the constant DOCS_TARGET to your needs.
  4. Annotate a method which is a publisher e.g. a methode which is already annotated with @RabbitListener with the j2asyncapi annotation @AsyncApi:
class Listener {

    @AsyncApi(
            type = LISTENER, exchange = "exchange", routingKey = "routing.key", payload = ExampleListenerMessage.class,
            description = "Description explaining exactly what happens here"
    )
    @RabbitListener(queues = "${some.long.path.to.the.queue.name}")
    public void on(Message message) {
        // do your stuff
    }
}
  1. Run the copied test. The resulting asyncapi.yml is generated to your DOCS_TARGET.

How to build

🥁 it is a simple a running:

./mvnw clean verify # or install in case you want to publish it to you local .m2 repository

TODOS

  • @JsonIgnore
  • process java.util.Locale
  • Statistics about schemas