Skip to content

About

DDD and API-First tools for Event-Driven microservices. Create Software Easy to Understand.

Topics

Resources

Contributing

Stars

57 stars

Watchers

2 watching

Forks

Repository files navigation

ZenWave SDK

ZW> Code Generator ZW> Code Generator

👉 ZenWave360 Helps You Create Software Easy to Understand

Maven Central General Availability build coverage branches coverage GitHub

Note: Starting with version 2.0.0, the Maven groupId has changed to io.zenwave360. The code remains fully compatible. You can find Previous Releases Documentation here.

ZenWave SDK is a configurable and extensible toolkit for Domain Driven Design (DDD) and API-First that can generate code from a mix of different models including:

  • ZDL Domain Language
  • AsyncAPI
  • OpenAPI

Table of Contents:

JBang Instalation

The easiest way to install ZenWave SDK is as a JBang alias:

jbang alias add --fresh --force --name=zw release@zenwave360/zenwave-sdk

or if you prefer to use the latest snapshot versions:

jbang alias add --fresh --force --name=zw snapshots@zenwave360/zenwave-sdk

or if you prefer to use the next experimental/unstable snapshot versions:

jbang alias add --fresh --force --name=zw next@zenwave360/zenwave-sdk

Snapshots repository

ZenWave snapshots (-SNAPSHOT versions built from develop) are published to the Maven repository https://www.zenwave360.io/maven-snapshots/, served from zenwave360/maven-snapshots. The snapshots alias above already uses it.

To use snapshots from a Maven build, for example the zenwave-sdk-maven-plugin, add the repository to your pom.xml:

<repositories>
    <repository>
        <id>zenwave-snapshots</id>
        <url>https://www.zenwave360.io/maven-snapshots/</url>
        <releases><enabled>false</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </repository>
</repositories>
<pluginRepositories>
    <pluginRepository>
        <id>zenwave-snapshots</id>
        <url>https://www.zenwave360.io/maven-snapshots/</url>
        <releases><enabled>false</enabled></releases>
        <snapshots><enabled>true</enabled></snapshots>
    </pluginRepository>
</pluginRepositories>

And from Gradle:

repositories {
    mavenCentral()
    maven("https://www.zenwave360.io/maven-snapshots/") { mavenContent { snapshotsOnly() } }
}

If you plan to use custom plugins you can create your own jbang-catalog.json in the current folder where you want to use jbang zwor perform a custom instalation with a command in the following format:

jbang alias add --name=zw  --force \
    -m=io.zenwave360.sdk.Main \
    --repos=mavencentral,snapshots=https://www.zenwave360.io/maven-snapshots/ \
    --deps=\
org.slf4j:slf4j-simple:1.7.36,\
io.zenwave360.sdk.plugins:asyncapi-spring-cloud-streams3:2.4.0,\
io.zenwave360.sdk.plugins:asyncapi-jsonschema2pojo:2.4.0,\
io.zenwave360.sdk.plugins:avro-schema-compiler:2.4.0,\
org.apache.avro:avro-compiler:1.12.0,\
io.zenwave360.sdk.plugins:asyncapi-generator:2.4.0,\
io.zenwave360.sdk.plugins:openapi-spring-webtestclient:2.4.0,\
io.zenwave360.sdk.plugins:openapi-karate:2.4.0,\
io.zenwave360.sdk.plugins:backend-application-default:2.4.0,\
io.zenwave360.sdk.plugins.customizations:kotlin-backend-application:2.4.0,\
io.zenwave360.sdk.plugins:zdl-to-openapi:2.4.0,\
io.zenwave360.sdk.plugins:zdl-to-asyncapi:2.4.0,\
io.zenwave360.sdk.plugins:jdl-to-asyncapi:2.4.0,\
io.zenwave360.sdk.plugins:zdl-to-markdown:2.4.0,\
io.zenwave360.sdk.plugins:openapi-controllers:2.4.0
    io.zenwave360.sdk:zenwave-sdk-cli:2.4.0

Available Plugins

Refer to individual plugin's documentation for more information:

