Skip to main content

Enum

These CodeGen settings provide you with control over the generated enums within the SDKs.

Generate Enums​

This setting allows you to choose whether to include enums in the generated SDKs and docs or not. You can disable this setting to convert enums to native types.

If you choose to disable this setting, APIMatic CodeGen will not generate any Enum related code. Which means, all enum related requests and responses will have to be maintained manually.

Usage​

To use this feature, you need to specify a Boolean value. By default, its value is set to true.

"info": {
...,
"x-codegen-settings": {
"GenerateEnums": true
}
}

Language Support​

C#JavaPHPPythonRubyTSGo
✔️✔️➖✔️✔️✔️➖
note

➖ shows that in PHP and Go, this behavior is inherently supported by default and cannot be disabled.

Change in SDK​

Configuring this setting has the following effect on the generated SDK:

Value Change
true (default)
public ServerResponse postStringEnumArray(final List<Days> days)
false
public ServerResponse postStringEnumArray(final List<String> days)

Use Enum Prefix​

Enabling this setting will postfix each enum class with the word "Enum".

This setting is helpful in cases where in an OpenAPI specification, an API, endpoint, model, controller etc. might have the same name which can lead to confusion. So, to distinguish between them, you can use this setting to specify that this is an enum class. For example, an enum Days becomes DaysEnum.

Usage​

To use this feature, you need to specify a Boolean value. By default, its value is set to true.

"info": {
...,
"x-codegen-settings": {
"UseEnumPrefix": true
}
}

Language Support​

C#JavaPHPPythonRubyTSGo
✔️✔️✔️✔️✔️✔️✔️

Change in SDK​

Configuring this setting has the following effect on the generated SDK:

Value Change
true (default)
List<SuiteCodeEnum> suites = new LinkedList<>();
suites.add(SuiteCodeEnum.HEARTS);
queryParamController.integerEnumArrayAsync(suites).thenAccept(result -> {
// TODO success callback handler
}).exceptionally(exception -> {
// TODO failure callback handler
return null;
});
false
List<SuiteCode> suites = new LinkedList<>();
suites.add(SuiteCode.HEARTS);
queryParamController.integerEnumArrayAsync(suites).thenAccept(result -> {
// TODO success callback handler
}).exceptionally(exception -> {
// TODO failure callback handler
return null;
});