All Projects → asyncapi → java-spring-template

asyncapi / java-spring-template

Licence: other
Java Spring template for the AsyncAPI Generator

Programming Languages

java
68154 projects - #9 most used programming language
javascript
184084 projects - #8 most used programming language

Projects that are alternatives of or similar to java-spring-template

go-watermill-template
Go template for the AsyncAPI Generator using Watermill module
Stars: ✭ 38 (-7.32%)
Mutual labels:  asyncapi
Spec
The AsyncAPI specification allows you to create machine-readable definitions of your asynchronous APIs.
Stars: ✭ 1,860 (+4436.59%)
Mutual labels:  asyncapi
modelina
Library for generating data models based on inputs such as AsyncAPI, OpenAPI, or JSON Schema documents.
Stars: ✭ 55 (+34.15%)
Mutual labels:  asyncapi
home
This is the home page for the API specification toolbox.
Stars: ✭ 16 (-60.98%)
Mutual labels:  asyncapi
boats
Beautiful Open Api Template System
Stars: ✭ 28 (-31.71%)
Mutual labels:  asyncapi
nodejs-template
Node.js template for the AsyncAPI Generator
Stars: ✭ 19 (-53.66%)
Mutual labels:  asyncapi
nestjs-asyncapi
Async API module for Nestjs that provides documentation generation using your existing code (similar to Nestjs swagger module)
Stars: ✭ 22 (-46.34%)
Mutual labels:  asyncapi
wsapix
Next generation Websocket framework for nodejs
Stars: ✭ 17 (-58.54%)
Mutual labels:  asyncapi
python-paho-template
Python Paho template for the AsyncAPI generator
Stars: ✭ 17 (-58.54%)
Mutual labels:  asyncapi
event-gateway
AsyncAPI Event Gateway
Stars: ✭ 35 (-14.63%)
Mutual labels:  asyncapi
html-template
HTML template for AsyncAPI Generator
Stars: ✭ 38 (-7.32%)
Mutual labels:  asyncapi
java-spring-cloud-stream-template
Java Spring Cloud Stream template for the AsyncAPI Generator
Stars: ✭ 26 (-36.59%)
Mutual labels:  asyncapi
jasyncapi
/jay-sync-api/ is a Java code-first tool for AsyncAPI specification
Stars: ✭ 29 (-29.27%)
Mutual labels:  asyncapi
asynction
SocketIO python framework driven by the AsyncAPI specification. Built on top of Flask-SocketIO. Inspired by Connexion.
Stars: ✭ 40 (-2.44%)
Mutual labels:  asyncapi
openapi-filter
Filter internal paths, operations, parameters, schemas etc from OpenAPI/Swagger/AsyncAPI definitions
Stars: ✭ 112 (+173.17%)
Mutual labels:  asyncapi
nestjs-asyncapi
NestJS AsyncAPI module - generate the documentation of your event-based services using decorators
Stars: ✭ 88 (+114.63%)
Mutual labels:  asyncapi
parser-go
It parses AsyncAPI documents.
Stars: ✭ 43 (+4.88%)
Mutual labels:  asyncapi
converter-go
Convert AsyncAPI documents from older to newer versions with Golang
Stars: ✭ 17 (-58.54%)
Mutual labels:  asyncapi

Java Spring generator

All Contributors

Use your AsyncAPI definition to generate java code to subscribe and publish messages

Usage

AsyncAPI definitions

To have correctly generated code, your AsyncAPI file MUST define operationId for every operation.

In order for the generator to know what names to use for some parameters it's necessary to make use of AsyncAPI specification bindings.

  • Complete example for Kafka is here. Notice information about binding.
    channels:
      event.lighting.measured:
        publish:
          bindings:
            kafka:
              groupId: my-group
          message:
            $ref: '#/components/messages/lightMeasured'
        subscribe:
          message:
            $ref: '#/components/messages/lightMeasured'
  • Complete example for MQTT is here.

From the command-line interface (CLI)

  Usage: ag [options] <asyncapi> @asyncapi/java-spring-template

  Options:

    -V, --version                 output the version number
    -o, --output <outputDir>       directory where to put the generated files (defaults to current directory)
    -p, --param <name=value>       additional param to pass to templates
    -h, --help                    output usage information