Plugin Description Model Types
Backend Application Default Backend Application Default ZDL
AsyncAPI Generator Generates full Java SDKs from AsyncAPI/Avro/JsonSchema AsyncAPI, Avro, JsonSchema
Avro Schema Generator AsyncAPI JSON Schema to POJO Avro
AsyncAPI JSON Schema to POJO AsyncAPI JSON Schema to POJO AsyncAPI, JsonSchema
AsyncAPI to Spring Cloud Streams 3 AsyncAPI to Spring Cloud Streams 3 (old, see AsyncAPI Generator) AsyncAPI, AVRO, JsonSchema
AsyncAPI to Terraform AsyncAPI to Terraform for Kafka and Schema Registry (LAB) AsyncAPI, AVRO
EventCatalog Generator EventCatalog Generator from OpenAPI, AsyncAPI, Markdown, ZDL OpenAPI, AsyncAPI, Markdown, ZDL
OpenAPI Controllers ZDL OpenAPI Controllers OpenAPI, ZDL
OpenAPI to Spring WebTestClient OpenAPI to Spring WebTestClient OpenAPI
ZDL to OpenAPI ZDL to OpenAPI and OpenAPI to ZDL ZDL, OpenAPI
ZDL to AsyncAPI ZDL to AsyncAPI ZDL, AsyncAPI
ZDL to Markdown ZDL to Markdown ZDL
DslDocs Multi-page Markdown documentation with Mermaid diagrams ZDL, ZFL, OpenAPI, AsyncAPI
Java 2 JDL Reverse Engineering Java 2 JDL Reverse Engineering Java, JDL
Java 2 AsyncAPI Reverse Engineering Java 2 AsyncAPI Reverse Engineering Java
MCP Server ZenWave MCP Server ZDL

ZenWave SDK Documentation

Please refer to the documentation website for more information.

Changelog

See CHANGELOG.md for an index of published release notes.

Features / Roadmap

This is the original roadmap, fully implemented some years/versions ago. It's kept here as a testimony of the fundational features included in ZenWave SDK.

  • ZenWave SDK CLI
    • Default parsers, processors, plugins, templating, formatters, writers, etc... for AsyncAPI, OpenAPI and JDL.
    • Help command: detailed, json, markdown, list of available plugins
    • Fork existing (custom or standard) plugin command
  • ZenWave SDK Maven Plugin
  • Standard Plugins
    • ZDL Backend Application (multiple architectures: hexagonal, layered, simple domain, modular monolith...)
      • Domain Entities
      • Inbound
        • Service Ports, DTOs, Mappers
        • Implementation for CRUD operations
        • Acceptance Tests: SpringData InMemory Repositories
      • Outbound: SpringData Repositories, ElasticSearch... (for REST or Async see other plugins)
      • Adapters:
        • Spring MVC
        • Spring WebFlux
      • Flavors
        • MongoDB
          • Imperative
          • Reactive
        • JPA
          • Imperative
          • Reactive
      • Unit/Integration Testing
        • Edge Integration Testing: partial spring-boot context for outbound adapters (with testcontainers)
        • Sociable Vertical Testing: manual dependency setup with in memory infrastructure test-doubles
        • Vertical Integration Testing: full spring-boot context for inbound adapters (with testcontainers)
    • ZDL OpenAPI Controllers
    • OpenAPI to Spring WebTestClient
    • AsyncAPI Spring Cloud Streams3
      • Consumer and Producer. Imperative and Reactive.
        • Business Exceptions Dead Letter Queues Routing
      • Producer with Transactional Outbox pattern
        • For MongoDB
        • For JDBC
      • Enterprise Envelop Pattern
      • Automatically fill headers at runtime from payload paths, tracing-id supplier...
    • ZDL to Specs
      • ZDL to OpenAPI
      • ZDL to AsyncAPI
        • AsyncAPI schemas
        • AVRO schemas
    • API Testing
    • Reverser Engineering
      • OpenAPI 2 JDL
      • Java 2 JDL
        • Spring Data MongoDB annotations
        • JPA annotations

Building from source

git clone https://github.com/ZenWave360/zenwave-sdk.git
cd zenwave-sdk
mvn clean install

Usage

Lint ZDL models

Lint is a regular plugin, with deterministic output for terminals, agents, and CI. One ZDL file per run:

