Versions Compared

Key

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

...

Example AsyncAPI Document

View file
namekafka.yml
height250



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

...

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'


ZenWave 360

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.

With ZenWave's spring-cloud-streams3 and jsonschema2pojo sdk plugins you can generate:

  • Strongly typed business interfaces
  • Payload DTOs
  • Header objects from AsyncAPI definitions.
  • It uses Spring Cloud Streams, so it can connect to different brokers via provided binders.


Using the kafka.yml the pom.xml can be configured to create DTO's:

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.