Template Generator for Camunda 8 Connectors

We decided to share our template generator for Camunda 8 Connectors with the community.

The template generator automatically generates the element template JSON from the annotated Request class. We have to write much less code and everything is managed neatly in one place. It also helped us to speed up development because typos and schema violations are avoided.

Here you can find the project with a detailed description, an example, how to automate the generator with maven and much more.

Feedback and questions are welcome.

6 Likes

We are now available on maven central:

<dependency>
  <groupId>ch.brix.camunda.connector</groupId>
  <artifactId>connector-utils</artifactId>
  <version>1.0.0</version>
</dependency>

Hi @cma, very cool idea, just to check if I get it right, so the input is the request class written in Java, the class containing all the properties I need, and the output is the Json file (element template) that in turns defines a form. is that correct ?

Hi @g.manzano, yes that is correct. There are some other minor features, but I would consider the template generator to be the most valuable one. We tried to explain it in detail in the readme (link in first post).

You put the @TemplateDefinition annotation directly on the Request class and for each property you use the @PropertyDefinition annotation. Then the element-template.json can be generated automatically from those annotations (actually a model is created, which could be modified with a post processor and then this model is serialized to create the file). The whole schema should be covered. Especially useful with a good IDE, you see all possible options, default values and javadoc when adding the annotations and you don’t have to care about the schema, bindings, ids etc. any more. The switching back and forth between the files and the incredible amount of simple mistakes I made, drove me to the development of this project.

@cma Excellent, I will give it a try. Thanks for contributing

We noticed that most connectors have a dropdown to select the action (e.g. slack connector).
Then depending on the selected option a group of fields is displayed. If we implement this
using the template generator (or traditionally) we always have to repeat the condition and group.
Also it becomes hard to manage if there are a lot of actions and fields. So we added a new
feature to the template generator:

  • It is possible to specify choiceClasses, by default the properties in those classes are only visible if the corresponding choice is selected
  • Additionally choiceGroupNames can be specified, by default all the corresponding properties are added to a group created from the given name and choice value (group id)
  • The Deserializer lets us use our custom Gson instance exactly as before without any changes, even though the classes are nested

Now we can logically structure our connector which makes it easier to manage and we have to write even less code than before.

How are you using the template generator? Are there other features that would facilitate your work?