Package io.swagger.codegen.languages
Class Swift3Codegen
- java.lang.Object
-
- io.swagger.codegen.DefaultCodegen
-
- io.swagger.codegen.languages.Swift3Codegen
-
- All Implemented Interfaces:
CodegenConfig
public class Swift3Codegen extends DefaultCodegen implements CodegenConfig
-
-
Field Summary
Fields Modifier and Type Field Description static String
DEFAULT_POD_AUTHORS
static String
LENIENT_TYPE_CAST
protected boolean
lenientTypeCast
protected static String
LIBRARY_PROMISE_KIT
protected static String
LIBRARY_RX_SWIFT
static String
OBJC_COMPATIBLE
protected boolean
objcCompatible
static String
POD_AUTHORS
static String
POD_DESCRIPTION
static String
POD_DOCSET_URL
static String
POD_DOCUMENTATION_URL
static String
POD_HOMEPAGE
static String
POD_LICENSE
static String
POD_SCREENSHOTS
static String
POD_SOCIAL_MEDIA_URL
static String
POD_SOURCE
static String
POD_SUMMARY
static String
PROJECT_NAME
protected String
projectName
static String
RESPONSE_AS
protected static String[]
RESPONSE_LIBRARIES
protected String[]
responseAs
protected String
sourceFolder
static String
SWIFT_USE_API_NAMESPACE
protected boolean
swiftUseApiNamespace
static String
UNWRAP_REQUIRED
protected boolean
unwrapRequired
-
Fields inherited from class io.swagger.codegen.DefaultCodegen
additionalProperties, allowUnicodeIdentifiers, apiDocTemplateFiles, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, commonTemplateDir, defaultIncludes, embeddedTemplateDir, ensureUniqueParams, fileSuffix, gitRepoBaseURL, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, ignoreImportMapping, importMapping, inputSpec, instantiationTypes, languageSpecificPrimitives, library, LOGGER, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, releaseNote, removeOperationIdPrefix, reservedWords, reservedWordsMappings, skipAliasGeneration, skipOverwrite, sortParamsByRequiredFlag, specialCharReplacements, supportedLibraries, supportingFiles, supportsInheritance, supportsMixins, templateDir, testPackage, typeAliases, typeMapping, vendorExtensions
-
-
Constructor Summary
Constructors Constructor Description Swift3Codegen()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected void
addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.models.ModelImpl swaggerModel)
String
apiFileFolder()
String
escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injectionString
escapeReservedWord(String name)
Return the escaped name of the reserved wordString
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe characters so as to avoid code injectionCodegenModel
fromModel(String name, io.swagger.models.Model model, Map<String,io.swagger.models.Model> allDefinitions)
Convert Swagger Model object to Codegen Model objectString
getHelp()
String
getName()
String
getSwaggerType(io.swagger.models.properties.Property p)
returns the swagger type for the propertyCodegenType
getTag()
String
getTypeDeclaration(io.swagger.models.properties.Property p)
Output the type declaration of the propertyboolean
isDataTypeBinary(String dataType)
boolean
isDataTypeFile(String dataType)
protected boolean
isReservedWord(String word)
String
modelFileFolder()
void
postProcessModelProperty(CodegenModel model, CodegenProperty property)
Map<String,Object>
postProcessModels(Map<String,Object> objs)
void
processOpts()
void
setLenientTypeCast(boolean lenientTypeCast)
void
setObjcCompatible(boolean objcCompatible)
void
setProjectName(String projectName)
void
setResponseAs(String[] responseAs)
void
setSwiftUseApiNamespace(boolean swiftUseApiNamespace)
void
setUnwrapRequired(boolean unwrapRequired)
String
toApiName(String name)
Output the API (class) name (capitalized) ending with "Api" Return DefaultApi if name is emptyString
toDefaultValue(io.swagger.models.properties.Property p)
Return the default value of the propertyString
toEnumDefaultValue(String value, String datatype)
Return the enum default value in the language specified formatString
toEnumName(CodegenProperty property)
Return the Enum name (e.g.String
toEnumValue(String value, String datatype)
Return the enum value in the language specified format e.g.String
toEnumVarName(String name, String datatype)
Return the sanitized variable name for enumString
toInstantiationType(io.swagger.models.properties.Property p)
Return the instantiation type of the property, especially for map and arrayString
toModelFilename(String name)
Return the capitalized file name of the modelString
toModelName(String name)
Output the proper model name (capitalized)String
toOperationId(String operationId)
Return the operation ID (method name)String
toParamName(String name)
Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.String
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if it's a reserved word.-
Methods inherited from class io.swagger.codegen.DefaultCodegen
addImport, additionalProperties, addOperationToGroup, addOption, addOption, addParentContainer, addProperties, addRegularExpressionDelimiter, addSwitch, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, camelize, camelize, cliOptions, configureDataForTestTemplate, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, dashize, defaultIgnoreImportMappingOption, defaultIncludes, embeddedTemplateDir, ensureUniqueName, escapeText, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fixUpParentAndInterfaces, fromModel, fromOperation, fromOperation, fromParameter, fromProperty, fromResponse, fromSecurity, generateExamplePath, getAlias, getAllAliases, getCommonTemplateDir, getExamples, getGitRepoBaseURL, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getIgnoreImportMapping, getInnerEnumAllowableValues, getInputSpec, getLibrary, getOrGenerateOperationId, getOutputDir, getParameterDataType, getReleaseNote, getSkipAliasGeneration, getSymbolName, getterAndSetterCapitalize, getTypeDeclaration, importMapping, initalizeSpecialCharacterMapping, initialCaps, instantiationTypes, isHideGenerationTimestamp, isModelObject, isPrimivite, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isSkipOverwrite, isUsingFlattenSpec, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, needToImport, outputFolder, postProcessAllModels, postProcessModelProperties, postProcessModelsEnum, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessSwagger, processCompiler, processSwagger, readRefModelParameter, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setAllowUnicodeIdentifiers, setApiPackage, setCommonTemplateDir, setEnsureUniqueParams, setGitRepoBaseURL, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setIgnoreImportMapping, setInputSpec, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterExampleValue, setReleaseNote, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipAliasGeneration, setSkipOverwrite, setSortParamsByRequiredFlag, setTemplateDir, shouldOverwrite, snakeCase, supportedLibraries, supportingFiles, templateDir, testPackage, titleCase, toApiDocFilename, toApiFilename, toApiImport, toApiTestFilename, toApiVarName, toBooleanGetter, toDefaultValueWithParam, toExamples, toExampleValue, toGetter, toModelDocFilename, toModelImport, toModelTestFilename, toRegularExpression, toSetter, typeMapping, underscore, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writeOptional, writePropertyBack
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface io.swagger.codegen.CodegenConfig
additionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIgnoreImportMappingOption, defaultIncludes, embeddedTemplateDir, escapeText, fileSuffix, fromModel, fromOperation, fromOperation, fromSecurity, generateExamplePath, getCommonTemplateDir, getGitRepoBaseURL, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getIgnoreImportMapping, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getSkipAliasGeneration, getTypeDeclaration, importMapping, instantiationTypes, isHideGenerationTimestamp, isRemoveOperationIdPrefix, isSkipOverwrite, isUsingFlattenSpec, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessSwagger, processCompiler, processSwagger, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setGitRepoBaseURL, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setIgnoreImportMapping, setInputSpec, setLibrary, setOutputDir, setReleaseNote, setRemoveOperationIdPrefix, setSkipAliasGeneration, setSkipOverwrite, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toApiDocFilename, toApiFilename, toApiImport, toApiTestFilename, toApiVarName, toBooleanGetter, toGetter, toModelDocFilename, toModelImport, toModelTestFilename, toSetter, typeMapping, vendorExtensions
-
-
-
-
Field Detail
-
PROJECT_NAME
public static final String PROJECT_NAME
- See Also:
- Constant Field Values
-
RESPONSE_AS
public static final String RESPONSE_AS
- See Also:
- Constant Field Values
-
UNWRAP_REQUIRED
public static final String UNWRAP_REQUIRED
- See Also:
- Constant Field Values
-
OBJC_COMPATIBLE
public static final String OBJC_COMPATIBLE
- See Also:
- Constant Field Values
-
POD_SOURCE
public static final String POD_SOURCE
- See Also:
- Constant Field Values
-
POD_AUTHORS
public static final String POD_AUTHORS
- See Also:
- Constant Field Values
-
POD_SOCIAL_MEDIA_URL
public static final String POD_SOCIAL_MEDIA_URL
- See Also:
- Constant Field Values
-
POD_DOCSET_URL
public static final String POD_DOCSET_URL
- See Also:
- Constant Field Values
-
POD_LICENSE
public static final String POD_LICENSE
- See Also:
- Constant Field Values
-
POD_HOMEPAGE
public static final String POD_HOMEPAGE
- See Also:
- Constant Field Values
-
POD_SUMMARY
public static final String POD_SUMMARY
- See Also:
- Constant Field Values
-
POD_DESCRIPTION
public static final String POD_DESCRIPTION
- See Also:
- Constant Field Values
-
POD_SCREENSHOTS
public static final String POD_SCREENSHOTS
- See Also:
- Constant Field Values
-
POD_DOCUMENTATION_URL
public static final String POD_DOCUMENTATION_URL
- See Also:
- Constant Field Values
-
SWIFT_USE_API_NAMESPACE
public static final String SWIFT_USE_API_NAMESPACE
- See Also:
- Constant Field Values
-
DEFAULT_POD_AUTHORS
public static final String DEFAULT_POD_AUTHORS
- See Also:
- Constant Field Values
-
LENIENT_TYPE_CAST
public static final String LENIENT_TYPE_CAST
- See Also:
- Constant Field Values
-
LIBRARY_PROMISE_KIT
protected static final String LIBRARY_PROMISE_KIT
- See Also:
- Constant Field Values
-
LIBRARY_RX_SWIFT
protected static final String LIBRARY_RX_SWIFT
- See Also:
- Constant Field Values
-
RESPONSE_LIBRARIES
protected static final String[] RESPONSE_LIBRARIES
-
projectName
protected String projectName
-
unwrapRequired
protected boolean unwrapRequired
-
objcCompatible
protected boolean objcCompatible
-
lenientTypeCast
protected boolean lenientTypeCast
-
swiftUseApiNamespace
protected boolean swiftUseApiNamespace
-
responseAs
protected String[] responseAs
-
sourceFolder
protected String sourceFolder
-
-
Method Detail
-
getTag
public CodegenType getTag()
- Specified by:
getTag
in interfaceCodegenConfig
-
getName
public String getName()
- Specified by:
getName
in interfaceCodegenConfig
-
getHelp
public String getHelp()
- Specified by:
getHelp
in interfaceCodegenConfig
-
addAdditionPropertiesToCodeGenModel
protected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.models.ModelImpl swaggerModel)
- Overrides:
addAdditionPropertiesToCodeGenModel
in classDefaultCodegen
-
processOpts
public void processOpts()
- Specified by:
processOpts
in interfaceCodegenConfig
- Overrides:
processOpts
in classDefaultCodegen
-
isReservedWord
protected boolean isReservedWord(String word)
- Overrides:
isReservedWord
in classDefaultCodegen
-
escapeReservedWord
public String escapeReservedWord(String name)
Description copied from class:DefaultCodegen
Return the escaped name of the reserved word- Specified by:
escapeReservedWord
in interfaceCodegenConfig
- Overrides:
escapeReservedWord
in classDefaultCodegen
- Parameters:
name
- the name to be escaped- Returns:
- the escaped reserved word throws Runtime exception as reserved word is not allowed (default behavior)
-
modelFileFolder
public String modelFileFolder()
- Specified by:
modelFileFolder
in interfaceCodegenConfig
- Overrides:
modelFileFolder
in classDefaultCodegen
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolder
in interfaceCodegenConfig
- Overrides:
apiFileFolder
in classDefaultCodegen
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.models.properties.Property p)
Description copied from class:DefaultCodegen
Output the type declaration of the property- Specified by:
getTypeDeclaration
in interfaceCodegenConfig
- Overrides:
getTypeDeclaration
in classDefaultCodegen
- Parameters:
p
- Swagger Property object- Returns:
- a string presentation of the property type
-
getSwaggerType
public String getSwaggerType(io.swagger.models.properties.Property p)
Description copied from class:DefaultCodegen
returns the swagger type for the property- Overrides:
getSwaggerType
in classDefaultCodegen
- Parameters:
p
- Swagger property object- Returns:
- string presentation of the type
-
isDataTypeFile
public boolean isDataTypeFile(String dataType)
- Overrides:
isDataTypeFile
in classDefaultCodegen
-
isDataTypeBinary
public boolean isDataTypeBinary(String dataType)
- Overrides:
isDataTypeBinary
in classDefaultCodegen
-
toModelName
public String toModelName(String name)
Output the proper model name (capitalized)- Specified by:
toModelName
in interfaceCodegenConfig
- Overrides:
toModelName
in classDefaultCodegen
- Parameters:
name
- the name of the model- Returns:
- capitalized model name
-
toModelFilename
public String toModelFilename(String name)
Return the capitalized file name of the model- Specified by:
toModelFilename
in interfaceCodegenConfig
- Overrides:
toModelFilename
in classDefaultCodegen
- Parameters:
name
- the model name- Returns:
- the file name of the model
-
toDefaultValue
public String toDefaultValue(io.swagger.models.properties.Property p)
Description copied from class:DefaultCodegen
Return the default value of the property- Overrides:
toDefaultValue
in classDefaultCodegen
- Parameters:
p
- Swagger property object- Returns:
- string presentation of the default value of the property
-
toInstantiationType
public String toInstantiationType(io.swagger.models.properties.Property p)
Description copied from class:DefaultCodegen
Return the instantiation type of the property, especially for map and array- Overrides:
toInstantiationType
in classDefaultCodegen
- Parameters:
p
- Swagger property object- Returns:
- string presentation of the instantiation type of the property
-
toApiName
public String toApiName(String name)
Description copied from class:DefaultCodegen
Output the API (class) name (capitalized) ending with "Api" Return DefaultApi if name is empty- Specified by:
toApiName
in interfaceCodegenConfig
- Overrides:
toApiName
in classDefaultCodegen
- Parameters:
name
- the name of the Api- Returns:
- capitalized Api name ending with "Api"
-
toOperationId
public String toOperationId(String operationId)
Description copied from class:DefaultCodegen
Return the operation ID (method name)- Overrides:
toOperationId
in classDefaultCodegen
- Parameters:
operationId
- operation ID- Returns:
- the sanitized method name
-
toVarName
public String toVarName(String name)
Description copied from class:DefaultCodegen
Return the variable name by removing invalid characters and proper escaping if it's a reserved word.- Overrides:
toVarName
in classDefaultCodegen
- Parameters:
name
- the variable name- Returns:
- the sanitized variable name
-
toParamName
public String toParamName(String name)
Description copied from class:DefaultCodegen
Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamName
in interfaceCodegenConfig
- Overrides:
toParamName
in classDefaultCodegen
- Parameters:
name
- Codegen property object- Returns:
- the sanitized parameter name
-
fromModel
public CodegenModel fromModel(String name, io.swagger.models.Model model, Map<String,io.swagger.models.Model> allDefinitions)
Description copied from class:DefaultCodegen
Convert Swagger Model object to Codegen Model object- Specified by:
fromModel
in interfaceCodegenConfig
- Overrides:
fromModel
in classDefaultCodegen
- Parameters:
name
- the name of the modelmodel
- Swagger Model objectallDefinitions
- a map of all Swagger models from the spec- Returns:
- Codegen Model object
-
setProjectName
public void setProjectName(String projectName)
-
setUnwrapRequired
public void setUnwrapRequired(boolean unwrapRequired)
-
setObjcCompatible
public void setObjcCompatible(boolean objcCompatible)
-
setLenientTypeCast
public void setLenientTypeCast(boolean lenientTypeCast)
-
setResponseAs
public void setResponseAs(String[] responseAs)
-
setSwiftUseApiNamespace
public void setSwiftUseApiNamespace(boolean swiftUseApiNamespace)
-
toEnumValue
public String toEnumValue(String value, String datatype)
Description copied from class:DefaultCodegen
Return the enum value in the language specified format e.g. status becomes "status"- Overrides:
toEnumValue
in classDefaultCodegen
- Parameters:
value
- enum variable namedatatype
- data type- Returns:
- the sanitized value for enum
-
toEnumDefaultValue
public String toEnumDefaultValue(String value, String datatype)
Description copied from class:DefaultCodegen
Return the enum default value in the language specified format- Overrides:
toEnumDefaultValue
in classDefaultCodegen
- Parameters:
value
- enum variable namedatatype
- data type- Returns:
- the default value for the enum
-
toEnumVarName
public String toEnumVarName(String name, String datatype)
Description copied from class:DefaultCodegen
Return the sanitized variable name for enum- Overrides:
toEnumVarName
in classDefaultCodegen
- Parameters:
name
- enum variable namedatatype
- data type- Returns:
- the sanitized variable name for enum
-
toEnumName
public String toEnumName(CodegenProperty property)
Description copied from class:DefaultCodegen
Return the Enum name (e.g. StatusEnum given 'status')- Overrides:
toEnumName
in classDefaultCodegen
- Parameters:
property
- Codegen property- Returns:
- the Enum name
-
postProcessModels
public Map<String,Object> postProcessModels(Map<String,Object> objs)
- Specified by:
postProcessModels
in interfaceCodegenConfig
- Overrides:
postProcessModels
in classDefaultCodegen
-
postProcessModelProperty
public void postProcessModelProperty(CodegenModel model, CodegenProperty property)
- Specified by:
postProcessModelProperty
in interfaceCodegenConfig
- Overrides:
postProcessModelProperty
in classDefaultCodegen
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Description copied from class:DefaultCodegen
Escape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMark
in interfaceCodegenConfig
- Overrides:
escapeQuotationMark
in classDefaultCodegen
- Parameters:
input
- String to be cleaned up- Returns:
- string with quotation mark removed or escaped
-
escapeUnsafeCharacters
public String escapeUnsafeCharacters(String input)
Description copied from class:DefaultCodegen
override with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharacters
in interfaceCodegenConfig
- Overrides:
escapeUnsafeCharacters
in classDefaultCodegen
- Parameters:
input
- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
-