Package io.swagger.codegen.languages
Class AbstractPhpCodegen
- java.lang.Object
-
- io.swagger.codegen.DefaultCodegen
-
- io.swagger.codegen.languages.AbstractPhpCodegen
-
- All Implemented Interfaces:
CodegenConfig
- Direct Known Subclasses:
LumenServerCodegen,SymfonyServerCodegen,ZendExpressivePathHandlerServerCodegen
public abstract class AbstractPhpCodegen extends DefaultCodegen implements CodegenConfig
-
-
Field Summary
Fields Modifier and Type Field Description protected StringapiDirNameprotected StringapiDocPathprotected StringartifactVersionprotected StringdocsBasePathprotected StringinvokerPackageprotected StringmodelDirNameprotected StringmodelDocPathstatic StringPACKAGE_PATHprotected StringpackagePathstatic StringSRC_BASE_PATHprotected StringsrcBasePathprotected StringtestBasePathstatic StringVARIABLE_NAMING_CONVENTIONprotected StringvariableNamingConvention-
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, 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 AbstractPhpCodegen()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description StringapiDocFileFolder()StringapiFileFolder()StringapiTestFileFolder()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 injectionprotected StringextractSimpleName(String phpClassName)StringgetInvokerPackage()StringgetPackagePath()StringgetSwaggerType(io.swagger.models.properties.Property p)returns the swagger type for the propertyStringgetTypeDeclaration(io.swagger.models.properties.Property p)Output the type declaration of the propertyStringgetTypeDeclaration(String name)Output the type declaration of a given nameStringmodelDocFileFolder()StringmodelFileFolder()StringmodelTestFileFolder()Map<String,Object>postProcessModels(Map<String,Object> objs)Map<String,Object>postProcessOperations(Map<String,Object> objs)voidprocessOpts()voidsetArtifactVersion(String artifactVersion)voidsetInvokerPackage(String invokerPackage)voidsetPackagePath(String packagePath)voidsetParameterExampleValue(CodegenParameter p)Return the example value of the parameter.voidsetParameterNamingConvention(String variableNamingConvention)voidsetSrcBasePath(String srcBasePath)StringtoApiDocFilename(String name)Return the file name of the Api DocumentationStringtoDefaultValue(io.swagger.models.properties.Property p)Return the default value of the propertyStringtoEnumDefaultValue(String value, String datatype)Return the enum default value in the language specified formatStringtoEnumName(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 enumStringtoModelDocFilename(String name)Return the capitalized file name of the model documentationStringtoModelFilename(String name)Return the capitalized file name of the modelStringtoModelName(String name)Output the proper model name (capitalized).StringtoModelTestFilename(String name)Return the capitalized file name of the model testStringtoOperationId(String operationId)Return the operation ID (method name)StringtoPackagePath(String packageName, String basePath)StringtoParamName(String name)Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.StringtoSrcPath(String packageName, String basePath)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.DefaultCodegen
addAdditionPropertiesToCodeGenModel, addImport, additionalProperties, addOperationToGroup, addOption, addOption, addParentContainer, addProperties, addRegularExpressionDelimiter, addSwitch, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, buildLibraryCliOption, camelize, camelize, cliOptions, configureDataForTestTemplate, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, dashize, defaultIgnoreImportMappingOption, defaultIncludes, embeddedTemplateDir, ensureUniqueName, escapeText, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fixUpParentAndInterfaces, fromModel, 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, importMapping, initalizeSpecialCharacterMapping, initialCaps, instantiationTypes, isDataTypeBinary, isDataTypeFile, isHideGenerationTimestamp, isModelObject, isPrimivite, isPropertyInnerMostEnum, isRemoveOperationIdPrefix, isReservedWord, isSkipOverwrite, isUsingFlattenSpec, languageSpecificPrimitives, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestTemplateFiles, needToImport, outputFolder, postProcessAllModels, postProcessModelProperties, postProcessModelProperty, postProcessModelsEnum, 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, setReleaseNote, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipAliasGeneration, setSkipOverwrite, setSortParamsByRequiredFlag, setTemplateDir, shouldOverwrite, snakeCase, supportedLibraries, supportingFiles, templateDir, testPackage, titleCase, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toBooleanGetter, toDefaultValueWithParam, toExamples, toExampleValue, toGetter, toInstantiationType, toModelImport, 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, apiDocFilename, apiDocTemplateFiles, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIgnoreImportMappingOption, defaultIncludes, embeddedTemplateDir, escapeText, fileSuffix, fromModel, fromModel, fromOperation, fromOperation, fromSecurity, generateExamplePath, getCodeName, getCommonTemplateDir, getGitRepoBaseURL, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getIgnoreImportMapping, getInputSpec, getLibrary, getName, getOutputDir, getPriority, getReleaseNote, getSkipAliasGeneration, getTag, importMapping, instantiationTypes, isHideGenerationTimestamp, isPrivileged, isRemoveOperationIdPrefix, isSkipOverwrite, isUsingFlattenSpec, languageSpecificPrimitives, modelDocTemplateFiles, modelFilename, modelPackage, modelTemplateFiles, modelTestTemplateFiles, outputFolder, postProcessAllModels, postProcessModelProperty, 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, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toBooleanGetter, toGetter, toModelImport, toSetter, typeMapping, vendorExtensions
-
-
-
-
Field Detail
-
VARIABLE_NAMING_CONVENTION
public static final String VARIABLE_NAMING_CONVENTION
- See Also:
- Constant Field Values
-
PACKAGE_PATH
public static final String PACKAGE_PATH
- See Also:
- Constant Field Values
-
SRC_BASE_PATH
public static final String SRC_BASE_PATH
- See Also:
- Constant Field Values
-
invokerPackage
protected String invokerPackage
-
packagePath
protected String packagePath
-
artifactVersion
protected String artifactVersion
-
srcBasePath
protected String srcBasePath
-
testBasePath
protected String testBasePath
-
docsBasePath
protected String docsBasePath
-
apiDirName
protected String apiDirName
-
modelDirName
protected String modelDirName
-
variableNamingConvention
protected String variableNamingConvention
-
apiDocPath
protected String apiDocPath
-
modelDocPath
protected String modelDocPath
-
-
Method Detail
-
processOpts
public void processOpts()
- Specified by:
processOptsin interfaceCodegenConfig- Overrides:
processOptsin classDefaultCodegen
-
getPackagePath
public String getPackagePath()
-
escapeReservedWord
public String escapeReservedWord(String name)
Description copied from class:DefaultCodegenReturn the escaped name of the reserved word- Specified by:
escapeReservedWordin interfaceCodegenConfig- Overrides:
escapeReservedWordin classDefaultCodegen- Parameters:
name- the name to be escaped- Returns:
- the escaped reserved word throws Runtime exception as reserved word is not allowed (default behavior)
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolderin interfaceCodegenConfig- Overrides:
apiFileFolderin classDefaultCodegen
-
modelFileFolder
public String modelFileFolder()
- Specified by:
modelFileFolderin interfaceCodegenConfig- Overrides:
modelFileFolderin classDefaultCodegen
-
apiTestFileFolder
public String apiTestFileFolder()
- Specified by:
apiTestFileFolderin interfaceCodegenConfig- Overrides:
apiTestFileFolderin classDefaultCodegen
-
modelTestFileFolder
public String modelTestFileFolder()
- Specified by:
modelTestFileFolderin interfaceCodegenConfig- Overrides:
modelTestFileFolderin classDefaultCodegen
-
apiDocFileFolder
public String apiDocFileFolder()
- Specified by:
apiDocFileFolderin interfaceCodegenConfig- Overrides:
apiDocFileFolderin classDefaultCodegen
-
modelDocFileFolder
public String modelDocFileFolder()
- Specified by:
modelDocFileFolderin interfaceCodegenConfig- Overrides:
modelDocFileFolderin classDefaultCodegen
-
toModelDocFilename
public String toModelDocFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model documentation- Specified by:
toModelDocFilenamein interfaceCodegenConfig- Overrides:
toModelDocFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toApiDocFilename
public String toApiDocFilename(String name)
Description copied from class:DefaultCodegenReturn the file name of the Api Documentation- Specified by:
toApiDocFilenamein interfaceCodegenConfig- Overrides:
toApiDocFilenamein classDefaultCodegen- Parameters:
name- the file name of the Api- Returns:
- the file name of the Api
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.models.properties.Property p)
Description copied from class:DefaultCodegenOutput the type declaration of the property- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegen- Parameters:
p- Swagger Property object- Returns:
- a string presentation of the property type
-
getTypeDeclaration
public String getTypeDeclaration(String name)
Description copied from class:DefaultCodegenOutput the type declaration of a given name- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegen- Parameters:
name- name- Returns:
- a string presentation of the type
-
getSwaggerType
public String getSwaggerType(io.swagger.models.properties.Property p)
Description copied from class:DefaultCodegenreturns the swagger type for the property- Overrides:
getSwaggerTypein classDefaultCodegen- Parameters:
p- Swagger property object- Returns:
- string presentation of the type
-
getInvokerPackage
public String getInvokerPackage()
-
setInvokerPackage
public void setInvokerPackage(String invokerPackage)
-
setArtifactVersion
public void setArtifactVersion(String artifactVersion)
-
setPackagePath
public void setPackagePath(String packagePath)
-
setSrcBasePath
public void setSrcBasePath(String srcBasePath)
-
setParameterNamingConvention
public void setParameterNamingConvention(String variableNamingConvention)
-
toVarName
public String toVarName(String name)
Description copied from class:DefaultCodegenReturn the variable name by removing invalid characters and proper escaping if it's a reserved word.- Overrides:
toVarNamein classDefaultCodegen- Parameters:
name- the variable name- Returns:
- the sanitized variable name
-
toParamName
public String toParamName(String name)
Description copied from class:DefaultCodegenReturn the parameter name by removing invalid characters and proper escaping if it's a reserved word.- Specified by:
toParamNamein interfaceCodegenConfig- Overrides:
toParamNamein classDefaultCodegen- Parameters:
name- Codegen property object- Returns:
- the sanitized parameter name
-
toModelName
public String toModelName(String name)
Description copied from class:DefaultCodegenOutput the proper model name (capitalized). In case the name belongs to the TypeSystem it won't be renamed.- Specified by:
toModelNamein interfaceCodegenConfig- Overrides:
toModelNamein classDefaultCodegen- Parameters:
name- the name of the model- Returns:
- capitalized model name
-
toModelFilename
public String toModelFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model- Specified by:
toModelFilenamein interfaceCodegenConfig- Overrides:
toModelFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toModelTestFilename
public String toModelTestFilename(String name)
Description copied from class:DefaultCodegenReturn the capitalized file name of the model test- Specified by:
toModelTestFilenamein interfaceCodegenConfig- Overrides:
toModelTestFilenamein classDefaultCodegen- Parameters:
name- the model name- Returns:
- the file name of the model
-
toOperationId
public String toOperationId(String operationId)
Description copied from class:DefaultCodegenReturn the operation ID (method name)- Overrides:
toOperationIdin classDefaultCodegen- Parameters:
operationId- operation ID- Returns:
- the sanitized method name
-
toDefaultValue
public String toDefaultValue(io.swagger.models.properties.Property p)
Return the default value of the property- Overrides:
toDefaultValuein classDefaultCodegen- Parameters:
p- Swagger property object- Returns:
- string presentation of the default value of the property
-
setParameterExampleValue
public void setParameterExampleValue(CodegenParameter p)
Description copied from class:DefaultCodegenReturn the example value of the parameter.- Overrides:
setParameterExampleValuein classDefaultCodegen- Parameters:
p- Swagger property object
-
toEnumValue
public String toEnumValue(String value, String datatype)
Description copied from class:DefaultCodegenReturn the enum value in the language specified format e.g. status becomes "status"- Overrides:
toEnumValuein 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:DefaultCodegenReturn the enum default value in the language specified format- Overrides:
toEnumDefaultValuein 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:DefaultCodegenReturn the sanitized variable name for enum- Overrides:
toEnumVarNamein 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:DefaultCodegenReturn the Enum name (e.g. StatusEnum given 'status')- Overrides:
toEnumNamein classDefaultCodegen- Parameters:
property- Codegen property- Returns:
- the Enum name
-
postProcessModels
public Map<String,Object> postProcessModels(Map<String,Object> objs)
- Specified by:
postProcessModelsin interfaceCodegenConfig- Overrides:
postProcessModelsin classDefaultCodegen
-
postProcessOperations
public Map<String,Object> postProcessOperations(Map<String,Object> objs)
- Specified by:
postProcessOperationsin interfaceCodegenConfig- Overrides:
postProcessOperationsin classDefaultCodegen
-
escapeQuotationMark
public String escapeQuotationMark(String input)
Description copied from class:DefaultCodegenEscape single and/or double quote to avoid code injection- Specified by:
escapeQuotationMarkin interfaceCodegenConfig- Overrides:
escapeQuotationMarkin 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:DefaultCodegenoverride with any special text escaping logic to handle unsafe characters so as to avoid code injection- Specified by:
escapeUnsafeCharactersin interfaceCodegenConfig- Overrides:
escapeUnsafeCharactersin classDefaultCodegen- Parameters:
input- String to be cleaned up- Returns:
- string with unsafe characters removed or escaped
-
-