jbang zw -p Lint zdlFile=<file.zdl> [format=text|json|sarif] [output=<file>] [strict=true]                  [root=<dir>] [linters=<Linter,...>]

Run jbang zw -p Lint -h for all options; like any plugin they can also be set in a zenwave-scripts .zw plugin block.

Text output uses file:line:column: severity ruleId message. JSON uses a versioned envelope (schemaVersion, tool, summary, diagnostics, and toolFailures when a linter failed) and SARIF output conforms to SARIF 2.1.0 with %SRCROOT% locations, rules[] derived from the reported rule ids and stable partial fingerprints. Positions are one-based; paths are relative to the working directory, or to root. The report goes to stdout, or to output= as UTF-8 (PowerShell 5.1 > writes UTF-16).

Exit codes (CLI-wide): 0 success; 1 findings (errors, or warnings with strict=true); 2 tool failure (invalid arguments, unreadable input, a failing linter, or any other exception). Plugins signal a code by throwing ZenWaveException(message, exitCode).

When run from the command line, System.out is redirected to stderr during plugin execution, so logs never pollute stdout: only deliberate results (the lint report, ZdlToJson, template stdout output) reach it.

linters is an ordered list of io.zenwave360.sdk.lint.Linter implementations (fully qualified names, or short names of built-ins such as ZdlProblems), loaded from the project classpath so custom linters can ship in jars added with --deps. The default set is: ZdlProblemsLinter (syntax and semantic problems, including lifecycle/transition states), ZdlReferencesLinter (unresolvable zdl/asyncapi clients), ZdlCallsLinter (@calls targets) and ZdlListenerLinter (@listener events, mixed @asyncapi/@listener bindings and required-input data-lineage warnings). Syntax errors are reported as a single problem and semantic linters are skipped after them. Presets are plugin subclasses of LintPlugin with a different default linters list.

Generate documentation

DslDocs generates a documentation index plus architecture, module, flow, OpenAPI and AsyncAPI pages from the files supplied. Every ZDL file is a separate module; OpenAPI and AsyncAPI files may be mixed because their kind is detected from their contents.

jbang zw -p DslDocs \
    zdlFiles=orders.zdl,payments.zdl \
    zflFiles=place-order.zfl \
    apiFiles=openapi.yml,asyncapi.yml \
    targetFolder=docs \
    title="Arcadia Editions"
Option Meaning
zdlFiles / zdlFile ZDL module files (comma-separated list or one-file shortcut)
zflFiles ZFL event-flow files, one page per file
apiFiles / apiFile Mixed OpenAPI and AsyncAPI files (comma-separated list or one-file shortcut)
targetFolder Output folder; defaults to docs
title, version, date Index-page metadata; title and version default from the first ZDL or API file
check Compare only; do not write files

Use check=true in CI to make stale committed documentation fail with exit code 1:

jbang zw -p DslDocs zdlFiles=orders.zdl,payments.zdl targetFolder=docs check=true

Generated pages are recognized by their marker, so hand-written Markdown in the output folder is preserved. A generated-page collision, missing/unknown input file, or an out-of-date check is exit code 1; unexpected tool failures are exit code 2.

Use the following jbang format:

jbang zw -p <pluginConfigClass or short-code> optionName=value optionName2=value

You can get a list of all available plugins:

 jbang zw -h list
Usage: <main class> [-f] [-h[=<helpFormat>]] [-p[=<pluginClass>]] [-d=<deps>[,
                    <deps>...]]... [-r=<repos>[,<repos>...]]...
                    [<String=Object>...]
      [<String=Object>...]
  -d, --deps=<deps>[,<deps>...]
                             Dependencies to include in classpath
  -f, --force                Force overwrite
  -h, --help[=<helpFormat>]  Help with output format
  -p, --plugin[=<pluginClass>]
                             Plugin Class or short-code
  -r, --repos=<repos>[,<repos>...]
                             Repositories to search for extra dependencies
INFO Reflections - Reflections took 3725 ms to scan 97 urls, producing 8936 keys and 63781 values
ZW> SDK (2.4.0)

Available plugins:

