Class AbstractSwiftCodegen
- java.lang.Object
-
- io.swagger.codegen.v3.generators.DefaultCodegenConfig
-
- io.swagger.codegen.v3.generators.swift.AbstractSwiftCodegen
-
- All Implemented Interfaces:
io.swagger.codegen.v3.CodegenConfig
- Direct Known Subclasses:
Swift3Codegen,Swift4Codegen
public abstract class AbstractSwiftCodegen extends DefaultCodegenConfig
-
-
Field Summary
Fields Modifier and Type Field Description static StringDEFAULT_POD_AUTHORSstatic StringLENIENT_TYPE_CASTprotected static StringMODEL_CLASSESstatic StringOBJC_COMPATIBLEstatic StringPOD_AUTHORSstatic StringPOD_DESCRIPTIONstatic StringPOD_DOCSET_URLstatic StringPOD_DOCUMENTATION_URLstatic StringPOD_HOMEPAGEstatic StringPOD_LICENSEstatic StringPOD_SCREENSHOTSstatic StringPOD_SOCIAL_MEDIA_URLstatic StringPOD_SOURCEstatic StringPOD_SUMMARYstatic StringPROJECT_NAMEstatic StringRESPONSE_ASprotected static String[]RESPONSE_LIBRARIESprotected StringsourceFolderstatic StringSWIFT_USE_API_NAMESPACEstatic StringUNWRAP_REQUIREDprotected static StringUSE_MODEL_CLASSES-
Fields inherited from class io.swagger.codegen.v3.generators.DefaultCodegenConfig
additionalProperties, allowUnicodeIdentifiers, apiDocTemplateFiles, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, commonTemplateDir, configFiles, customTemplateDir, DEFAULT_CONTENT_TYPE, DEFAULT_TEMPLATE_DIR, defaultIncludes, embeddedTemplateDir, ensureUniqueParams, fileSuffix, gitRepoBaseURL, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, ignoreImportMapping, importMapping, inputSpec, inputURL, instantiationTypes, IS_NULLABLE_FALSE, IS_NULLABLE_TRUE, languageArguments, languageSpecificPrimitives, library, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, openAPI, outputFolder, releaseNote, removeOperationIdPrefix, REQUEST_BODY_NAME, reservedWords, reservedWordsMappings, skipOverwrite, sortParamsByRequiredFlag, specialCharReplacements, supportedLibraries, supportingFiles, supportsInheritance, supportsMixins, templateDir, templateEngine, templateVersion, testPackage, typeAliases, typeMapping, unflattenedOpenAPI, useOas2, vendorExtensions
-
-
Constructor Summary
Constructors Constructor Description AbstractSwiftCodegen()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected voidaddAdditionPropertiesToCodeGenModel(io.swagger.codegen.v3.CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)StringapiFileFolder()StringescapeQuotationMark(String input)Escape single and/or double quote to avoid code injectionStringescapeReservedWord(String name)Return the escaped name of the reserved wordStringescapeUnsafeCharacters(String input)override with any special text escaping logic to handle unsafe characters so as to avoid code injectionio.swagger.codegen.v3.CodegenModelfromModel(String name, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allDefinitions)Convert Swagger Model object to Codegen Model objectStringgetArgumentsLocation()StringgetDefaultTemplateDir()StringgetHelp()StringgetSchemaType(io.swagger.v3.oas.models.media.Schema schema)returns the swagger type for the propertyio.swagger.codegen.v3.CodegenTypegetTag()StringgetTypeDeclaration(io.swagger.v3.oas.models.media.Schema propertySchema)Output the type declaration of the propertybooleanisDataTypeBinary(String dataType)booleanisDataTypeFile(String dataType)protected booleanisReservedWord(String word)StringmodelFileFolder()voidpostProcessModelProperty(io.swagger.codegen.v3.CodegenModel model, io.swagger.codegen.v3.CodegenProperty property)voidprocessOpts()voidsetLenientTypeCast(boolean lenientTypeCast)voidsetObjcCompatible(boolean objcCompatible)voidsetProjectName(String projectName)voidsetResponseAs(String[] responseAs)voidsetSwiftUseApiNamespace(boolean swiftUseApiNamespace)voidsetUnwrapRequired(boolean unwrapRequired)StringtoApiName(String name)Output the API (class) name (capitalized) ending with "Api" Return DefaultApi if name is emptyStringtoDefaultValue(io.swagger.v3.oas.models.media.Schema schema)Return the default value of the propertyStringtoEnumDefaultValue(String value, String datatype)Return the enum default value in the language specified formatStringtoEnumName(io.swagger.codegen.v3.CodegenProperty property)Return the Enum name (e.g.StringtoEnumValue(String value, String datatype)Return the enum value in the language specified format e.g.StringtoEnumVarName(String name, String datatype)Return the sanitized variable name for enumStringtoInstantiationType(io.swagger.v3.oas.models.media.Schema schema)Return the instantiation type of the property, especially for map and arrayStringtoModelFilename(String name)Return the capitalized file name of the model.StringtoModelName(String name)Output the proper model name (capitalized).StringtoOperationId(String operationId)Return the operation ID (method name)StringtoParamName(String name)Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.StringtoVarName(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.v3.generators.DefaultCodegenConfig
addCodegenContentParameters, addConsumesInfo, addHandlebarHelpers, addImport, additionalProperties, addOperationImports, addOperationToGroup, addOption, addOption, addParameters, addParentContainer, addProducesInfo, addProperties, addRegularExpressionDelimiter, addSwitch, addVars, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, camelize, camelize, cliOptions, configFiles, configureDataForTestTemplate, configuresParameterForMediaType, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, copyFirstAllOfProperties, customTemplateDir, dashize, defaultIgnoreImportMappingOption, defaultIncludes, detectParent, embeddedTemplateDir, ensureUniqueParameters, escapeText, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fixUpParentAndInterfaces, fromModel, fromOperation, fromOperation, fromParameter, fromProperty, fromRequestBody, fromResponse, fromSecurity, generateExamplePath, getAlias, getCollectionFormat, getCommonTemplateDir, getConsumesInfo, getContentType, getGitRepoBaseURL, getGitRepoId, getGitUserId, getHideGenerationTimestamp, getHttpUserAgent, getIgnoreFilePathOverride, getIgnoreImportMapping, getInnerEnumAllowableValues, getInputSpec, getInputURL, getLanguageArguments, getLibrary, getOpenAPI, getOptionValue, getOrGenerateOperationId, getOutputDir, getParameterFromRef, getParentName, getProducesInfo, getReleaseNote, getSchemaFromBody, getSchemaFromParameter, getSchemaFromResponse, getSchemaHandler, getSortParamsByRequiredFlag, getSymbolName, getTemplateDir, getTemplateEngine, getTemplateVersion, getterAndSetterCapitalize, getTypeDeclaration, hasSchemaProperties, hasTrueAdditionalProperties, importMapping, initialCaps, instantiationTypes, isFileTypeSchema, isObjectSchema, isPrimivite, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isSkipOverwrite, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, needsUnflattenedSpec, needToImport, outputFolder, postProcessAllCodegenModels, postProcessAllModels, postProcessModels, postProcessModelsEnum, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processMapSchema, processModelEnums, processOpenAPI, processPropertySchemaContainerTypes, processPropertySchemaTypes, readLanguageArguments, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setAllowUnicodeIdentifiers, setApiPackage, setCommonTemplateDir, setEnsureUniqueParams, setGitRepoBaseURL, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setIgnoreImportMapping, setInputSpec, setInputURL, setLanguageArguments, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterExampleValue, setParameterJson, setParameterNullable, setReleaseNote, setRemoveOperationIdPrefix, setReservedWords, setReservedWordsLowerCase, setSchemaProperties, setSkipOverwrite, setSortParamsByRequiredFlag, setTemplateDir, setTemplateEngine, setTemplateVersion, setUnflattenedOpenAPI, setUseOas2, shouldOverwrite, snakeCase, supportedLibraries, supportingFiles, templateDir, testPackage, toApiDocFilename, toApiFilename, toApiImport, toApiTestFilename, toApiVarName, toBooleanGetter, toDefaultValueWithParam, toExamples, toExampleValue, toGetter, toModelDocFilename, toModelImport, toModelTestFilename, toRegularExpression, toSetter, typeMapping, underscore, updateCodegenModelEnumVars, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writeOptional, writeOptional, writePropertyBack
-
-
-
-
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
-
MODEL_CLASSES
protected static final String MODEL_CLASSES
- See Also:
- Constant Field Values
-
USE_MODEL_CLASSES
protected static final String USE_MODEL_CLASSES
- See Also:
- Constant Field Values
-
RESPONSE_LIBRARIES
protected static final String[] RESPONSE_LIBRARIES
-
sourceFolder
protected String sourceFolder
-
-
Method Detail
-
getArgumentsLocation
public String getArgumentsLocation()
- Overrides:
getArgumentsLocationin classDefaultCodegenConfig
-
getTag
public io.swagger.codegen.v3.CodegenType getTag()
-
getHelp
public String getHelp()
-
addAdditionPropertiesToCodeGenModel
protected void addAdditionPropertiesToCodeGenModel(io.swagger.codegen.v3.CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)- Overrides:
addAdditionPropertiesToCodeGenModelin classDefaultCodegenConfig
-
processOpts
public void processOpts()
- Specified by:
processOptsin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
processOptsin classDefaultCodegenConfig
-
isReservedWord
protected boolean isReservedWord(String word)
- Overrides:
isReservedWordin classDefaultCodegenConfig
-
escapeReservedWord
public String escapeReservedWord(String name)
Description copied from class:DefaultCodegenConfigReturn the escaped name of the reserved word- Specified by:
escapeReservedWordin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
escapeReservedWordin classDefaultCodegenConfig- 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:
modelFileFolderin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
modelFileFolderin classDefaultCodegenConfig
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolderin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
apiFileFolderin classDefaultCodegenConfig
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema propertySchema)
Description copied from class:DefaultCodegenConfigOutput the type declaration of the property- Specified by:
getTypeDeclarationin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegenConfig- Parameters:
propertySchema- Schema Property object- Returns:
- a string presentation of the property type
-
getSchemaType
public String getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenConfigreturns the swagger type for the property- Overrides:
getSchemaTypein classDefaultCodegenConfig- Parameters:
schema- Schema property object- Returns:
- string presentation of the type
-
isDataTypeFile
public boolean isDataTypeFile(String dataType)
- Overrides:
isDataTypeFilein classDefaultCodegenConfig
-
isDataTypeBinary
public boolean isDataTypeBinary(String dataType)
- Overrides:
isDataTypeBinaryin classDefaultCodegenConfig
-
toModelName
public String toModelName(String name)
Output the proper model name (capitalized).- Specified by:
toModelNamein interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
toModelNamein classDefaultCodegenConfig- 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:
toModelFilenamein interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
toModelFilenamein classDefaultCodegenConfig- Parameters:
name- the model name- Returns:
- the file name of the model
-
toDefaultValue
public String toDefaultValue(io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenConfigReturn the default value of the property- Overrides:
toDefaultValuein classDefaultCodegenConfig- Parameters:
schema- Schema property object- Returns:
- string presentation of the default value of the property
-
toInstantiationType
public String toInstantiationType(io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenConfigReturn the instantiation type of the property, especially for map and array- Overrides:
toInstantiationTypein classDefaultCodegenConfig- Parameters:
schema- Swagger property object- Returns:
- string presentation of the instantiation type of the property
-
toApiName
public String toApiName(String name)
Description copied from class:DefaultCodegenConfigOutput the API (class) name (capitalized) ending with "Api" Return DefaultApi if name is empty- Specified by:
toApiNamein interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
toApiNamein classDefaultCodegenConfig- Parameters:
name- the name of the Api- Returns:
- capitalized Api name ending with "Api"
-
toOperationId
public String toOperationId(String operationId)
Description copied from class:DefaultCodegenConfigReturn the operation ID (method name)- Overrides:
toOperationIdin classDefaultCodegenConfig- Parameters:
operationId- operation ID- Returns:
- the sanitized method name
-
toVarName
public String toVarName(String name)
Description copied from class:DefaultCodegenConfigReturn the variable name by removing invalid characters and proper escaping if it's a reserved word.- Overrides:
toVarNamein classDefaultCodegenConfig- Parameters:
name- the variable name- Returns:
- the sanitized variable name
-
toParamName
public String toParamName(String name)
Description copied from class:DefaultCodegenConfigReturn the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamNamein interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
toParamNamein classDefaultCodegenConfig- Parameters:
name- Codegen property object- Returns:
- the sanitized parameter name
-
fromModel
public io.swagger.codegen.v3.CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allDefinitions)
Description copied from class:DefaultCodegenConfigConvert Swagger Model object to Codegen Model object- Specified by:
fromModelin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
fromModelin classDefaultCodegenConfig- Parameters:
name- the name of the modelschema- Swagger Model objectallDefinitions- a map of all Swagger models from the spec- Returns:
- Codegen Model object
-
getDefaultTemplateDir
public String getDefaultTemplateDir()
- Specified by:
getDefaultTemplateDirin classDefaultCodegenConfig
-
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:DefaultCodegenConfigReturn the enum value in the language specified format e.g. status becomes "status"- Overrides:
toEnumValuein classDefaultCodegenConfig- 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:DefaultCodegenConfigReturn the enum default value in the language specified format- Overrides:
toEnumDefaultValuein classDefaultCodegenConfig- 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:DefaultCodegenConfigReturn the sanitized variable name for enum- Overrides:
toEnumVarNamein classDefaultCodegenConfig- Parameters:
name- enum variable namedatatype- data type- Returns:
- the sanitized variable name for enum
-
toEnumName
public String toEnumName(io.swagger.codegen.v3.CodegenProperty property)
Description copied from class:DefaultCodegenConfigReturn the Enum name (e.g. StatusEnum given 'status')- Overrides:
toEnumNamein classDefaultCodegenConfig- Parameters:
property- Codegen property- Returns:
- the Enum name
-
postProcessModelProperty
public void postProcessModelProperty(io.swagger.codegen.v3.CodegenModel model, io.swagger.codegen.v3.CodegenProperty property)- Specified by:
postProcessModelPropertyin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
postProcessModelPropertyin classDefaultCodegenConfig
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Description copied from class:DefaultCodegenConfigEscape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMarkin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
escapeQuotationMarkin classDefaultCodegenConfig- 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:DefaultCodegenConfigoverride with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharactersin interfaceio.swagger.codegen.v3.CodegenConfig- Overrides:
escapeUnsafeCharactersin classDefaultCodegenConfig- Parameters:
input- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
-