An enum type is a special data type that enables for a field to be a set of predefined constants.
Akwatype allows you to define enums that can then be used like any other type.
In the following example the size of the Pizza can only take the values small, medium and family
enum PizzaSize { small, medium, family }
type Pizza{ name:String size: PizzaSize }
For example, this will be translated into OpenAPI
Advanced enum definition
It is also possible to add properties to enum value. This can be useful, for example, when using Akwatype export for code generation, or if you wish to add a label for each value.
Standard enum value properties :
- label (String)
- short description of the value
- num (String)
- Integer value associated with enum value
- comment(String)
- Comment related to this value
example :
enum PizzaSize { small{ label:"Individual pizza" num:1 } medium{ label:"Pizza for 2 or 3 persons" num:2 } family{ label:"Pizza for up to 5 or 6 people" num:3 } }
type Pizza{ name:String size: PizzaSize }