Skip to main content

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:

SettingTypePurpose
SynchronyModeNumber. Could be 0 or 1.0 represents Asynchronous while 1 represents Synchronous. When Asynchronous, the CodeGen engine generates asynchronous C# and Java code.
ArraySerializationStringArray serialisation scheme for primitive types (applicable to form and query params). Allowed values are Indexed, UnIndexed, Plain, CSV, TSV, PSV
UseHttpMethodPrefixBooleanWhen true, HTTP verbs are used as prefix for generated controller methods.
UseModelPrefixBooleanWhen true, a postfix "Model" is appended to all classes generated from schemas.
UseEnumPrefixBooleanWhen true, a postfix "Enum" is appended to all enumerations lifted from "allowedValues".
AppendContentHeadersBooleanWhen 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.
UseCommonSDKLibraryBooleanWhen true, a common library comprising of common classes is used by the generated SDKs
UseControllerPrefixBooleanWhen true, a postfix "Controller" is appended to all controllers generated from path groups.
GenerateInterfacesBooleanWhen true, interfaces for controller classes are generated in the generated SDKs
PreserveParameterOrderBooleanWhen true, parameter order is tried to be preserved in endpoints and models
AndroidUseAppManifestBooleanWhen true, configuration values e.g., authentication credentials, are expected in AndroidManifest.xml file for the Android SDK. When set, this setting ignores useConstructorsForConfig flag.
EnablePHPComposerVersionStringBooleanWhen 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.
iOSUseAppInfoPlistBooleanWhen 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.
iOSGenerateCoreDataBooleanWhen true, iOS CoreData schema and classes are generated.
CollapseParamsToArrayBooleanWhen true, collapse more than 3 parameters into an options arrays
Nullify404BooleanWhen true, null response will be returned on the HTTP status code 404
ValidateRequiredParametersBooleanWhen true, required API endpoint parameters are validated to be not null
PreserveParameterOrderBooleanWhen true, parameter order is tried to be preserved in endpoints and models
TimeoutFloatWhen true the requests will timeout after the specified duration
EnableAdditionalModelPropertiesBooleanWhen true, additional or unknown properties in the response JSON are collected into a dictionary.
BrandLabelStringA string value to brand the generated files. For example: "Acme Corp."
UserAgentStringA string value to use as user-agent in the API calls. This is useful for analytics and tracking purposes. For example: "SDK V1.1"
ProjectNameStringThe name of the project for the Generated SDKs
CSharpNamespaceStringA valid C# namespace value to be used as the default namespace. Leave empty or null to automatically generate.
JavaPackageNameStringA 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.
RunscopeEnabledBooleanWhen true Runscope pass-through for traffic monitoring will be enabled
RunscopeBucketStringThis is the Runscope Bucket Key for traffic monitoring
GenerateTravisConfigBooleanWhen true, the Travis Configuration file will be generated along with the SDK
GenerateCircleConfigBooleanWhen true, the Circle Configuration file will be generated along with the SDK
GenerateAppveyorConfigBooleanWhen true, the Appveyor Configuration file will be generated along with the SDK
GenerateJenkinsConfigBooleanWhen true, the Jenkins Configuration file will be generated along with the SDK
StatusCodesToRetryIntegerConfigure the Http status codes to invoke retry on.
RequestMethodsToRetryHTTPVerbConfigure the Http request methods to invoke retry for.
ControllerPostfixBooleanSpecify custom postfix for controller names.
ControllerNamespaceBooleanSpecify name of controller namespace in SDK. Defaults to controllers in the CodeGen.
ReturnCompleteHttpResponseBooleanReturn complete http response including headers and status code.
ThrowForHttpErrorStatusCodesBooleanReturn status code and response instead of throwing an exception for error responses.
GenerateModelsBooleanUse maps instead of models when disabled.
GenerateEnumsBooleanWhether to generate exception classes for Exception Custom types defined by the user.
GenerateExceptionsBooleanWhether to generate exception classes for Exception Custom types defined by the user.
ResponseMappingResponseMappingStrategyAllows using a field of the response during deserialization, instead of the complete response.
SymbolizeHashKeysInRubyBooleanUses symbols instead of strings for hash keys in Ruby.
UsageExampleEndpointBooleanDisplay a complete usage example for this endpoint in the README.
IsLatestVersionBooleanEnabling this will hide version number from install commands and package repo links in the docs.
ShortCopyrightNoticeStringA copyright notice to prepend to all code files. Only for white-labelled SDKs.
CustomDependenciesStringAdd custom dependencies to the project.
LicenseTextStringLicense text to use in place of the standard MIT License.
EnableImmutableModelsBooleanWhether the models in the SDK should be immutable.
UseEndpointMethodNameBooleanUse the MethodName in the Endpoint entity to name endpoints instead of the Name property.
EncodeTemplateParametersBooleanWhether to encode endpoint level template parameters. Can be overridden at the parameter level.
GenerateExamplesForOptionalFieldsBooleanSet this to true to include optional fields during sample value generation.
MultitargetDotnetVersionsBooleanWhether multiple target frameworks are to be used.
BackoffMaxFloatThe maximum back off time.
RetryOnTimeoutBooleanSpecifies whether to retry on timeout or not.

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,    "GenerateTravisConfig": true,    "GenerateCircleConfig": true,    "GenerateAppveyorConfig": true,    "GenerateJenkinsConfig": true,    "EnableLogging": false,    "EnableHttpCache": false,    "EnablePHPComposerVersionString": false  }}