public class MysqlSchemaCodegen extends DefaultCodegen implements CodegenConfig
| Modifier and Type | Field and Description |
|---|---|
protected String |
columnNamePrefix |
protected String |
columnNameSuffix |
protected String |
databaseNamePrefix |
protected String |
databaseNameSuffix |
static String |
DEFAULT_DATABASE_NAME |
protected String |
defaultDatabaseName |
static Integer |
ENUM_MAX_ELEMENTS |
static Integer |
IDENTIFIER_MAX_LENGTH |
static String |
IDENTIFIER_NAMING_CONVENTION |
protected String |
identifierNamingConvention |
static String |
JSON_DATA_TYPE_ENABLED |
protected Boolean |
jsonDataTypeEnabled |
protected Vector<String> |
mysqlDateAndTimeTypes |
protected Vector<String> |
mysqlNumericTypes |
protected Vector<String> |
mysqlSpatialTypes |
protected Vector<String> |
mysqlStringTypes |
static String |
NAMED_PARAMETERS_ENABLED |
protected Boolean |
namedParametersEnabled |
protected String |
tableNamePrefix |
protected String |
tableNameSuffix |
static String |
VENDOR_EXTENSION_MYSQL_SCHEMA |
additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, cliOptions, DefaultFeatureSet, defaultIncludes, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importMapping, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, modelDocTemplateFiles, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, openAPI, outputFolder, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, reservedWords, reservedWordsMappings, serverVariables, skipOverwrite, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, testPackage, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions| Constructor and Description |
|---|
MysqlSchemaCodegen() |
| Modifier and Type | Method and Description |
|---|---|
String |
escapeMysqlQuotedIdentifier(String identifier)
Escapes MySQL identifier to use it in SQL statements with backticks, eg.
|
String |
escapeMysqlUnquotedIdentifier(String identifier)
Escapes MySQL identifier to use it in SQL statements without backticks, eg.
|
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
|
String |
getDefaultDatabaseName()
Returns default database name for all MySQL queries
This value must be used with backticks only, eg.
|
String |
getHelp() |
String |
getIdentifierNamingConvention()
Returns identifier naming convention for table names and column names.
|
Boolean |
getJsonDataTypeEnabled()
Whether JSON data type enabled or disabled in all MySQL queries
|
String |
getMysqlMatchedIntegerDataType(Long minimum,
Long maximum,
Boolean unsigned)
Finds best fitted MySQL data type for integer variable based on minimum and maximum properties
|
String |
getMysqlMatchedStringDataType(Integer minLength,
Integer maxLength)
Finds best fitted MySQL data type for string variable based on minLength and maxLength properties
|
String |
getName() |
Boolean |
getNamedParametersEnabled()
Whether named parameters enabled or disabled in prepared SQLs
|
CodegenType |
getTag() |
Boolean |
isMysqlDataType(String dataType)
Checks whether string is one of MySQL Data Types
Ref: https://dev.mysql.com/doc/refman/8.0/en/data-type-overview.html
|
void |
postProcessModelProperty(CodegenModel model,
CodegenProperty property) |
Map<String,Object> |
postProcessModels(Map<String,Object> objs) |
void |
processBooleanTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to boolean type and adds related vendor extensions
|
void |
processDateTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to date type and adds related vendor extensions
|
void |
processDecimalTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to decimal type and adds related vendor extensions
|
void |
processIntegerTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to integer type and adds related vendor extensions
|
void |
processJsonTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to JSON type and adds related vendor extensions
|
void |
processOpts() |
void |
processStringTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property mapped to string type and adds related vendor extensions
|
void |
processUnknownTypeProperty(CodegenModel model,
CodegenProperty property)
Processes each model's property not mapped to any type and adds related vendor extensions
Most of time it's related to referenced properties eg.
|
void |
setDefaultDatabaseName(String databaseName)
Sets default database name for all MySQL queries
Provided value will be escaped when necessary
|
void |
setIdentifierNamingConvention(String naming)
Sets identifier naming convention for table names and column names.
|
void |
setJsonDataTypeEnabled(Boolean enabled)
Enables special JSON data type in all MySQL queries
JSON data type requires MySQL version 5.7.8
|
void |
setNamedParametersEnabled(Boolean enabled)
Enables named parameters in prepared SQLs
|
HashMap<String,Object> |
toCodegenMysqlDataTypeArgument(Object value)
Generates codegen property for MySQL data type argument
|
HashMap<String,Object> |
toCodegenMysqlDataTypeDefault(String defaultValue,
String mysqlDataType)
Generates default codegen property for MySQL column definition
Ref: https://dev.mysql.com/doc/refman/5.7/en/data-type-defaults.html
|
String |
toColumnName(String name)
Converts name to valid MySQL column name
Produced name must be used with backticks only, eg.
|
String |
toDatabaseName(String name)
Converts name to valid MySQL database name
Produced name must be used with backticks only, eg.
|
String |
toMysqlIdentifier(String name,
String prefix,
String suffix)
Converts name to valid MySQL identifier which can be used as database, table, column name
Produced name must be used with backticks only, eg.
|
String |
toSrcPath(String packageName)
Slightly modified version of AbstractPhpCodegen.toSrcPath method.
|
String |
toTableName(String name)
Converts name to valid MySQL column name
Produced name must be used with backticks only, eg.
|
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImportsToOneOfInterface, additionalProperties, addMustacheLambdas, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addParentContainer, addProperties, addRegularExpressionDelimiter, addSwitch, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, createDiscriminator, defaultIncludes, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromModel, fromOperation, fromParameter, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, getAdditionalProperties, getAlias, getAllModels, getAllOfDescendants, getAllowUnicodeIdentifiers, getApiNamePrefix, getApiNameSuffix, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDocExtension, getEnsureUniqueParams, getFeatureSet, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getLegacyDiscriminatorBehavior, getLibrary, getModelNamePrefix, getModelNameSuffix, getModelNameToSchemaCache, getMostInnerItems, getOneOfAnyOfDescendants, getOrGenerateOperationId, getOutputDir, getParameterDataType, getPrependFormOrBodyParameters, getProducesInfo, getReleaseNote, getSchemaAdditionalProperties, getSchemaItems, getSchemaType, getSingleSchemaType, getSortModelPropertiesByRequiredFlag, getSortParamsByRequiredFlag, getSymbolName, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getTypeDeclaration, getUseOneOfInterfaces, handleMethodResponse, handleMethodResponse, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, instantiationTypes, isAnyTypeSchema, isDataTypeBinary, isDataTypeFile, isDataTypeString, isEnableMinimalUpdate, isEnablePostProcessFile, isFreeFormObject, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isReservedWord, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, lowerCamelCase, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, modifyFeatureSet, needToImport, outputFolder, postProcess, postProcessAllModels, postProcessFile, postProcessModelsEnum, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, sanitizeTag, serverVariableOverrides, setAllowUnicodeIdentifiers, setApiNamePrefix, setApiNameSuffix, setApiPackage, setCircularReferences, setDisallowAdditionalPropertiesIfNotPresent, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setEnsureUniqueParams, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLegacyDiscriminatorBehavior, setLibrary, setModelNamePrefix, setModelNameSuffix, setModelPackage, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterContentType, setParameterExampleValue, setParameterExampleValue, setParameterExampleValue, setParameterNullable, setPrependFormOrBodyParameters, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOverwrite, setSortModelPropertiesByRequiredFlag, setSortParamsByRequiredFlag, setStrictSpecBehavior, setTemplateDir, setTemplatingEngine, setUseOneOfInterfaces, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toArrayModelParamName, toBooleanGetter, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumName, toEnumValue, toEnumVarName, toExamples, toExampleValue, toGetter, toInstantiationType, toModelDocFilename, toModelFilename, toModelImport, toModelImportMap, toModelName, toModelTestFilename, toOneOfName, toOperationId, toParamName, toRegularExpression, toSetter, toVarName, typeMapping, unaliasSchema, updateAllModels, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateEnumVarsWithExtensions, updateOption, updatePropertyForArray, updatePropertyForMap, vendorExtensions, writePropertyBackclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitadditionalProperties, addOperationToGroup, apiDocFileFolder, apiDocFilename, apiDocTemplateFiles, apiFileFolder, apiFilename, apiPackage, apiTemplateFiles, apiTestFileFolder, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, embeddedTemplateDir, encodePath, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromModel, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, getDocExtension, getFeatureSet, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getOutputDir, getReleaseNote, getTemplatingEngine, getTypeDeclaration, getTypeDeclaration, importMapping, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOverwrite, isStrictSpecBehavior, languageSpecificPrimitives, modelDocFileFolder, modelDocTemplateFiles, modelFileFolder, modelFilename, modelPackage, modelTemplateFiles, modelTestFileFolder, modelTestTemplateFiles, outputFolder, postProcess, postProcessAllModels, postProcessFile, postProcessOperationsWithModels, postProcessParameter, postProcessSupportingFileData, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOverwrite, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, testPackage, toApiDocFilename, toApiFilename, toApiImport, toApiName, toApiTestFilename, toApiVarName, toBooleanGetter, toGetter, toModelDocFilename, toModelFilename, toModelImport, toModelImportMap, toModelName, toModelTestFilename, toParamName, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensionspublic static final String VENDOR_EXTENSION_MYSQL_SCHEMA
public static final String DEFAULT_DATABASE_NAME
public static final String JSON_DATA_TYPE_ENABLED
public static final String IDENTIFIER_NAMING_CONVENTION
public static final String NAMED_PARAMETERS_ENABLED
public static final Integer ENUM_MAX_ELEMENTS
public static final Integer IDENTIFIER_MAX_LENGTH
protected String defaultDatabaseName
protected String databaseNamePrefix
protected String databaseNameSuffix
protected String tableNamePrefix
protected String tableNameSuffix
protected String columnNamePrefix
protected String columnNameSuffix
protected Boolean jsonDataTypeEnabled
protected Boolean namedParametersEnabled
protected String identifierNamingConvention
public CodegenType getTag()
getTag in interface CodegenConfiggetTag in class DefaultCodegenpublic String getName()
getName in interface CodegenConfiggetName in class DefaultCodegenpublic String getHelp()
getHelp in interface CodegenConfiggetHelp in class DefaultCodegenpublic void processOpts()
processOpts in interface CodegenConfigprocessOpts in class DefaultCodegenpublic Map<String,Object> postProcessModels(Map<String,Object> objs)
postProcessModels in interface CodegenConfigpostProcessModels in class DefaultCodegenpublic void postProcessModelProperty(CodegenModel model, CodegenProperty property)
postProcessModelProperty in interface CodegenConfigpostProcessModelProperty in class DefaultCodegenpublic void processIntegerTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processDecimalTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processBooleanTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processStringTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processDateTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processJsonTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic void processUnknownTypeProperty(CodegenModel model, CodegenProperty property)
model - modelproperty - model's propertypublic HashMap<String,Object> toCodegenMysqlDataTypeArgument(Object value)
value - argument valuepublic HashMap<String,Object> toCodegenMysqlDataTypeDefault(String defaultValue, String mysqlDataType)
defaultValue - valuemysqlDataType - MySQL data typepublic String getMysqlMatchedIntegerDataType(Long minimum, Long maximum, Boolean unsigned)
minimum - (optional) codegen propertymaximum - (optional) codegen propertyunsigned - (optional) whether variable is unsigned or notpublic String getMysqlMatchedStringDataType(Integer minLength, Integer maxLength)
minLength - (optional) codegen propertymaxLength - (optional) codegen propertypublic Boolean isMysqlDataType(String dataType)
dataType - which needs to checkpublic String toDatabaseName(String name)
name - source namepublic String toTableName(String name)
name - source namepublic String toColumnName(String name)
name - source namepublic String toMysqlIdentifier(String name, String prefix, String suffix)
name - source nameprefix - when escaped name is digits only, prefix will be prependedsuffix - when escaped name is digits only, suffix will be appendedpublic String escapeMysqlUnquotedIdentifier(String identifier)
identifier - source identifierpublic String escapeMysqlQuotedIdentifier(String identifier)
identifier - source identifierpublic String escapeReservedWord(String name)
DefaultCodegenescapeReservedWord in interface CodegenConfigescapeReservedWord in class DefaultCodegenname - the name to be escapedthrows Runtime exception as reserved word is not allowed (default behavior)
public String escapeQuotationMark(String input)
DefaultCodegenescapeQuotationMark in interface CodegenConfigescapeQuotationMark in class DefaultCodegeninput - String to be cleaned uppublic String escapeUnsafeCharacters(String input)
DefaultCodegenescapeUnsafeCharacters in interface CodegenConfigescapeUnsafeCharacters in class DefaultCodegeninput - String to be cleaned uppublic void setDefaultDatabaseName(String databaseName)
databaseName - source namepublic String getDefaultDatabaseName()
public void setJsonDataTypeEnabled(Boolean enabled)
enabled - true to enable, otherwise falsepublic Boolean getJsonDataTypeEnabled()
public void setNamedParametersEnabled(Boolean enabled)
enabled - true to enable, otherwise falsepublic Boolean getNamedParametersEnabled()
public void setIdentifierNamingConvention(String naming)
naming - identifier naming convention (original|snake_case)public String getIdentifierNamingConvention()
Copyright © 2021. All rights reserved.