public class SwiftCodegen extends DefaultCodegen implements CodegenConfig
Modifier and Type | Field and Description |
---|---|
static String |
DEFAULT_POD_AUTHORS |
protected static String |
LIBRARY_PROMISE_KIT |
protected static String |
LIBRARY_RX_SWIFT |
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 |
additionalProperties, allowUnicodeIdentifiers, apiDocTemplateFiles, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, commonTemplateDir, defaultIncludes, embeddedTemplateDir, ensureUniqueParams, fileSuffix, 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 and Description |
---|
SwiftCodegen() |
Modifier and Type | Method and Description |
---|---|
String |
apiFileFolder() |
String |
escapeQuotationMark(String input)
Escape single and/or double quote to avoid code injection
|
String |
escapeReservedWord(String name)
Return the escaped name of the reserved word
|
String |
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe
characters so as to avoid code injection
|
CodegenOperation |
fromOperation(String path,
String httpMethod,
io.swagger.models.Operation operation,
Map<String,io.swagger.models.Model> definitions,
io.swagger.models.Swagger swagger)
Convert Swagger Operation object to Codegen Operation object
|
CodegenProperty |
fromProperty(String name,
io.swagger.models.properties.Property p)
Convert Swagger Property object to Codegen Property object
|
String |
getHelp() |
String |
getName() |
String |
getSwaggerType(io.swagger.models.properties.Property p)
returns the swagger type for the property
|
CodegenType |
getTag() |
String |
getTypeDeclaration(io.swagger.models.properties.Property p)
Output the type declaration of the property
|
boolean |
isDataTypeBinary(String dataType) |
boolean |
isDataTypeFile(String dataType) |
protected boolean |
isReservedWord(String word) |
String |
modelFileFolder() |
Map<String,Object> |
postProcessModels(Map<String,Object> objs) |
void |
processOpts() |
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 empty
|
String |
toDefaultValue(io.swagger.models.properties.Property p)
Return the default value of the property
|
String |
toEnumDefaultValue(String value,
String datatype)
Return the enum default value in the language specified format
|
String |
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 enum
|
String |
toInstantiationType(io.swagger.models.properties.Property p)
Return the instantiation type of the property, especially for map and array
|
String |
toModelFilename(String name)
Return the capitalized file name of the model
|
String |
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 |
toSwiftyEnumName(String value) |
String |
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if
it's a reserved word.
|
addAdditionPropertiesToCodeGenModel, addImport, additionalProperties, addOperationToGroup, addOption, addOption, 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, fromModel, fromOperation, fromParameter, fromResponse, fromSecurity, generateExamplePath, getAlias, getCommonTemplateDir, getExamples, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getIgnoreImportMapping, getInnerEnumAllowableValues, getInputSpec, getLibrary, getOrGenerateOperationId, getOutputDir, getParameterDataType, getReleaseNote, getSkipAliasGeneration, getSymbolName, getterAndSetterCapitalize, getTypeDeclaration, importMapping, initalizeSpecialCharacterMapping, initialCaps, instantiationTypes, isHideGenerationTimestamp, isModelObject, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isSkipOverwrite, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, needToImport, outputFolder, postProcessAllModels, postProcessModelProperty, postProcessModelsEnum, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessSwagger, processCompiler, processSwagger, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setAllowUnicodeIdentifiers, setApiPackage, setCommonTemplateDir, setEnsureUniqueParams, 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, 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
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
additionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIgnoreImportMappingOption, defaultIncludes, embeddedTemplateDir, escapeText, fileSuffix, fromModel, fromModel, fromOperation, fromSecurity, generateExamplePath, getCommonTemplateDir, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getIgnoreImportMapping, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getSkipAliasGeneration, getTypeDeclaration, importMapping, instantiationTypes, isHideGenerationTimestamp, isRemoveOperationIdPrefix, isSkipOverwrite, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessModelProperty, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessSwagger, processCompiler, processSwagger, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, 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
public static final String PROJECT_NAME
public static final String RESPONSE_AS
public static final String UNWRAP_REQUIRED
public static final String POD_SOURCE
public static final String POD_AUTHORS
public static final String POD_SOCIAL_MEDIA_URL
public static final String POD_DOCSET_URL
public static final String POD_LICENSE
public static final String POD_HOMEPAGE
public static final String POD_SUMMARY
public static final String POD_DESCRIPTION
public static final String POD_SCREENSHOTS
public static final String POD_DOCUMENTATION_URL
public static final String SWIFT_USE_API_NAMESPACE
public static final String DEFAULT_POD_AUTHORS
protected static final String LIBRARY_PROMISE_KIT
protected static final String LIBRARY_RX_SWIFT
protected static final String[] RESPONSE_LIBRARIES
protected String projectName
protected boolean unwrapRequired
protected boolean swiftUseApiNamespace
protected String[] responseAs
protected String sourceFolder
public CodegenType getTag()
getTag
in interface CodegenConfig
public String getName()
getName
in interface CodegenConfig
public String getHelp()
getHelp
in interface CodegenConfig
public void processOpts()
processOpts
in interface CodegenConfig
processOpts
in class DefaultCodegen
protected boolean isReservedWord(String word)
isReservedWord
in class DefaultCodegen
public String escapeReservedWord(String name)
DefaultCodegen
escapeReservedWord
in interface CodegenConfig
escapeReservedWord
in class DefaultCodegen
name
- the name to be escapedpublic String modelFileFolder()
modelFileFolder
in interface CodegenConfig
modelFileFolder
in class DefaultCodegen
public String apiFileFolder()
apiFileFolder
in interface CodegenConfig
apiFileFolder
in class DefaultCodegen
public String getTypeDeclaration(io.swagger.models.properties.Property p)
DefaultCodegen
getTypeDeclaration
in interface CodegenConfig
getTypeDeclaration
in class DefaultCodegen
p
- Swagger Property objectpublic String getSwaggerType(io.swagger.models.properties.Property p)
DefaultCodegen
getSwaggerType
in class DefaultCodegen
p
- Swagger property objectpublic boolean isDataTypeFile(String dataType)
isDataTypeFile
in class DefaultCodegen
public boolean isDataTypeBinary(String dataType)
isDataTypeBinary
in class DefaultCodegen
public String toModelName(String name)
toModelName
in interface CodegenConfig
toModelName
in class DefaultCodegen
name
- the name of the modelpublic String toModelFilename(String name)
toModelFilename
in interface CodegenConfig
toModelFilename
in class DefaultCodegen
name
- the model namepublic String toDefaultValue(io.swagger.models.properties.Property p)
DefaultCodegen
toDefaultValue
in class DefaultCodegen
p
- Swagger property objectpublic String toInstantiationType(io.swagger.models.properties.Property p)
DefaultCodegen
toInstantiationType
in class DefaultCodegen
p
- Swagger property objectpublic CodegenProperty fromProperty(String name, io.swagger.models.properties.Property p)
DefaultCodegen
fromProperty
in class DefaultCodegen
name
- name of the propertyp
- Swagger property objectpublic String toApiName(String name)
DefaultCodegen
toApiName
in interface CodegenConfig
toApiName
in class DefaultCodegen
name
- the name of the Apipublic String toOperationId(String operationId)
DefaultCodegen
toOperationId
in class DefaultCodegen
operationId
- operation IDpublic String toVarName(String name)
DefaultCodegen
toVarName
in class DefaultCodegen
name
- the variable namepublic String toParamName(String name)
DefaultCodegen
toParamName
in interface CodegenConfig
toParamName
in class DefaultCodegen
name
- Codegen property objectpublic CodegenOperation fromOperation(String path, String httpMethod, io.swagger.models.Operation operation, Map<String,io.swagger.models.Model> definitions, io.swagger.models.Swagger swagger)
DefaultCodegen
fromOperation
in interface CodegenConfig
fromOperation
in class DefaultCodegen
path
- the path of the operationhttpMethod
- HTTP methodoperation
- Swagger operation objectdefinitions
- a map of Swagger modelsswagger
- a Swagger object representing the specpublic void setProjectName(String projectName)
public void setUnwrapRequired(boolean unwrapRequired)
public void setResponseAs(String[] responseAs)
public void setSwiftUseApiNamespace(boolean swiftUseApiNamespace)
public String toEnumValue(String value, String datatype)
DefaultCodegen
toEnumValue
in class DefaultCodegen
value
- enum variable namedatatype
- data typepublic String toEnumDefaultValue(String value, String datatype)
DefaultCodegen
toEnumDefaultValue
in class DefaultCodegen
value
- enum variable namedatatype
- data typepublic String toEnumVarName(String name, String datatype)
DefaultCodegen
toEnumVarName
in class DefaultCodegen
name
- enum variable namedatatype
- data typepublic String toEnumName(CodegenProperty property)
DefaultCodegen
toEnumName
in class DefaultCodegen
property
- Codegen propertypublic Map<String,Object> postProcessModels(Map<String,Object> objs)
postProcessModels
in interface CodegenConfig
postProcessModels
in class DefaultCodegen
public String escapeQuotationMark(String input)
DefaultCodegen
escapeQuotationMark
in interface CodegenConfig
escapeQuotationMark
in class DefaultCodegen
input
- String to be cleaned uppublic String escapeUnsafeCharacters(String input)
DefaultCodegen
escapeUnsafeCharacters
in interface CodegenConfig
escapeUnsafeCharacters
in class DefaultCodegen
input
- String to be cleaned upCopyright © 2020. All rights reserved.