io.github.zenwave360:zenwave-code-generator-mojo

Extensible code generation framework for JSON/YAML models and specifications.


Keywords
api-first, asyncapi, code-generator, ddd, jdl, jhipster, openapi
License
MIT

Documentation

ZenWave SDK

ZW> Code Generator ZW> Code Generator

👉 ZenWave360 Helps You Create Software Easy to Understand

Maven Central GitHub release (latest by date) General Availability build coverage branches coverage GitHub

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

If you plan to use custom plugins you will need to use the command in the following format:

jbang alias add --name=zw  --force \
    -m=io.zenwave360.sdk.Main \
    --repos=mavencentral,snapshots=https://s01.oss.sonatype.org/content/repositories/snapshots \
    --deps=\
org.slf4j:slf4j-simple:1.7.36,\
io.github.zenwave360.zenwave-sdk.plugins:asyncapi-spring-cloud-streams3:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:asyncapi-jsonschema2pojo:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:openapi-spring-webtestclient:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:backend-application-default:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:zdl-to-openapi:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:zdl-to-asyncapi:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:jdl-to-asyncapi:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:zdl-to-markdown:1.4.0,\
io.github.zenwave360.zenwave-sdk.plugins:openapi-controllers:1.4.0
    io.github.zenwave360.zenwave-sdk:zenwave-sdk-cli:1.4.0

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

JBang will use you maven settings for repository resolution, but you can also specify a custom maven repository in the --repos option.

Features / Roadmap

  • 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
    • JDL Backend Application (flexible hexagonal architecture)
      • 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)
    • JDL 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...
    • JDL to Specs
      • JDL to OpenAPI
      • JDL 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

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
INFO Reflections - Reflections took 461 ms to scan 56 urls, producing 2393 keys and 11675 values
ZW> SDK (1.4.0)

Available plugins:

backend-application-default    io.zenwave360.sdk.plugins.BackendApplicationDefaultPlugin: Generates a full backend application using a flexible hexagonal architecture (1.4.0)
spring-cloud-streams3-adapters io.zenwave360.sdk.plugins.SpringCloudStreams3AdaptersPlugin: Generates tests for Spring Cloud Streams Consumers. (1.4.0)
jdl-to-asyncapi                io.zenwave360.sdk.plugins.JDLToAsyncAPIPlugin: Generates a full AsyncAPI definitions for CRUD operations from JDL models (1.4.0)
spring-webtestclient           io.zenwave360.sdk.plugins.SpringWebTestClientPlugin: Generates test for SpringMVC or Spring WebFlux using WebTestClient based on OpenAPI specification. (1.4.0)
fork-plugin                    io.zenwave360.sdk.plugins.ForkPlugin: Creates a new standalone maven module cloning an existing plugin (1.4.0)
jsonschema2pojo                io.zenwave360.sdk.plugins.AsyncApiJsonSchema2PojoPlugin: Generate Plain Old Java Objects from OpenAPI/AsyncAPI schemas or full JSON-Schema files (1.4.0)
openapi-controllers            io.zenwave360.sdk.plugins.OpenAPIControllersPlugin: Generates implementations based on ZDL models and OpenAPI definitions SpringMVC generated OpenAPI interfaces. (1.4.0)
openapi-to-jdl                 io.zenwave360.sdk.plugins.OpenAPIToJDLPlugin: Generates JDL model from OpenAPI schemas (1.4.0)
spring-cloud-streams3          io.zenwave360.sdk.plugins.SpringCloudStreams3Plugin: Generates strongly typed SpringCloudStreams3 producer/consumer classes for AsyncAPI (1.4.0)
zdl-to-openapi                 io.zenwave360.sdk.plugins.ZDLToOpenAPIPlugin: Generates a draft OpenAPI definitions from your ZDL entities and services. (1.4.0)
zdl-to-markdown                io.zenwave360.sdk.plugins.ZdlToMarkdownPlugin: Generates Markdown glossary from Zdl Models (1.4.0)
zdl-to-asyncapi                io.zenwave360.sdk.plugins.ZDLToAsyncAPIPlugin: Generates a draft AsyncAPI file with events from your ZDL services. (1.4.0)

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>

Available Plugins

Refer to individual plugin's documentation for more information:

Plugin Description Model Types
Backend Application Default Backend Application Default ZDL
AsyncAPI JSON Schema to POJO AsyncAPI JSON Schema to POJO AsyncAPI, JsonSchema
AsyncAPI to Spring Cloud Streams 3 AsyncAPI to Spring Cloud Streams 3 AsyncAPI, AVRO, JsonSchema
OpenAPI Controllers JDL 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
Java 2 JDL Reverse Engineering Java 2 JDL Reverse Engineering Java, JDL

Forking an Standard or Custom Plugin

One promise of ZenWave SDK is to be easily extensible and adaptable to your project or your organization needs and likes.

You can always fork an existing plugin with the following command:

jbang zw -p io.zenwave360.sdk.plugins.ForkPlugin -h
Option Description Type Default Values
targetFolder String
sourcePluginClassName Plugin Plugin class to fork String
targetPluginClassName New Plugin Plugin class. It will be used for class name, package and maven groupId. String
downloadURL Download URL for the source code of original plugin in zip format URL https://github.com/ZenWave360/zenwave-sdk/archive/refs/tags/v1.4.0.zip

Example:

jbang zw -p io.zenwave360.sdk.plugins.ForkPlugin \
            targetFolder=plugins/zdl-to-asyncapi \
            sourcePluginClassName=io.zenwave360.sdk.plugins.ZDLToOpenAPIPlugin \
            targetPluginClassName=io.zenwave360.sdk.plugins.ZDLToAsyncAPIPlugin
cd plugins/zdl-to-asyncapi
mvn clean install

Now you can add this jar to the list of available plugins in jbang install command

ZenWave SDK Documentation

Please refer to the documentation website for more information.