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# | Java | PHP | Python | Ruby | TS | Go |
---|
✔️ | ✔️ | ➖ | ✔️ | ✔️ | ✔️ | ➖ |
➖ 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 Models.ServerResponse PostStringEnumArray( List<Models.Days> days)
|
false | public Models.ServerResponse PostStringEnumArray(List<string> days)
|
Value | Change |
true (default) | public ServerResponse postStringEnumArray(final List<Days> days)
|
false | public ServerResponse postStringEnumArray(final List<String> days)
|
Value | Change |
true (default) | days = [ Days.SUNDAY, Days.MONDAY, Days.TUESDAY ] result = body_params_controller.send_string_enum_array(days)
|
false | days = [ 'Sunday', 'Monday', 'Tuesday' ] result = body_params_controller.send_string_enum_array(days)
|
Value | Change |
true (default) | async postStringEnumArray(days: Days[], requestOptions?: RequestOptions): Promise<ApiResponse<ServerResponse>>
|
false | async postStringEnumArray(days: string[], requestOptions?: RequestOptions): Promise<ApiResponse<ServerResponse>>
|
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# | Java | PHP | Python | Ruby | TS | Go |
---|
✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ | ✔️ |
Change in SDK
Configuring this setting has the following effect on the generated SDK:
- C#
- Java
- PHP
- Python
- Ruby
- TypeScript
- Go
Value | Change |
true (default) | var suites = new List<SuiteCodeEnum>(); suites.Add(SuiteCodeEnum.Hearts); try { ServerResponse result = await queryParamController.IntegerEnumArrayAsync(suites); } catch (ApiException e){};
|
false | var suites = new List<SuiteCode>(); suites.Add(SuiteCode.Hearts); try { ServerResponse result = await queryParamController.IntegerEnumArrayAsync(suites); } catch (ApiException e){}
|
Value | Change |
true (default) | List<SuiteCodeEnum> suites = new LinkedList<>(); suites.add(SuiteCodeEnum.HEARTS); queryParamController.integerEnumArrayAsync(suites).thenAccept(result -> { }).exceptionally(exception -> { return null; });
|
false | List<SuiteCode> suites = new LinkedList<>(); suites.add(SuiteCode.HEARTS); queryParamController.integerEnumArrayAsync(suites).thenAccept(result -> { }).exceptionally(exception -> { return null; });
|
Value | Change |
true (default) | $suites = [Models\SuiteCodeEnum::HEARTS]; $result = $queryParamController->integerEnumArray($suites);
|
false | $suites = [Models\SuiteCode::HEARTS]; $result = $queryParamController->integerEnumArray($suites);
|
Value | Change |
true (default) | suites = [SuiteCodeEnum.HEARTS] result = query_param_controller.integer_enum_array(suites)
|
false | suites = [SuiteCode.HEARTS] result = query_param_controller.integer_enum_array(suites)
|
Value | Change |
true (default) | suites = [SuiteCodeEnum::HEARTS] result = query_param_controller.integer_enum_array(suites)
|
false | suites = [SuiteCode::HEARTS] result = query_param_controller.integer_enum_array(suites)
|
Value | Change |
true (default) | const modelWorkingDays: DaysEnum[] = ['Thursday', 'Wednesday', 'Tuesday'];
|
false | const modelWorkingDays: Days[] = ['Thursday', 'Wednesday', 'Tuesday'];
|
Value | Change |
true (default) | days := []models.DaysEnum{ "Tuesday", "Saturday", "Wednesday" }
|
false | days := []models.Days{ "Tuesday", "Saturday", "Wednesday" }
|