Configure CodeGen Settings
You can import your API definition file along with a Metadata file that will allow you to configure various CodeGen and import settings for your API. The details on the available code generation settings is available at Code Generation Settings. These can be specified in the form of an object as described below:
Code Generation Object
Name : CodeGenSettings
The available properties and their respective types are as follows:
Setting | Type | Purpose |
---|---|---|
SynchronyMode | Number. Could be 0 or 1. | 0 represents Asynchronous while 1 represents Synchronous. When Asynchronous, the CodeGen engine generates asynchronous C# and Java code. |
ArraySerialization | String | Array serialisation scheme for primitive types (applicable to form and query params). Allowed values are Indexed , UnIndexed , Plain , CSV , TSV , PSV |
UseHttpMethodPrefix | Boolean | When true, HTTP verbs are used as prefix for generated controller methods. |
UseModelPrefix | Boolean | When true, a postfix "Model" is appended to all classes generated from schemas. |
UseEnumPrefix | Boolean | When true, a postfix "Enum" is appended to all enumerations lifted from "allowedValues". |
AppendContentHeaders | Boolean | When true, code generation engine automatically detects request and response schema and appends content headers e.g., "accept: application/json" and "content-type: application/json" headers for JSON serialization mode. |
UseCommonSDKLibrary | Boolean | When true, a common library comprising of common classes is used by the generated SDKs |
UseControllerPrefix | Boolean | When true, a postfix "Controller" is appended to all controllers generated from path groups. |
GenerateInterfaces | Boolean | When true, interfaces for controller classes are generated in the generated SDKs |
PreserveParameterOrder | Boolean | When true, parameter order is tried to be preserved in endpoints and models |
AndroidUseAppManifest | Boolean | When true, configuration values e.g., authentication credentials, are expected in AndroidManifest.xml file for the Android SDK. When set, this setting ignores useConstructorsForConfig flag. |
EnablePHPComposerVersionString | Boolean | When true, adds version component to composer.json file in PHP SDKs. This can cause conflicts with Git tag-based version publishing and should be used with care. |
EnableJsonPassThroughForAny | Boolean | Specifies whether JSON should be passed through any type in the SDK. |
iOSUseAppInfoPlist | Boolean | When true, configuration values e.g., authentication credentials, are expected in app-info.plist file for the iOS SDK. When set, this setting ignores useConstructorsForConfig flag. |
iOSGenerateCoreData | Boolean | When true, iOS CoreData schema and classes are generated. |
CollapseParamsToArray | Boolean | When true, collapse more than 3 parameters into an options arrays |
Nullify404 | Boolean | When true, null response will be returned on the HTTP status code 404 |
ValidateRequiredParameters | Boolean | When true, required API endpoint parameters are validated to be not null |
PreserveParameterOrder | Boolean | When true, parameter order is tried to be preserved in endpoints and models |
Timeout | Float | When true the requests will timeout after the specified duration |
EnableAdditionalModelProperties | Boolean | When true, additional or unknown properties in the response JSON are collected into a dictionary. |
BrandLabel | String | A string value to brand the generated files. For example: "Acme Corp." |
UserAgent | String | A string value to use as user-agent in the API calls. This is useful for analytics and tracking purposes. For example: "SDK V1.1" |
ProjectName | String | The name of the project for the Generated SDKs |
CSharpNamespace | String | A valid C# namespace value to be used as the default namespace. Leave empty or null to automatically generate. |
JavaPackageName | String | A valid Java package name to be used as the base package name. Leave empty or null to automatically generate. This value is applied for both Java and Android code generation templates. |
RunscopeEnabled | Boolean | When true Runscope pass-through for traffic monitoring will be enabled |
RunscopeBucket | String | This is the Runscope Bucket Key for traffic monitoring |
GenerateTravisConfig | Boolean | When true, the Travis Configuration file will be generated along with the SDK |
GenerateCircleConfig | Boolean | When true, the Circle Configuration file will be generated along with the SDK |
GenerateAppveyorConfig | Boolean | When true, the Appveyor Configuration file will be generated along with the SDK |
GenerateJenkinsConfig | Boolean | When true, the Jenkins Configuration file will be generated along with the SDK |
StatusCodesToRetry | Integer | Configure the Http status codes to invoke retry on. |
RequestMethodsToRetry | HTTPVerb | Configure the Http request methods to invoke retry for. |
ControllerPostfix | Boolean | Specify custom postfix for controller names. |
ControllerNamespace | Boolean | Specify name of controller namespace in SDK. Defaults to controllers in the CodeGen. |
ReturnCompleteHttpResponse | Boolean | Return complete http response including headers and status code. |
ThrowForHttpErrorStatusCodes | Boolean | Return status code and response instead of throwing an exception for error responses. |
GenerateModels | Boolean | Use maps instead of models when disabled. |
GenerateEnums | Boolean | Whether to generate exception classes for Exception Custom types defined by the user. |
GenerateExceptions | Boolean | Whether to generate exception classes for Exception Custom types defined by the user. |
ResponseMapping | ResponseMappingStrategy | Allows using a field of the response during deserialization, instead of the complete response. |
SymbolizeHashKeysInRuby | Boolean | Uses symbols instead of strings for hash keys in Ruby. |
UsageExampleEndpoint | UsageExampleEndpoint | Allows choosing an endpoint to display its full usage example in the README. You can specify Description , EndpointGroupName , EndpointName . |
IsLatestVersion | Boolean | Enabling this will hide version number from install commands and package repo links in the docs. |
ShortCopyrightNotice | String | A copyright notice to prepend to all code files. Only for white-labelled SDKs. |
CustomDependencies | String | Add custom dependencies to the project. |
LicenseText | String | License text to use in place of the standard MIT License. |
EnableImmutableModels | Boolean | Whether the models in the SDK should be immutable. |
UseEndpointMethodName | Boolean | Use the MethodName in the Endpoint entity to name endpoints instead of the Name property. |
EncodeTemplateParameters | Boolean | Whether to encode endpoint level template parameters. Can be overridden at the parameter level. |
GenerateExamplesForOptionalFields | Boolean | Set this to true to include optional fields during sample value generation. |
MultitargetDotnetVersions | Boolean | Whether multiple target frameworks are to be used. |
BackoffMax | Float | The maximum back off time. |
RetryOnTimeout | Boolean | When true, specifies whether to retry on request timeout or not. |
EnableRetries | Boolean | When true, enables the retries and backoff feature. |
NumberOfRetries | Integer | Tells about the number of retries to make. For example: "3". |
RetryInterval | Float | States the retry time interval between the endpoint calls.For example: "1". |
BackOffFactor | Float | Use this as exponential backoff factor to increase interval between retries.For example: "2". |
MaximumRetryWaitTime | Integer | Shows the maximum wait time in seconds for overall retrying requests.For example: "120". |
HttpStatusCodesToRetry | Array | Specifies the Http status codes to retry against. Values could be: "408, 413, 429, 500, 502, 503, 504, 521, 522, 524". |
HttpMethodsToRetry | Array | Specifies the Http methods to retry against. Allowed values are: "GET, PUT". |
EnableGlobalUserAgent | Boolean | States whether to send the UserAgent header or not. |
ClientInterfaceName | String | Describes the name of the client in the SDK. |
GenerateInterfaces | Boolean | Generates interfaces for controller classes. |
EnableLogging | Boolean | Enables generation of logging code in SDK. |
AllowSkippingSSLCertVerification | Boolean | Allows clients the option to make insecure endpoint calls that do not verify SSL certificate when using HTTPs. |
DoNotSplitWords | String | Shows list of words that should not be split, regardless of the capitalisation. |
Retries | Number | Number of retries for calling an idempotent endpoint after which endpoint call should fail. Could be O. |
ForceKeywordArgsInRuby | Boolean | Uses keyword arguments for required parameters when set to true and positional arguments when set to false. |
JavaGroupId | String | Java Groupid used by package managers such as POM and Gradle. |
JavaArtifactId | String | Java ArtifactId used by package managers such as POM and Gradle. |
PHPComposerPackageName | String | Optional package name for composer file generated for PHP. |
PHPNamespace | String | Root namespace for the PHP SDKs. |
EnableHttpCache | Boolean | Enable HTTP caching for idempotent endpoint methods. |
UserConfigurableRetries | Boolean | Tells whether SDK users should be able to configure retries. |
DisableDocs | Boolean | Disables read-me file generation for SDKs (including any other SDK documentation files). |
StoreTimezomeInformation | Boolean | Stores timezone information with date-time types. Otherwise, SDKs will attempt to convert all date-times to UTC. |
DisableLinting | Boolean | Disables generation of linting config and test code. |
IgnoreIfNullJson | Boolean | Ignores all null properties during serialization of models as JSON in the generated SDKs. |
UseSingletonPattern | Boolean | |
LiftParameterDescriptionFromCustomType | Boolean | |
SortResources | Boolean | This sorts endpoint groups, endpoints and models during code generation (SDKs and docs). |
ApplyCustomizations | String | Each customization is a customer-specific key. It triggers specific customization in codegen and dependent projects. |
Example
{
"CodeGenSettings": {
"SynchronyMode": 0,
"ModelSerializationScheme": "Json",
"ArraySerialization": "Indexed",
"Nullify404": true,
"UseHttpMethodPrefix": true,
"UseModelPrefix": true,
"UseExceptionPrefix": true,
"UseEnumPrefix": true,
"UseControllerPrefix": true,
"UseConstructorsForConfig": true,
"Timeout": 0.1,
"AndroidUseAppManifest": true,
"iOSUseAppInfoPlist": true,
"iOSGenerateCoreData": true,
"CollapseParamsToArray": true,
"RunscopeEnabled": true,
"RunscopeBucket": "key",
"AndroidHttpClient": "UNIREST",
"ObjCHttpClient": "UNIREST",
"CSharpHttpClient": "UNIREST",
"CSharpNamespace": "Root",
"JavaPackageName": "Root",
"JavaUsePropertiesConfig": false,
"PHPHttpClient": "UNIREST",
"BrandLabel": "Label",
"UserAgent": "User",
"ProjectName": "Calculator",
"EnableAdditionalModelProperties": true,
"PreserveParameterOrder": true,
"ValidateRequiredParameters": true,
"AppendContentHeaders": true,
"GenerateInterfaces": true,
"UseCommonSDKLibrary": true,
"ParameterArrayFormat": 2,
"UsageExampleEndpoint": {
"Description": "Endpoint description here",
"EndpointGroupName": "Calculator",
"EndpointName": "OperationGet"
},
"GenerateTravisConfig": true,
"GenerateCircleConfig": true,
"GenerateAppveyorConfig": true,
"GenerateJenkinsConfig": true,
"EnableLogging": false,
"EnableHttpCache": false,
"EnablePHPComposerVersionString": false,
"EnableRetries": false,
"EnableGlobalUserAgent": true,
"NumberOfRetries": 3,
"RetryInterval": 1,
"BackOffFactor": 2,
"MaximumRetryWaitTime": 120,
"RetryOnTimeout": true,
"HttpStatusCodesToRetry": 413,
"HttpMethodsToRetry": "GET",
"Retries": 0,
"DisableDocs": false,
"StoreTimezoneInformation": false,
"GenerateInterfaces": true,
"IgnoreIfNullJson": false,
"DisableLinting": false,
"SortResources": false,
"LiftParameterDescriptionFromCustomType": false,
"AllowSkippingSSLCertVerification": false,
"ForceKeywordArgsInRuby": false
}
}