Supported parameters

Name Description Required Default
disableEqualsHashCode Disable generation of equals and hashCode methods for model classes. No false
inverseOperations Generate an application that will publish messages to publish operation of channels and read messages from subscribe operation of channels. Literally this flag will simply swap publish and subscribe operations in the channels.
This flag will be useful when you want to generate a code of mock for your main application. Be aware, generation could be incomplete and manual changes will be required e.g. if bindings are defined only for case of main application.
No false
javaPackage The Java package of the generated classes. Alternatively you can set the specification extension info.x-java-package. If both extension and parameter are used, parameter has more priority. No com.asyncapi
listenerPollTimeout Only for Kafka. Timeout in ms to use when polling the consumer. No 3000
listenerConcurrency Only for Kafka. Number of threads to run in the listener containers. No 3
addTypeInfoHeader Only for Kafka. Add type information to message header. No true
connectionTimeout Only for MQTT. This value, measured in seconds, defines the maximum time interval the client will wait for the network connection to the MQTT server to be established. The default timeout is 30 seconds. A value of 0 disables timeout processing meaning the client will wait until the network connection is made successfully or fails. No 30
disconnectionTimeout Only for MQTT. The completion timeout in milliseconds when disconnecting. The default disconnect completion timeout is 5000 milliseconds. No 5000
completionTimeout Only for MQTT. The completion timeout in milliseconds for operations. The default completion timeout is 30000 milliseconds. No 30000
asyncapiFileDir Path where original AsyncAPI file will be stored. No src/main/resources/api/

Examples

The shortest possible syntax:

ag asyncapi.yaml @asyncapi/java-spring-template

Specify where to put the result and define poll timeout:

ag -o ./src asyncapi.yaml -p listenerPollTimeout=5000 @asyncapi/java-spring-template

If you don't have the AsyncAPI Generator installed, you can install it like this:

npm install -g @asyncapi/generator

Development

  1. Clone the repository:

    git clone https://github.com/asyncapi/java-spring-template
    cd java-spring-template
    
  2. Make sure template has all the dependencies:

    npm install
    
  3. Install AsyncAPI Generator:

    npm install -g @asyncapi/generator
    
  4. Run generation:

    # for MQTT protocol test with below
    ag tests/mocks/mqtt.yml ./ --output output
    # for Kafka protocol test with below
    ag tests/mocks/kafka.yml ./ --output output
  5. Explore generated files in output directory

For local development, you need different variations of this command. First of all, you need to know about three important CLI flags:

  • --debug enables the debug mode.
  • --watch-template enables a watcher of changes that you make in the template. It regenerates your template whenever it detects a change.
  • --install enforces reinstallation of the template.

Run it

Go to the root folder of the generated code and run this command (you need the JDK1.8):

./gradlew bootRun

Generated source contains RabbitMQ docker-compose. So you could use it to test amqp with:

docker-compose -f src/main/docker/rabbitmq.yml up -d

Missing features

See the list of features that are still missing in the component:

  • support of Kafka is done based on clear "spring-kafka" library without integration like for mqtt or amqp
  • generated code for protocol amqp could be out of date. Please have a look to application.yaml and AmqpConfig.java
  • tests for protocol amqp are not provided
  • add annotation to the model generation. Consider "@Valid", "@JsonProperty", "@Size", "@NotNull" e.t.c.
  • parameters for topics are not supported
  • server variables are not entirely supported
  • security schemas are not supported
  • traits are not supported
  • Json serializer/deserializer is used always, without taking into account real content type
  • client side generation mode (in general just flip subscribe and publish channels)
  • template generation of docker-compose depending on protocol of server, now the rabbitmq is hardcoded

If you want to help us develop them, feel free to contribute.

Contributors

Thanks goes to these wonderful people (emoji key):


Semen

📖 💻

Francesco Nobilia

👀

Amrut Prabhu

💻

This project follows the all-contributors specification. Contributions of any kind welcome!

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].