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, DEFAULT_CONTENT_TYPE, defaultIncludes, embeddedTemplateDir, ensureUniqueParams, fileSuffix, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importMapping, inputSpec, instantiationTypes, languageSpecificPrimitives, library, LOGGER, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, releaseNote, removeOperationIdPrefix, REQUEST_BODY_NAME, reservedWords, reservedWordsMappings, 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.v3.oas.models.Operation operation,
Map<String,io.swagger.v3.oas.models.media.Schema> schemas,
io.swagger.v3.oas.models.OpenAPI openAPI)
Convert Swagger Operation object to Codegen Operation object
|
CodegenProperty |
fromProperty(String name,
io.swagger.v3.oas.models.media.Schema propertySchema)
Convert Swagger Property object to Codegen Property object
|
String |
getHelp() |
String |
getName() |
String |
getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
returns the swagger type for the property
|
CodegenType |
getTag() |
String |
getTypeDeclaration(io.swagger.v3.oas.models.media.Schema propertySchema)
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.v3.oas.models.media.Schema schema)
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.v3.oas.models.media.Schema schema)
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, addConsumesInfo, addHandlebarHelpers, addImport, additionalProperties, addOperationToGroup, addProducesInfo, addProperties, addRegularExpressionDelimiter, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, camelize, camelize, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, dashize, defaultIncludes, detectParent, embeddedTemplateDir, escapeText, fileSuffix, findMethodResponse, fromModel, fromModel, fromOperation, fromParameter, fromRequestBody, fromResponse, fromSecurity, generateExamplePath, getAlias, getCollectionFormat, getCommonTemplateDir, getConsumesInfo, getContentType, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getLibrary, getOrGenerateOperationId, getOutputDir, getParameterFromRef, getParentName, getProducesInfo, getReleaseNote, getSchemaFromBody, getSchemaFromResponse, getSimpleRef, getSymbolName, getterAndSetterCapitalize, getTypeDeclaration, hasSchemaProperties, importMapping, initialCaps, instantiationTypes, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isSkipOverwrite, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, needToImport, outputFolder, postProcessAllModels, postProcessModelProperty, postProcessModelsEnum, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, setAllowUnicodeIdentifiers, setApiPackage, setCommonTemplateDir, setEnsureUniqueParams, setGitRepoId, setGitUserId, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterExampleValue, setReleaseNote, setRemoveOperationIdPrefix, setReservedWordsLowerCase, 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, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writeOptional, writePropertyBack
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
addHandlebarHelpers, additionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, embeddedTemplateDir, escapeText, fileSuffix, fromModel, fromModel, fromOperation, fromSecurity, generateExamplePath, getCommonTemplateDir, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getTypeDeclaration, importMapping, instantiationTypes, isRemoveOperationIdPrefix, isSkipOverwrite, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessModelProperty, postProcessOperations, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, reservedWords, reservedWordsMappings, sanitizeTag, setGitRepoId, setGitUserId, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOutputDir, setReleaseNote, setRemoveOperationIdPrefix, 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
getTag
in class DefaultCodegen
public String getName()
getName
in interface CodegenConfig
getName
in class DefaultCodegen
public String getHelp()
getHelp
in interface CodegenConfig
getHelp
in class DefaultCodegen
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.v3.oas.models.media.Schema propertySchema)
DefaultCodegen
getTypeDeclaration
in interface CodegenConfig
getTypeDeclaration
in class DefaultCodegen
propertySchema
- Schema Property objectpublic String getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
DefaultCodegen
getSchemaType
in class DefaultCodegen
schema
- Schema 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.v3.oas.models.media.Schema schema)
DefaultCodegen
toDefaultValue
in class DefaultCodegen
schema
- Schema property objectpublic String toInstantiationType(io.swagger.v3.oas.models.media.Schema schema)
DefaultCodegen
toInstantiationType
in class DefaultCodegen
schema
- Swagger property objectpublic CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema propertySchema)
DefaultCodegen
fromProperty
in class DefaultCodegen
name
- name of the propertypropertySchema
- Schema 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.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, io.swagger.v3.oas.models.OpenAPI openAPI)
DefaultCodegen
fromOperation
in interface CodegenConfig
fromOperation
in class DefaultCodegen
path
- the path of the operationhttpMethod
- HTTP methodoperation
- Swagger operation objectschemas
- a map of schemasopenAPI
- a OpenAPI 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 © 2018. All rights reserved.