Skip to content
This repository has been archived by the owner on Apr 1, 2023. It is now read-only.

🌠 This template generates Go structures as a package for building event-driven applications

License

Notifications You must be signed in to change notification settings

spiral-modules/asyncapi-go-template

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AsyncAPI logo

release tests release license

Overview

This template generates Go structures as a package for building event-driven applications.

Template Output

The go code generated by this template has the following structure:

  • channels.gen.go - contains all the channels defined in the AsyncAPI document.
  • payloads.gen.go - contains all the payloads.
  • servers.gen.go - contains servers addresses.
  • version.gen.go - contains version constants.

Watch the example output in the example directory.

Technical requirements

How to use the template

This template must be used with the AsyncAPI Generator. You can find all available options here.

Run the following command to generate a Go package

$ npm install -g @asyncapi/generator
# clone this repository and navigate to this repository
$ ag ./example/asyncapi.yaml ./ -o ./example/generated -p packageName=your_go_package_name

Following are the options that can be passed to the generator

  1. packageName: name of the go package to be generated

Docker usage

Additionally, you can use the docker image:

Registry Image
GitHub Container Registry ghcr.io/spiral/asyncapi-go-template

Using the latest tag for the docker image is highly discouraged because of possible backward-incompatible changes during major upgrades. Please, use tags in X.Y.Z format

$ docker run --rm -u "$(id -u):$(id -g)" -v "${PWD}:/host:rw" -w "/host" \
    ghcr.io/spiral/asyncapi-go-template ./example/asyncapi.yaml @spiral/asyncapi-go-template \
      -o ./example/generated \
      -p packageName=your_go_package_name \
      --force-write

In addition, the docker image contains installed @asyncapi/markdown-template and @asyncapi/html-template. You can use them to generate documentation for your AsyncAPI document.

Template configuration

You can configure this template by passing different parameters in the Generator CLI: -p PARAM1_NAME=PARAM1_VALUE -p PARAM2_NAME=PARAM2_VALUE

Name Description Required Example
packageName Name for the generated Go package false asyncapi

Releasing

New versions publishing is very simple - just make required changes in this repository, update changelog file and "publish" new release using repo releases page.

Docker image & npm package will be build and published automatically.

New release will overwrite the latest docker image tag.

About

🌠 This template generates Go structures as a package for building event-driven applications

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published