public class DefaultCodegen extends Object implements CodegenConfig
| 构造器和说明 |
|---|
DefaultCodegen()
Default constructor.
|
| 限定符和类型 | 方法和说明 |
|---|---|
protected void |
addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel,
io.swagger.v3.oas.models.media.Schema schema) |
protected void |
addImport(CodegenModel m,
String type) |
Map<String,Object> |
additionalProperties() |
void |
addOperationToGroup(String tag,
String resourcePath,
io.swagger.v3.oas.models.Operation operation,
CodegenOperation co,
Map<String,List<CodegenOperation>> operations)
Add operation to group
|
protected void |
addOption(String key,
String description,
String defaultValue) |
protected void |
addProperties(Map<String,io.swagger.v3.oas.models.media.Schema> properties,
List<String> required,
io.swagger.v3.oas.models.media.Schema schema,
Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas) |
String |
addRegularExpressionDelimiter(String pattern)
If the pattern misses the delimiter, add "/" to the beginning and end
Otherwise, return the original pattern
|
protected void |
addSwitch(String key,
String description,
Boolean defaultValue) |
String |
apiDocFileFolder() |
String |
apiDocFilename(String templateName,
String tag)
Return the full path and API documentation file
|
Map<String,String> |
apiDocTemplateFiles() |
String |
apiFileFolder() |
String |
apiFilename(String templateName,
String tag) |
String |
apiPackage() |
Map<String,String> |
apiTemplateFiles() |
String |
apiTestFileFolder() |
String |
apiTestFilename(String templateName,
String tag)
Return the full path and API test file
|
Map<String,String> |
apiTestTemplateFiles() |
protected CliOption |
buildLibraryCliOption(Map<String,String> supportedLibraries) |
static String |
camelize(String word)
已过时。
since version 3.2.3, may be removed with the next major release (4.0)
|
static String |
camelize(String word,
boolean lowercaseFirstLetter)
已过时。
since version 3.2.3, may be removed with the next major release (4.0)
|
List<CliOption> |
cliOptions() |
boolean |
convertPropertyToBoolean(String propertyKey) |
boolean |
convertPropertyToBooleanAndWriteBack(String propertyKey)
reads propertyKey from additionalProperties, converts it to a boolean and
writes it back to additionalProperties to be usable as a boolean in
mustache files.
|
protected String |
dashize(String word)
已过时。
since version 3.2.3, may be removed with the next major release (4.0)
|
Set<String> |
defaultIncludes() |
String |
embeddedTemplateDir() |
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 |
escapeSpecialCharacters(String name,
List<String> charactersToAllow,
String appdendixToReplacement)
已过时。
since version 3.2.3, may be removed with the next major release (4.0)
|
String |
escapeText(String input) |
String |
escapeTextWhileAllowingNewLines(String input)
Escape characters while allowing new lines
|
String |
escapeUnsafeCharacters(String input)
override with any special text escaping logic to handle unsafe
characters so as to avoid code injection
|
String |
fileSuffix() |
String |
findCommonPrefixOfVars(List<Object> vars)
Returns the common prefix of variables for enum naming if
two or more variables are present
|
protected io.swagger.v3.oas.models.responses.ApiResponse |
findMethodResponse(io.swagger.v3.oas.models.responses.ApiResponses responses)
Override with any special handling of response codes
|
CodegenCallback |
fromCallback(String name,
io.swagger.v3.oas.models.callbacks.Callback callback,
Map<String,io.swagger.v3.oas.models.media.Schema> schemas,
io.swagger.v3.oas.models.OpenAPI openAPI)
Convert OAS Callback object to Codegen Callback object
|
CodegenParameter |
fromFormProperty(String name,
io.swagger.v3.oas.models.media.Schema propertySchema,
Set<String> imports) |
CodegenModel |
fromModel(String name,
io.swagger.v3.oas.models.media.Schema schema,
Map<String,io.swagger.v3.oas.models.media.Schema> allDefinitions)
Convert OAS Model object to Codegen Model object
|
CodegenOperation |
fromOperation(String path,
String httpMethod,
io.swagger.v3.oas.models.Operation operation,
Map<String,io.swagger.v3.oas.models.media.Schema> schemas)
Convert OAS Operation object to Codegen Operation object (without providing a OAS object)
|
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 OAS Operation object to Codegen Operation object
|
CodegenParameter |
fromParameter(io.swagger.v3.oas.models.parameters.Parameter parameter,
Set<String> imports)
Convert OAS Parameter object to Codegen Parameter object
|
CodegenProperty |
fromProperty(String name,
io.swagger.v3.oas.models.media.Schema p)
Convert OAS Property object to Codegen Property object
|
CodegenParameter |
fromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody body,
Map<String,io.swagger.v3.oas.models.media.Schema> schemas,
Set<String> imports,
String bodyParameterName) |
List<CodegenParameter> |
fromRequestBodyToFormParameters(io.swagger.v3.oas.models.parameters.RequestBody body,
Map<String,io.swagger.v3.oas.models.media.Schema> schemas,
Set<String> imports) |
CodegenResponse |
fromResponse(io.swagger.v3.oas.models.OpenAPI openAPI,
String responseCode,
io.swagger.v3.oas.models.responses.ApiResponse response)
Convert OAS Response object to Codegen Response object
|
List<CodegenSecurity> |
fromSecurity(Map<String,io.swagger.v3.oas.models.security.SecurityScheme> securitySchemeMap)
Convert map of OAS SecurityScheme objects to a list of Codegen Security objects
|
List<CodegenServer> |
fromServers(List<io.swagger.v3.oas.models.servers.Server> servers) |
List<CodegenServerVariable> |
fromServerVariables(Map<String,io.swagger.v3.oas.models.servers.ServerVariable> variables) |
String |
generateExamplePath(String path,
io.swagger.v3.oas.models.Operation operation)
Return the example path
|
void |
generateJSONSpecFile(Map<String,Object> objs)
generates OpenAPI specification file in JSON format
|
void |
generateYAMLSpecFile(Map<String,Object> objs)
generates OpenAPI specification file in YAML format
|
String |
getAlias(String name)
Determine the type alias for the given type if it exists.
|
protected String |
getCollectionFormat(io.swagger.v3.oas.models.parameters.Parameter parameter) |
String |
getCommonTemplateDir() |
static Set<String> |
getConsumesInfo(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.Operation operation) |
protected String |
getContentType(io.swagger.v3.oas.models.parameters.RequestBody requestBody) |
String |
getDocExtension()
Documentation files extension
|
String |
getGitRepoId()
Git repo ID
|
String |
getGitUserId()
Git user ID
|
String |
getHelp() |
String |
getHttpUserAgent()
HTTP user agent
|
String |
getIgnoreFilePathOverride()
Provides an override location, if any is specified, for the .openapi-generator-ignore.
|
protected Map<String,Object> |
getInnerEnumAllowableValues(CodegenProperty property) |
String |
getInputSpec() |
String |
getLibrary()
Library template (sub-template).
|
protected CodegenProperty |
getMostInnerItems(CodegenProperty property) |
String |
getName() |
protected String |
getOrGenerateOperationId(io.swagger.v3.oas.models.Operation operation,
String path,
String httpMethod)
Get operationId from the operation object, and if it's blank, generate a new one from the given parameters.
|
String |
getOutputDir() |
protected String |
getParameterDataType(io.swagger.v3.oas.models.parameters.Parameter parameter,
io.swagger.v3.oas.models.media.Schema schema)
Returns the data type of a parameter.
|
protected io.swagger.v3.oas.models.parameters.Parameter |
getParameterFromRef(String ref,
io.swagger.v3.oas.models.OpenAPI openAPI) |
protected String |
getParentName(io.swagger.v3.oas.models.media.ComposedSchema composedSchema,
Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas) |
static Set<String> |
getProducesInfo(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.Operation operation)
returns the list of MIME types the APIs can produce
|
String |
getReleaseNote()
Release note
|
String |
getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
returns the OpenAPI type for the property.
|
protected String |
getSymbolName(String input)
Return the symbol name of a symbol
|
CodegenType |
getTag() |
String |
getterAndSetterCapitalize(String name)
Camelize the method name of the getter and setter
|
String |
getTypeDeclaration(io.swagger.v3.oas.models.media.Schema schema)
Output the type declaration of the property
|
String |
getTypeDeclaration(String name)
Output the type declaration of a given name
|
boolean |
hasBodyParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.Operation operation) |
boolean |
hasFormParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.Operation operation) |
Map<String,String> |
importMapping() |
protected void |
initalizeSpecialCharacterMapping()
Initialize special character mapping
|
String |
initialCaps(String name)
Capitalize the string
|
Map<String,String> |
instantiationTypes() |
boolean |
isDataTypeBinary(String dataType) |
boolean |
isDataTypeFile(String dataType) |
boolean |
isDataTypeString(String dataType)
checks if the data should be classified as "string" in enum
e.g. double in C# needs to be double-quoted (e.g. "2.8") by treating it as a string
In the future, we may rename this function to "isEnumString"
|
boolean |
isEnablePostProcessFile()
Boolean value indicating the state of the option for post-processing file using envirionment variables.
|
boolean |
isHideGenerationTimestamp() |
boolean |
isParameterNameUnique(CodegenParameter p,
List<CodegenParameter> parameters) |
protected Boolean |
isPropertyInnerMostEnum(CodegenProperty property)
Update property for map container
|
boolean |
isRemoveOperationIdPrefix() |
protected boolean |
isReservedWord(String word) |
boolean |
isSkipOverwrite() |
Set<String> |
languageSpecificPrimitives() |
String |
modelDocFileFolder() |
Map<String,String> |
modelDocTemplateFiles() |
String |
modelFileFolder() |
String |
modelPackage() |
Map<String,String> |
modelTemplateFiles() |
String |
modelTestFileFolder() |
Map<String,String> |
modelTestTemplateFiles() |
protected boolean |
needToImport(String type)
Check the type to see if it needs import the library/module/package
|
String |
outputFolder() |
Map<String,Object> |
postProcessAllModels(Map<String,Object> objs) |
void |
postProcessFile(File file,
String fileType)
Post-process the auto-generated file, e.g. using go-fmt to format the Go code.
|
void |
postProcessModelProperty(CodegenModel model,
CodegenProperty property) |
Map<String,Object> |
postProcessModels(Map<String,Object> objs) |
Map<String,Object> |
postProcessModelsEnum(Map<String,Object> objs)
post process enum defined in model's properties
|
Map<String,Object> |
postProcessOperations(Map<String,Object> objs) |
Map<String,Object> |
postProcessOperationsWithModels(Map<String,Object> objs,
List<Object> allModels) |
void |
postProcessParameter(CodegenParameter parameter) |
Map<String,Object> |
postProcessSupportingFileData(Map<String,Object> objs) |
void |
preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI) |
com.samskivert.mustache.Mustache.Compiler |
processCompiler(com.samskivert.mustache.Mustache.Compiler compiler) |
void |
processOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI) |
void |
processOpts() |
String |
removeNonNameElementToCamelCase(String name)
Remove characters not suitable for variable or method name from the input and camelize it
|
protected String |
removeNonNameElementToCamelCase(String name,
String nonNameElementPattern)
Remove characters that is not good to be included in method name from the input and camelize it
|
Set<String> |
reservedWords() |
Map<String,String> |
reservedWordsMappings() |
String |
sanitizeName(String name)
Sanitize name (parameter, property, method, etc)
|
String |
sanitizeName(String name,
String removeCharRegEx)
Sanitize name (parameter, property, method, etc)
|
String |
sanitizeTag(String tag)
Sanitize tag
|
void |
setAllowUnicodeIdentifiers(Boolean allowUnicodeIdentifiers) |
void |
setApiPackage(String apiPackage) |
void |
setCommonTemplateDir(String commonTemplateDir) |
void |
setDocExtension(String userDocExtension)
Set Documentation files extension
|
void |
setEnablePostProcessFile(boolean enablePostProcessFile)
Set the boolean value indicating the state of the option for post-processing file using envirionment variables.
|
void |
setEnsureUniqueParams(Boolean ensureUniqueParams) |
void |
setGitRepoId(String gitRepoId)
Set Git repo ID.
|
void |
setGitUserId(String gitUserId)
Set Git user ID.
|
void |
setGlobalOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
Set global OpenAPI based on OpenAPI object
|
void |
setGlobalSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
Set global schema based on OpenAPI object
|
void |
setHideGenerationTimestamp(boolean hideGenerationTimestamp) |
void |
setHttpUserAgent(String httpUserAgent)
Set HTTP user agent.
|
void |
setIgnoreFilePathOverride(String ignoreFileOverride)
Sets an override location for the '.openapi-generator-ignore' location for the first code generation.
|
void |
setInputSpec(String inputSpec) |
void |
setLibrary(String library)
Set library template (sub-template).
|
void |
setModelNamePrefix(String modelNamePrefix) |
void |
setModelNameSuffix(String modelNameSuffix) |
void |
setModelPackage(String modelPackage) |
protected void |
setNonArrayMapProperty(CodegenProperty property,
String type) |
void |
setOutputDir(String dir) |
void |
setParameterBooleanFlagWithCodegenProperty(CodegenParameter parameter,
CodegenProperty property)
Set CodegenParameter boolean flag using CodegenProperty.
|
void |
setParameterExampleValue(CodegenParameter codegenParameter)
Return the example value of the parameter.
|
void |
setParameterExampleValue(CodegenParameter codegenParameter,
io.swagger.v3.oas.models.parameters.Parameter parameter)
Return the example value of the parameter.
|
void |
setParameterExampleValue(CodegenParameter codegenParameter,
io.swagger.v3.oas.models.parameters.RequestBody requestBody)
Return the example value of the parameter.
|
void |
setPrependFormOrBodyParameters(Boolean prependFormOrBodyParameters) |
void |
setReleaseNote(String releaseNote)
Set release note.
|
void |
setRemoveOperationIdPrefix(boolean removeOperationIdPrefix) |
protected void |
setReservedWordsLowerCase(List<String> words) |
void |
setSkipOverwrite(boolean skipOverwrite) |
void |
setSortParamsByRequiredFlag(Boolean sortParamsByRequiredFlag) |
void |
setTemplateDir(String templateDir) |
boolean |
shouldOverwrite(String filename) |
String |
snakeCase(String name)
Return the snake-case of the string
|
Map<String,String> |
supportedLibraries()
All library templates supported.
|
List<SupportingFile> |
supportingFiles() |
String |
templateDir() |
String |
testPackage() |
String |
toApiDocFilename(String name)
Return the file name of the Api Documentation
|
String |
toApiFilename(String name)
Return the file name of the Api Test
|
String |
toApiImport(String name)
Return the fully-qualified "Api" name for import
|
String |
toApiName(String name)
Output the API (class) name (capitalized) ending with "Api"
Return DefaultApi if name is empty
|
String |
toApiTestFilename(String name)
Return the file name of the Api Test
|
String |
toApiVarName(String name)
Return the variable name in the Api
|
String |
toArrayModelParamName(String name)
Return the parameter name of array of model
|
String |
toBooleanGetter(String name)
Output the Getter name for boolean property, e.g. getActive
|
String |
toDefaultValue(io.swagger.v3.oas.models.media.Schema schema)
Return the default value of the property
|
String |
toDefaultValueWithParam(String name,
io.swagger.v3.oas.models.media.Schema schema)
Return the property initialized from a data object
Useful for initialization with a plain object in Javascript
|
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. status becomes "status"
|
String |
toEnumVarName(String value,
String datatype)
Return the sanitized variable name for enum
|
protected List<Map<String,Object>> |
toExamples(Map<String,Object> examples) |
String |
toExampleValue(io.swagger.v3.oas.models.media.Schema schema)
Return the example value of the property
|
String |
toGetter(String name)
Output the Getter name, e.g. getSize
|
String |
toGetter(String name,
String prefix) |
String |
toInstantiationType(io.swagger.v3.oas.models.media.Schema schema)
Return the instantiation type of the property, especially for map and array
|
String |
toModelDocFilename(String name)
Return the capitalized file name of the model documentation
|
String |
toModelFilename(String name)
Return the capitalized file name of the model
|
String |
toModelImport(String name)
Return the fully-qualified "Model" name for import
|
String |
toModelName(String name)
Output the proper model name (capitalized).
|
String |
toModelTestFilename(String name)
Return the capitalized file name of the model test
|
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 |
toRegularExpression(String pattern)
Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
|
String |
toSetter(String name)
Output the Getter name, e.g. getSize
|
String |
toSetter(String name,
String prefix) |
String |
toVarName(String name)
Return the variable name by removing invalid characters and proper escaping if
it's a reserved word.
|
Map<String,String> |
typeMapping() |
static String |
underscore(String word)
已过时。
since version 3.2.3, may be removed with the next major release (4.0)
|
void |
updateCodegenPropertyEnum(CodegenProperty var)
Update codegen property's enum by adding "enumVars" (with name and value)
|
protected void |
updateDataTypeWithEnumForArray(CodegenProperty property)
Update datatypeWithEnum for array container
|
protected void |
updateDataTypeWithEnumForMap(CodegenProperty property)
Update datatypeWithEnum for map container
|
protected void |
updatePropertyForArray(CodegenProperty property,
CodegenProperty innerProperty)
Update property for array(list) container
|
protected void |
updatePropertyForMap(CodegenProperty property,
CodegenProperty innerProperty)
Update property for map container
|
Map<String,Object> |
vendorExtensions() |
void |
writeOptional(String outputFolder,
SupportingFile supportingFile)
Only write if the file doesn't exist
|
void |
writePropertyBack(String propertyKey,
boolean value) |
protected String inputSpec
protected String outputFolder
protected String modelPackage
protected String apiPackage
protected String fileSuffix
protected String modelNamePrefix
protected String modelNameSuffix
protected String testPackage
protected String templateDir
protected String embeddedTemplateDir
protected String commonTemplateDir
protected List<SupportingFile> supportingFiles
protected boolean skipOverwrite
protected boolean removeOperationIdPrefix
protected boolean supportsInheritance
protected boolean supportsMixins
protected String library
protected Boolean sortParamsByRequiredFlag
protected Boolean ensureUniqueParams
protected Boolean allowUnicodeIdentifiers
protected String gitUserId
protected String gitRepoId
protected String releaseNote
protected String httpUserAgent
protected Boolean hideGenerationTimestamp
protected Boolean prependFormOrBodyParameters
protected String docExtension
protected String ignoreFilePathOverride
protected boolean enablePostProcessFile
protected io.swagger.v3.oas.models.OpenAPI globalOpenAPI
public DefaultCodegen()
public List<CliOption> cliOptions()
cliOptions 在接口中 CodegenConfigpublic void processOpts()
processOpts 在接口中 CodegenConfigpublic Map<String,Object> postProcessAllModels(Map<String,Object> objs)
postProcessAllModels 在接口中 CodegenConfigpublic Map<String,Object> postProcessModels(Map<String,Object> objs)
postProcessModels 在接口中 CodegenConfigpublic Map<String,Object> postProcessModelsEnum(Map<String,Object> objs)
objs - Map of modelspublic String findCommonPrefixOfVars(List<Object> vars)
vars - List of variable namespublic String toEnumDefaultValue(String value, String datatype)
value - enum variable namedatatype - data typepublic String toEnumValue(String value, String datatype)
value - enum variable namedatatype - data typepublic String toEnumVarName(String value, String datatype)
value - enum variable namedatatype - data typepublic void setGlobalOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
setGlobalOpenAPI 在接口中 CodegenConfigopenAPI - OpenAPI objectpublic void setGlobalSchemas(io.swagger.v3.oas.models.OpenAPI openAPI)
setGlobalSchemas 在接口中 CodegenConfigopenAPI - OpenAPI objectpublic Map<String,Object> postProcessOperations(Map<String,Object> objs)
postProcessOperations 在接口中 CodegenConfigobjs - the objects map that will be passed to the templating enginepublic Map<String,Object> postProcessOperationsWithModels(Map<String,Object> objs, List<Object> allModels)
postProcessOperationsWithModels 在接口中 CodegenConfigpublic Map<String,Object> postProcessSupportingFileData(Map<String,Object> objs)
postProcessSupportingFileData 在接口中 CodegenConfigpublic void postProcessModelProperty(CodegenModel model, CodegenProperty property)
postProcessModelProperty 在接口中 CodegenConfigpublic void postProcessParameter(CodegenParameter parameter)
postProcessParameter 在接口中 CodegenConfigpublic void preprocessOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
preprocessOpenAPI 在接口中 CodegenConfigpublic void processOpenAPI(io.swagger.v3.oas.models.OpenAPI openAPI)
processOpenAPI 在接口中 CodegenConfigpublic com.samskivert.mustache.Mustache.Compiler processCompiler(com.samskivert.mustache.Mustache.Compiler compiler)
processCompiler 在接口中 CodegenConfigpublic String escapeText(String input)
escapeText 在接口中 CodegenConfigpublic String escapeTextWhileAllowingNewLines(String input)
escapeTextWhileAllowingNewLines 在接口中 CodegenConfiginput - String to be escapedpublic String escapeUnsafeCharacters(String input)
escapeUnsafeCharacters 在接口中 CodegenConfiginput - String to be cleaned uppublic String escapeQuotationMark(String input)
escapeQuotationMark 在接口中 CodegenConfiginput - String to be cleaned uppublic Set<String> defaultIncludes()
defaultIncludes 在接口中 CodegenConfigpublic Map<String,String> typeMapping()
typeMapping 在接口中 CodegenConfigpublic Map<String,String> instantiationTypes()
instantiationTypes 在接口中 CodegenConfigpublic Set<String> reservedWords()
reservedWords 在接口中 CodegenConfigpublic Set<String> languageSpecificPrimitives()
languageSpecificPrimitives 在接口中 CodegenConfigpublic Map<String,String> importMapping()
importMapping 在接口中 CodegenConfigpublic String testPackage()
testPackage 在接口中 CodegenConfigpublic String modelPackage()
modelPackage 在接口中 CodegenConfigpublic String apiPackage()
apiPackage 在接口中 CodegenConfigpublic String fileSuffix()
fileSuffix 在接口中 CodegenConfigpublic String templateDir()
templateDir 在接口中 CodegenConfigpublic String embeddedTemplateDir()
embeddedTemplateDir 在接口中 CodegenConfigpublic String getCommonTemplateDir()
getCommonTemplateDir 在接口中 CodegenConfigpublic void setCommonTemplateDir(String commonTemplateDir)
public Map<String,String> apiDocTemplateFiles()
apiDocTemplateFiles 在接口中 CodegenConfigpublic Map<String,String> modelDocTemplateFiles()
modelDocTemplateFiles 在接口中 CodegenConfigpublic Map<String,String> reservedWordsMappings()
reservedWordsMappings 在接口中 CodegenConfigpublic Map<String,String> apiTestTemplateFiles()
apiTestTemplateFiles 在接口中 CodegenConfigpublic Map<String,String> modelTestTemplateFiles()
modelTestTemplateFiles 在接口中 CodegenConfigpublic Map<String,String> apiTemplateFiles()
apiTemplateFiles 在接口中 CodegenConfigpublic Map<String,String> modelTemplateFiles()
modelTemplateFiles 在接口中 CodegenConfigpublic String apiFileFolder()
apiFileFolder 在接口中 CodegenConfigpublic String modelFileFolder()
modelFileFolder 在接口中 CodegenConfigpublic String apiTestFileFolder()
apiTestFileFolder 在接口中 CodegenConfigpublic String modelTestFileFolder()
modelTestFileFolder 在接口中 CodegenConfigpublic String apiDocFileFolder()
apiDocFileFolder 在接口中 CodegenConfigpublic String modelDocFileFolder()
modelDocFileFolder 在接口中 CodegenConfigpublic Map<String,Object> additionalProperties()
additionalProperties 在接口中 CodegenConfigpublic Map<String,Object> vendorExtensions()
vendorExtensions 在接口中 CodegenConfigpublic List<SupportingFile> supportingFiles()
supportingFiles 在接口中 CodegenConfigpublic String outputFolder()
outputFolder 在接口中 CodegenConfigpublic void setOutputDir(String dir)
setOutputDir 在接口中 CodegenConfigpublic String getOutputDir()
getOutputDir 在接口中 CodegenConfigpublic String getInputSpec()
getInputSpec 在接口中 CodegenConfigpublic void setInputSpec(String inputSpec)
setInputSpec 在接口中 CodegenConfigpublic void setTemplateDir(String templateDir)
public void setModelPackage(String modelPackage)
public void setModelNamePrefix(String modelNamePrefix)
public void setModelNameSuffix(String modelNameSuffix)
public void setApiPackage(String apiPackage)
public void setSortParamsByRequiredFlag(Boolean sortParamsByRequiredFlag)
public void setPrependFormOrBodyParameters(Boolean prependFormOrBodyParameters)
public void setEnsureUniqueParams(Boolean ensureUniqueParams)
public void setAllowUnicodeIdentifiers(Boolean allowUnicodeIdentifiers)
public String toRegularExpression(String pattern)
pattern - the pattern (regular expression)public String toApiFilename(String name)
toApiFilename 在接口中 CodegenConfigname - the file name of the Apipublic String toApiDocFilename(String name)
toApiDocFilename 在接口中 CodegenConfigname - the file name of the Apipublic String toApiTestFilename(String name)
toApiTestFilename 在接口中 CodegenConfigname - the file name of the Apipublic String toApiVarName(String name)
toApiVarName 在接口中 CodegenConfigname - the varible name of the Apipublic String toModelFilename(String name)
toModelFilename 在接口中 CodegenConfigname - the model namepublic String toModelTestFilename(String name)
toModelTestFilename 在接口中 CodegenConfigname - the model namepublic String toModelDocFilename(String name)
toModelDocFilename 在接口中 CodegenConfigname - the model namepublic String toOperationId(String operationId)
operationId - operation IDpublic String toVarName(String name)
name - the variable namepublic String toParamName(String name)
toParamName 在接口中 CodegenConfigname - Codegen property objectpublic String toArrayModelParamName(String name)
name - name of the array modelpublic String toEnumName(CodegenProperty property)
property - Codegen propertypublic String escapeReservedWord(String name)
escapeReservedWord 在接口中 CodegenConfigname - the name to be escapedthrows Runtime exception as reserved word is not allowed (default behavior)
@Deprecated public String escapeSpecialCharacters(String name, List<String> charactersToAllow, String appdendixToReplacement)
name - the name to be escapedcharactersToAllow - characters that are not escapedappdendixToReplacement - String to append to replaced characters.throws Runtime exception as word is not escaped properly.
directly insteadpublic String toModelImport(String name)
toModelImport 在接口中 CodegenConfigname - the name of the "Model"public String toApiImport(String name)
toApiImport 在接口中 CodegenConfigname - the name of the "Api"protected void initalizeSpecialCharacterMapping()
protected String getSymbolName(String input)
input - Symbol (e.g. $)public String generateExamplePath(String path, io.swagger.v3.oas.models.Operation operation)
generateExamplePath 在接口中 CodegenConfigpath - the path of the operationoperation - OAS operation objectpublic String toInstantiationType(io.swagger.v3.oas.models.media.Schema schema)
schema - property schemapublic void setParameterExampleValue(CodegenParameter codegenParameter)
codegenParameter - Codegen parameterpublic void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.Parameter parameter)
codegenParameter - Codegen parameterparameter - Parameterpublic void setParameterExampleValue(CodegenParameter codegenParameter, io.swagger.v3.oas.models.parameters.RequestBody requestBody)
codegenParameter - Codegen parameterrequestBody - Request bodypublic String toExampleValue(io.swagger.v3.oas.models.media.Schema schema)
schema - Property schemapublic String toDefaultValue(io.swagger.v3.oas.models.media.Schema schema)
schema - Property schemapublic String toDefaultValueWithParam(String name, io.swagger.v3.oas.models.media.Schema schema)
name - Name of the property objectschema - Property schemapublic String getSchemaType(io.swagger.v3.oas.models.media.Schema schema)
schema - property schemapublic String snakeCase(String name)
name - string to be snake-casedpublic String initialCaps(String name)
name - string to be capitalizedpublic String getTypeDeclaration(String name)
getTypeDeclaration 在接口中 CodegenConfigname - namepublic String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema schema)
getTypeDeclaration 在接口中 CodegenConfigschema - property schemapublic String getAlias(String name)
name - The type name.public String toBooleanGetter(String name)
toBooleanGetter 在接口中 CodegenConfigname - the name of the propertypublic String toGetter(String name)
toGetter 在接口中 CodegenConfigname - the name of the propertypublic String toSetter(String name)
toSetter 在接口中 CodegenConfigname - the name of the propertypublic String toApiName(String name)
toApiName 在接口中 CodegenConfigname - the name of the Apipublic String toModelName(String name)
toModelName 在接口中 CodegenConfigname - the name of the modelpublic CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allDefinitions)
fromModel 在接口中 CodegenConfigname - the name of the modelschema - OAS Model objectallDefinitions - a map of all OAS models from the specprotected void addAdditionPropertiesToCodeGenModel(CodegenModel codegenModel, io.swagger.v3.oas.models.media.Schema schema)
protected void addProperties(Map<String,io.swagger.v3.oas.models.media.Schema> properties, List<String> required, io.swagger.v3.oas.models.media.Schema schema, Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas)
public String getterAndSetterCapitalize(String name)
name - string to be camelizedpublic CodegenProperty fromProperty(String name, io.swagger.v3.oas.models.media.Schema p)
name - name of the propertyp - OAS property objectprotected void updatePropertyForArray(CodegenProperty property, CodegenProperty innerProperty)
property - Codegen propertyinnerProperty - Codegen inner property of map or listprotected void updatePropertyForMap(CodegenProperty property, CodegenProperty innerProperty)
property - Codegen propertyinnerProperty - Codegen inner property of map or listprotected Boolean isPropertyInnerMostEnum(CodegenProperty property)
property - Codegen propertyprotected CodegenProperty getMostInnerItems(CodegenProperty property)
protected Map<String,Object> getInnerEnumAllowableValues(CodegenProperty property)
protected void updateDataTypeWithEnumForArray(CodegenProperty property)
property - Codegen propertyprotected void updateDataTypeWithEnumForMap(CodegenProperty property)
property - Codegen propertyprotected void setNonArrayMapProperty(CodegenProperty property, String type)
protected io.swagger.v3.oas.models.responses.ApiResponse findMethodResponse(io.swagger.v3.oas.models.responses.ApiResponses responses)
responses - OAS Operation's responsespublic CodegenOperation fromOperation(String path, String httpMethod, io.swagger.v3.oas.models.Operation operation, Map<String,io.swagger.v3.oas.models.media.Schema> schemas)
fromOperation 在接口中 CodegenConfigpath - the path of the operationhttpMethod - HTTP methodoperation - OAS operation objectschemas - a map of OAS modelspublic 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)
fromOperation 在接口中 CodegenConfigpath - the path of the operationhttpMethod - HTTP methodoperation - OAS operation objectschemas - a map of OAS modelsopenAPI - a OAS object representing the specpublic boolean isParameterNameUnique(CodegenParameter p, List<CodegenParameter> parameters)
public CodegenResponse fromResponse(io.swagger.v3.oas.models.OpenAPI openAPI, String responseCode, io.swagger.v3.oas.models.responses.ApiResponse response)
openAPI - a OAS object representing the specresponseCode - HTTP response coderesponse - OAS Response objectpublic CodegenCallback fromCallback(String name, io.swagger.v3.oas.models.callbacks.Callback callback, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, io.swagger.v3.oas.models.OpenAPI openAPI)
name - callback namecallback - OAS Callback objectschemas - a map of OAS modelsopenAPI - a OAS object representing the specpublic CodegenParameter fromParameter(io.swagger.v3.oas.models.parameters.Parameter parameter, Set<String> imports)
parameter - OAS parameter objectimports - set of imports for library/package/moduleprotected String getParameterDataType(io.swagger.v3.oas.models.parameters.Parameter parameter, io.swagger.v3.oas.models.media.Schema schema)
parameter - Parameterschema - Schemapublic boolean isDataTypeBinary(String dataType)
public boolean isDataTypeFile(String dataType)
public List<CodegenSecurity> fromSecurity(Map<String,io.swagger.v3.oas.models.security.SecurityScheme> securitySchemeMap)
fromSecurity 在接口中 CodegenConfigsecuritySchemeMap - a map of OAS SecuritySchemeDefinition objectprotected boolean isReservedWord(String word)
protected String getOrGenerateOperationId(io.swagger.v3.oas.models.Operation operation, String path, String httpMethod)
operation - the operation objectpath - the path of the operationhttpMethod - the HTTP method of the operationprotected boolean needToImport(String type)
type - name of the typepublic void addOperationToGroup(String tag, String resourcePath, io.swagger.v3.oas.models.Operation operation, CodegenOperation co, Map<String,List<CodegenOperation>> operations)
addOperationToGroup 在接口中 CodegenConfigtag - name of the tagresourcePath - path of the resourceoperation - OAS Operation objectco - Codegen Operation objectoperations - map of Codegen operations@Deprecated public static String underscore(String word)
word - The wordStringUtils.underscore(java.lang.String)@Deprecated protected String dashize(String word)
word - The wordStringUtils.dashize(java.lang.String)protected void addImport(CodegenModel m, String type)
public String removeNonNameElementToCamelCase(String name)
name - string to be camelizeprotected String removeNonNameElementToCamelCase(String name, String nonNameElementPattern)
name - string to be camelizenonNameElementPattern - a regex pattern of the characters that is not good to be included in name@Deprecated public static String camelize(String word)
word - string to be camelizeStringUtils.camelize(String)@Deprecated public static String camelize(String word, boolean lowercaseFirstLetter)
word - string to be camelizelowercaseFirstLetter - lower case for first letter if set to trueStringUtils.camelize(String, boolean)public String apiFilename(String templateName, String tag)
apiFilename 在接口中 CodegenConfigpublic String apiDocFilename(String templateName, String tag)
apiDocFilename 在接口中 CodegenConfigtemplateName - template nametag - tagpublic String apiTestFilename(String templateName, String tag)
apiTestFilename 在接口中 CodegenConfigtemplateName - template nametag - tagpublic boolean shouldOverwrite(String filename)
shouldOverwrite 在接口中 CodegenConfigpublic boolean isSkipOverwrite()
isSkipOverwrite 在接口中 CodegenConfigpublic void setSkipOverwrite(boolean skipOverwrite)
setSkipOverwrite 在接口中 CodegenConfigpublic boolean isRemoveOperationIdPrefix()
isRemoveOperationIdPrefix 在接口中 CodegenConfigpublic void setRemoveOperationIdPrefix(boolean removeOperationIdPrefix)
setRemoveOperationIdPrefix 在接口中 CodegenConfigpublic boolean isHideGenerationTimestamp()
isHideGenerationTimestamp 在接口中 CodegenConfigpublic void setHideGenerationTimestamp(boolean hideGenerationTimestamp)
setHideGenerationTimestamp 在接口中 CodegenConfigpublic Map<String,String> supportedLibraries()
supportedLibraries 在接口中 CodegenConfigpublic void setLibrary(String library)
setLibrary 在接口中 CodegenConfiglibrary - Library templatepublic String getLibrary()
getLibrary 在接口中 CodegenConfigpublic void setGitUserId(String gitUserId)
setGitUserId 在接口中 CodegenConfiggitUserId - Git user IDpublic String getGitUserId()
getGitUserId 在接口中 CodegenConfigpublic void setGitRepoId(String gitRepoId)
setGitRepoId 在接口中 CodegenConfiggitRepoId - Git repo IDpublic String getGitRepoId()
getGitRepoId 在接口中 CodegenConfigpublic void setReleaseNote(String releaseNote)
setReleaseNote 在接口中 CodegenConfigreleaseNote - Release notepublic String getReleaseNote()
getReleaseNote 在接口中 CodegenConfigpublic String getDocExtension()
getDocExtension 在接口中 CodegenConfigpublic void setDocExtension(String userDocExtension)
setDocExtension 在接口中 CodegenConfiguserDocExtension - documentation files extensionpublic void setHttpUserAgent(String httpUserAgent)
setHttpUserAgent 在接口中 CodegenConfighttpUserAgent - HTTP user agentpublic String getHttpUserAgent()
getHttpUserAgent 在接口中 CodegenConfigprotected CliOption buildLibraryCliOption(Map<String,String> supportedLibraries)
public String sanitizeName(String name)
sanitizeName 在接口中 CodegenConfigname - string to be sanitizepublic String sanitizeName(String name, String removeCharRegEx)
name - string to be sanitizeremoveCharRegEx - a regex containing all char that will be removedpublic String sanitizeTag(String tag)
sanitizeTag 在接口中 CodegenConfigtag - Tagpublic void writeOptional(String outputFolder, SupportingFile supportingFile)
outputFolder - Output foldersupportingFile - Supporting filepublic void setParameterBooleanFlagWithCodegenProperty(CodegenParameter parameter, CodegenProperty property)
parameter - Codegen Parameterproperty - Codegen propertypublic void updateCodegenPropertyEnum(CodegenProperty var)
var - list of CodegenPropertypublic String addRegularExpressionDelimiter(String pattern)
pattern - the pattern (regular expression)public boolean convertPropertyToBooleanAndWriteBack(String propertyKey)
propertyKey - property keypublic String getIgnoreFilePathOverride()
This is originally intended for the first generation only.
getIgnoreFilePathOverride 在接口中 CodegenConfigpublic void setIgnoreFilePathOverride(String ignoreFileOverride)
setIgnoreFilePathOverride 在接口中 CodegenConfigignoreFileOverride - The full path to an ignore filepublic boolean convertPropertyToBoolean(String propertyKey)
public void writePropertyBack(String propertyKey, boolean value)
protected String getContentType(io.swagger.v3.oas.models.parameters.RequestBody requestBody)
protected io.swagger.v3.oas.models.parameters.Parameter getParameterFromRef(String ref, io.swagger.v3.oas.models.OpenAPI openAPI)
public static Set<String> getConsumesInfo(io.swagger.v3.oas.models.OpenAPI openAPI, io.swagger.v3.oas.models.Operation operation)
public boolean hasFormParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.Operation operation)
public boolean hasBodyParameter(io.swagger.v3.oas.models.OpenAPI openAPI,
io.swagger.v3.oas.models.Operation operation)
public static Set<String> getProducesInfo(io.swagger.v3.oas.models.OpenAPI openAPI, io.swagger.v3.oas.models.Operation operation)
openAPI - current specification instanceoperation - Operationprotected String getParentName(io.swagger.v3.oas.models.media.ComposedSchema composedSchema, Map<String,io.swagger.v3.oas.models.media.Schema> allSchemas)
protected String getCollectionFormat(io.swagger.v3.oas.models.parameters.Parameter parameter)
public CodegenType getTag()
getTag 在接口中 CodegenConfigpublic String getName()
getName 在接口中 CodegenConfigpublic String getHelp()
getHelp 在接口中 CodegenConfigpublic List<CodegenParameter> fromRequestBodyToFormParameters(io.swagger.v3.oas.models.parameters.RequestBody body, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, Set<String> imports)
public CodegenParameter fromFormProperty(String name, io.swagger.v3.oas.models.media.Schema propertySchema, Set<String> imports)
public CodegenParameter fromRequestBody(io.swagger.v3.oas.models.parameters.RequestBody body, Map<String,io.swagger.v3.oas.models.media.Schema> schemas, Set<String> imports, String bodyParameterName)
public void generateJSONSpecFile(Map<String,Object> objs)
objs - map of objectpublic void generateYAMLSpecFile(Map<String,Object> objs)
objs - map of objectpublic boolean isDataTypeString(String dataType)
dataType - data typepublic List<CodegenServer> fromServers(List<io.swagger.v3.oas.models.servers.Server> servers)
fromServers 在接口中 CodegenConfigpublic List<CodegenServerVariable> fromServerVariables(Map<String,io.swagger.v3.oas.models.servers.ServerVariable> variables)
fromServerVariables 在接口中 CodegenConfigpublic void postProcessFile(File file, String fileType)
TODO: store these values in enum instead
postProcessFile 在接口中 CodegenConfigfile - file to be processedfileType - file typepublic boolean isEnablePostProcessFile()
isEnablePostProcessFile 在接口中 CodegenConfigpublic void setEnablePostProcessFile(boolean enablePostProcessFile)
setEnablePostProcessFile 在接口中 CodegenConfigenablePostProcessFile - true to enable post-processing fileCopyright © 2019. All rights reserved.