Tags
As Telosys aims to provide highly customizable models (and predefined annotations are usually not sufficient to handle all special cases) since version 3.3.0 "tags" have been added.
Tags are a very simple way to easily customize your models by adding as much additional information as you want.

Set tags in model

Each attribute can have 0 to N tags.
Like annotations, tags provide additional information usable during the code generation. But, unlike annotations, tags do not have predefined names. The user can define as many tags as he wants.
A tag is any name starting with "#" and optionally having a value. If the tag has a value then the value is defined between "(" and ")".
Examples of tags :
1
MyEntity {
2
id : int { @Id } ;
3
4
// tag "mytag" (without value) :
5
comment : string { #mytag } ;
6
7
// tag "OpenAPIFormat" with value :
8
val : long { #OpenAPIFormat(int64) } ;
9
10
}
Copied!

Use tags in templates

In a template you can define conditions based on the presence (or absence) of a tag and you can retrieve the value of a tag.
To do this, use the following syntax:
  • $attrib.hasTag("tagName")
  • $attrib.tagValue("tagName")
Example : check tag presence and use its value if present
1
#if ( $attrib.hasTag("OpenAPIFormat") )
2
$attrib.tagValue("OpenAPIFormat")
3
#end
Copied!
Last modified 11mo ago