Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

The AsyncAPI generator is a tool that generates anything you want using the AsyncAPI Document and Template that are supplied as inputs to the AsyncAPI CLI. The template can define code, documentation and diagrams among other things to be generated with the generator.

...


Servers

Code Block
languageyml
titleservers
servers:
  production:
    url: kafka.bootstrap:{port}
    protocol: kafka
    variables:
      port:
        default: '9092'
        enum:
          - '9092'
          - '9093'


Channels

A channel is a mechanism created by the server for the organization and transmission of messages. Users can define channels as a topic, queue, routing key, path, or subject depending on the protocol used.

Code Block
languageyml
titlechannels
channels:
  event.lighting.measured:
    publish:
      bindings:
        kafka:
          groupId: my-group
      operationId: readLightMeasurement
      message:
        $ref: '#/components/messages/lightMeasured'
    subscribe:
      operationId: updateLightMeasurement
      message:
        $ref: '#/components/messages/lightMeasured'

...


Example AsyncAPI Document

View file
namekafka.yml
height250

ZenWave SDK

ZenWave 360º is a set of tools built on the foundations of Domain Driven Design and API-First principles for Event-Driven Architectures, to help you create software easy to understand.

...

Code Block
 <plugin>
                <groupId>io.github.zenwave360.zenwave-sdk</groupId>
                <artifactId>zenwave-sdk-maven-plugin</artifactId>
                <version>1.3.5</version>
                <configuration>
                    <skip>false</skip>
                    <inputSpec>${project.basedir}/src/main/resources/asyncapi.yml</inputSpec>
                    <addCompileSourceRoot>true</addCompileSourceRoot>
                    <addTestCompileSourceRoot>true</addTestCompileSourceRoot>
                </configuration>
                <executions>
                    <execution>
                        <id>generate-asyncapi-dtos</id>
                        <phase>generate-sources</phase>
                        <goals>
                            <goal>generate</goal>
                        </goals>
                        <configuration>
                            <generatorName>jsonschema2pojo</generatorName>
                            <configOptions>
                                <jsonschema2pojo.removeOldOutput>true</jsonschema2pojo.removeOldOutput>
                                <jsonschema2pojo.useJakartaValidation>true</jsonschema2pojo.useJakartaValidation>
                                <modelPackage>com.example.asyncmethod.models</modelPackage>
                                <apiPackage>com.example.asyncmethod.api</apiPackage>
                                <jsonschema2pojo.useLongIntegers>true</jsonschema2pojo.useLongIntegers>
                            </configOptions>
                        </configuration>
                    </execution>
                </executions>
                <dependencies>
                    <dependency>
                        <groupId>io.github.zenwave360.zenwave-sdk.plugins</groupId>
                        <artifactId>asyncapi-spring-cloud-streams3</artifactId>
                        <version>1.3.5</version>
                    </dependency>
                    <dependency>
                        <groupId>io.github.zenwave360.zenwave-sdk.plugins</groupId>
                        <artifactId>asyncapi-jsonschema2pojo</artifactId>
                        <version>1.3.5</version>
                    </dependency>
                    <dependency>
                        <groupId>jakarta.validation</groupId>
                        <artifactId>jakarta.validation-api</artifactId>
                        <version>3.0.2</version>
                    </dependency>
                </dependencies>
            </plugin>


Problem

...

The useJakartaValidation configuration option does not appear to work. This results in generated code using javax.validation that does not always work with Java 17.


MultiAPI Generator