io.zenwave360.sdk.plugins.BackendApplicationDefaultPlugin: Generates a full backend application using the provided 'layout' property (2.4.0)
io.zenwave360.sdk.plugins.SpringCloudStreams3AdaptersPlugin: Generates Spring Cloud Streams Consumers from AsyncAPI definitions. (2.4.0)
io.zenwave360.sdk.plugins.JDLToAsyncAPIPlugin: Generates a full AsyncAPI definitions for CRUD operations from JDL models (2.4.0)
io.zenwave360.sdk.plugins.AsyncAPIGeneratorPlugin: Generates strongly typed SpringCloudStreams3 producer/consumer classes for AsyncAPI with Avro and JSON DTOs (2.4.0)
io.zenwave360.sdk.plugins.ZdlToJsonPlugin: Prints to StdOut ZDL Model as JSON (2.4.0)
io.zenwave360.sdk.plugins.SpringWebTestClientPlugin: Generates test for SpringMVC or Spring WebFlux using WebTestClient based on OpenAPI specification. (2.4.0)
io.zenwave360.sdk.plugins.AsyncApiJsonSchema2PojoPlugin: Generate Plain Old Java Objects from OpenAPI/AsyncAPI schemas or full JSON-Schema files. (2.4.0)
io.zenwave360.sdk.plugins.OpenAPIControllersPlugin: Generates implementations based on ZDL models and OpenAPI definitions SpringMVC generated OpenAPI interfaces. (2.4.0)
io.zenwave360.sdk.plugins.OpenAPIToJDLPlugin: Generates JDL model from OpenAPI schemas (2.4.0)
io.zenwave360.sdk.plugins.SpringCloudStreams3Plugin: Generates strongly typed SpringCloudStreams3 producer/consumer classes for AsyncAPI (2.4.0)
io.zenwave360.sdk.plugins.OpenAPIKaratePlugin: Generates test for KarateDSL based on OpenAPI specification. (2.4.0)
io.zenwave360.sdk.plugins.ZDLToOpenAPIPlugin: Generates a draft OpenAPI definitions from your ZDL entities and services. (2.4.0)
io.zenwave360.sdk.plugins.ZdlToMarkdownPlugin: Generates Markdown glossary from Zdl Models (2.4.0)
io.zenwave360.sdk.plugins.ZDLToAsyncAPIPlugin: Generates a draft AsyncAPI file with events from your ZDL services. (2.4.0)
io.zenwave360.sdk.plugins.AvroSchemaGeneratorPlugin: Generates Java classes from Avro schemas using Avro Compiler. (2.4.0)


Use: "jbang zw -p <plugin | short-code> -h" to get help on a specific plugin


Use: "jbang zw -p <plugin | short-code> -h" to get help on a specific plugin

You can include any custom plugin jars in the --deps option.

--deps is resolved by ZenWave using JBang's Maven resolver. Extra repositories come from, in order:

  1. zw --repos / -r (id=url or a JBang alias such as central)
  2. Silent JBang defaults: run.repos or repos in jbang.properties (project directory walking up, then ~/.jbang/jbang.properties)
  3. Active profile <repositories> from Maven settings.xml (~/.m2/settings.xml, then $MAVEN_HOME/conf/settings.xml)
  4. Maven Central is always included.

NOTE: settings.xml is read by MIMA, the same library JBang uses for mirrors and credentials. Profiles listed in <activeProfiles> and profiles marked <activeByDefault>true</activeByDefault> are both active. Maven itself would drop the activeByDefault ones once another profile is active.

You can still set extra repos without touching settings.xml:

jbang config set run.repos central,github=https://maven.pkg.github.com/OWNER/REPO

GitHub Packages requires authentication even for public packages. Use a ~/.m2/settings.xml <server> whose <id> matches the repo id (github in the examples above).

NOTE: it will list any available plugin, standard or custom, inside any of these root java packages "io", "com" or "org".

And get help for a given plugin:

jbang zw --help -p <pluginConfigClass>

You can add choose a help format from the following: help, detailed, markdown, or list:

jbang zw --help markdown -p <pluginConfigClass>

About

DDD and API-First tools for Event-Driven microservices. Create Software Easy to Understand.

Topics

Resources

Contributing

Stars

57 stars

Watchers

2 watching

Forks

Releases

Packages

Used by

Contributors

Languages