Class AbstractKotlinCodegen
- java.lang.Object
-
- org.openapitools.codegen.DefaultCodegen
-
- org.openapitools.codegen.languages.AbstractKotlinCodegen
-
- All Implemented Interfaces:
CodegenConfig
- Direct Known Subclasses:
KotlinClientCodegen,KotlinServerCodegen,KotlinSpringServerCodegen,KotlinVertxServerCodegen,KotlinWiremockServerCodegen,KtormSchemaCodegen
public abstract class AbstractKotlinCodegen extends DefaultCodegen implements CodegenConfig
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description protected static interfaceAbstractKotlinCodegen.DataTypeAssigner
-
Field Summary
Fields Modifier and Type Field Description static StringADDITIONAL_MODEL_TYPE_ANNOTATIONSprotected List<String>additionalModelTypeAnnotationsprotected StringapiDocPathprotected StringapiSuffixprotected StringartifactIdprotected StringartifactVersionprotected CodegenConstants.ENUM_PROPERTY_NAMING_TYPEenumPropertyNamingprotected StringgroupIdstatic StringJAVAX_PACKAGEstatic StringMODEL_MUTABLEstatic StringMODEL_MUTABLE_DESCprotected StringmodelDocPathprotected booleannonPublicApiprotected StringpackageNameprotected booleanparcelizeModelsprotected Set<String>propertyAdditionalKeywordsprotected StringresourcesFolderprotected booleanserializableModelprotected StringsourceFolderprotected StringtestFolderstatic StringUSE_JAKARTA_EEprotected booleanuseJakartaEe-
Fields inherited from class org.openapitools.codegen.DefaultCodegen
additionalProperties, addOneOfInterfaceImports, addOneOfInterfaces, addSuffixToDuplicateOperationNicknames, allowUnicodeIdentifiers, apiDocTemplateFiles, apiNamePrefix, apiNameSuffix, apiPackage, apiTemplateFiles, apiTestTemplateFiles, autosetConstants, cliOptions, DefaultFeatureSet, defaultIncludes, disallowAdditionalPropertiesIfNotPresent, docExtension, embeddedTemplateDir, enableMinimalUpdate, enablePostProcessFile, ensureUniqueParams, enumNameMapping, enumUnknownDefaultCase, enumUnknownDefaultCaseName, falseSchema, filesMetadataFilename, fileSuffix, generatorMetadata, gitHost, gitRepoId, gitUserId, hideGenerationTimestamp, httpUserAgent, ignoreFilePathOverride, importBaseType, importContainerType, importMapping, inlineSchemaNameMapping, inlineSchemaOption, inputSpec, instantiationTypes, JSON_MIME_PATTERN, JSON_VENDOR_MIME_PATTERN, languageSpecificPrimitives, legacyDiscriminatorBehavior, library, loadDeepObjectIntoItems, modelDocTemplateFiles, modelNameMapping, modelNamePrefix, modelNameSuffix, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openAPI, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, prependFormOrBodyParameters, releaseNote, removeEnumValuePrefix, removeOperationIdPrefix, removeOperationIdPrefixCount, removeOperationIdPrefixDelimiter, reservedWords, reservedWordsMappings, schemaMapping, serverVariables, skipOperationExample, skipOverwrite, skipSortingOperations, sortModelPropertiesByRequiredFlag, sortParamsByRequiredFlag, specialCharReplacements, strictSpecBehavior, supportedLibraries, supportingFiles, supportsAdditionalPropertiesWithComposedSchema, supportsInheritance, supportsMixins, supportsMultipleInheritance, templateDir, templateOutputDirs, testPackage, trueSchema, typeAliases, typeMapping, useOneOfInterfaces, vendorExtensions, versionMetadataFilename, XML_MIME_PATTERN
-
-
Constructor Summary
Constructors Constructor Description AbstractKotlinCodegen()
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda>addMustacheLambdas()Preset map builder with commonly used Mustache lambdas.StringapiDocFileFolder()StringapiFileFolder()StringapiTestFileFolder()protected voidapplyJakartaPackage()protected voidapplyJavaxPackage()protected voiddoDataTypeAssignment(String returnType, AbstractKotlinCodegen.DataTypeAssigner dataTypeAssigner)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 injectionCodegenModelfromModel(String name, io.swagger.v3.oas.models.media.Schema schema)Convert OAS Model object to Codegen Model object.GeneratorLanguagegeneratorLanguage()BooleangetParcelizeModels()StringgetSchemaType(io.swagger.v3.oas.models.media.Schema p)returns the OpenAPI type for the propertyStringgetTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)Output the type declaration of the propertybooleanisDataTypeString(String dataType)checks if the data should be classified as "string" in enum e.g.protected booleanisModelMutable()protected booleanisReservedWord(String word)StringmodelDocFileFolder()StringmodelFileFolder()StringmodelTestFileFolder()protected booleanneedToImport(String type)Check the type to see if it needs import the library/module/packagebooleannonPublicApi()Map<String,ModelsMap>postProcessAllModels(Map<String,ModelsMap> objs)voidpostProcessFile(File file, String fileType)Post-process the auto-generated file, e.g.ModelsMappostProcessModels(ModelsMap objs)voidprocessOpts()voidsetEnumPropertyNaming(String enumPropertyNamingType)Sets the naming convention for Kotlin enum propertiesvoidsetParcelizeModels(Boolean parcelizeModels)StringtoApiName(String name)Output the API (class) name (capitalized) ending with the specified or default suffix Return DefaultApi if name is emptyStringtoDefaultParameterValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)Return the default value of the parameterStringtoDefaultValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)Return the default value of the propertyStringtoEnumName(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 value, String datatype)Return the sanitized variable name for enumStringtoModelFilename(String name)Return the capitalized file name of the modelStringtoModelImport(String name)Return the fully-qualified "Model" name for importStringtoModelName(String name)Output the proper model name (capitalized).StringtoOperationId(String operationId)Return the operation ID (method name)StringtoParamName(String name)Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.StringtoRegularExpression(String pattern)Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)protected StringtoVariableName(String name)StringtoVarName(String name)Return the variable name by removing invalid characters and proper escaping if it's a reserved word.protected voidupdateModelForObject(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema)-
Methods inherited from class org.openapitools.codegen.DefaultCodegen
addAdditionPropertiesToCodeGenModel, addBodyModelSchema, addHeaders, addImport, addImport, addImport, addImports, addImports, addImports, addImportsForPropertyType, addImportsToOneOfInterface, additionalProperties, addOneOfInterfaceModel, addOneOfNameExtension, addOperationToGroup, addOption, addOption, addParentContainer, addParentFromContainer, addProperties, addRegularExpressionDelimiter, addRequiredVarsMap, addSwitch, addVars, addVars, addVarsRequiredVarsAdditionalProps, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, buildEnumVars, buildLibraryCliOption, cliOptions, convertPropertyToBoolean, convertPropertyToBooleanAndWriteBack, convertPropertyToBooleanAndWriteBack, convertPropertyToStringAndWriteBack, convertPropertyToTypeAndWriteBack, createDiscriminator, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextInSingleQuotes, escapeTextWhileAllowingNewLines, executePostProcessor, fileSuffix, findCommonPrefixOfVars, findMethodResponse, fromCallback, fromFormProperty, fromOperation, fromParameter, fromProperty, fromProperty, fromProperty, fromRequestBody, fromRequestBodyToFormParameters, fromResponse, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generateJSONSpecFile, generateYAMLSpecFile, generatorLanguageVersion, getAdditionalPropertiesName, getAddSuffixToDuplicateOperationNicknames, getAlias, getAllModels, getAllOfDescendants, getCollectionFormat, getCollectionFormat, getConsumesInfo, getContent, getContentType, getDisallowAdditionalPropertiesIfNotPresent, getDocExtension, getEnumDefaultValue, getEnumUnknownDefaultCase, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInnerEnumAllowableValues, getInputSpec, getItemsName, getLegacyDiscriminatorBehavior, getLibrary, getModelNameToSchemaCache, getMostInnerItems, getName, getOneOfAnyOfDescendants, getOpenapiGeneratorIgnoreList, getOrGenerateOperationId, getOutputDir, getParameterDataType, getProducesInfo, getReleaseNote, getSchemaAdditionalProperties, getSchemaFromBooleanOrSchema, getSingleSchemaType, getSupportedVendorExtensions, getSymbolName, getTag, getTemplatingEngine, getterAndSetterCapitalize, getTypeDeclaration, getUseInlineModelResolver, getUseOneOfInterfaces, getUseOpenapiNormalizer, getVersionMetadataFilename, handleConstantParams, handleMethodResponse, handleMethodResponse, handleSpecialCharacters, hasBodyParameter, hasFormParameter, importMapping, initializeSpecialCharacterMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isDataTypeBinary, isDataTypeFile, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isJsonMimeType, isJsonVendorMimeType, isLibrary, isParameterNameUnique, isPropertyInnerMostEnum, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isTypeErasedGenerics, isXmlMimeType, languageSpecificPrimitives, lowerCamelCase, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestTemplateFiles, modifyFeatureSet, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessEnumVars, postProcessModelProperty, postProcessModelsEnum, postProcessOperationsWithModels, postProcessParameter, postProcessResponseWithProperty, postProcessSupportingFileData, postProcessWebhooksWithModels, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, processTestExampleData, removeImport, removeNonNameElementToCamelCase, removeNonNameElementToCamelCase, removeOption, removeSelfReferenceImports, reservedWords, reservedWordsMappings, sanitizeName, sanitizeName, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setAddProps, setCircularReferences, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setNonArrayMapProperty, setOpenAPI, setOutputDir, setParameterBooleanFlagWithCodegenProperty, setParameterEncodingValues, setParameterExamples, setParameterExampleValue, setParameterExampleValue, setParameterExampleValue, setParameterNullable, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setReservedWordsLowerCase, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, setUseOneOfInterfaces, shouldAddImport, shouldOverwrite, SortModelPropertiesByRequiredFlag, SortParametersByRequiredFlag, specVersionGreaterThanOrEqualTo310, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toAllOfName, toAnyOfName, toApiDocFilename, toApiFilename, toApiImport, toApiTestFilename, toApiVarName, toArrayModelParamName, toBooleanGetter, toDefaultParameterValue, toDefaultValue, toDefaultValueWithParam, toEnumDefaultValue, toEnumDefaultValue, toExamples, toExampleValue, toGetter, toInstantiationType, toMediaTypeSchemaName, toModelDocFilename, toModelImportMap, toModelTestFilename, toOneOfName, toSetter, toTestCaseName, typeMapping, unaliasPropertySchema, unaliasSchema, updateAllModels, updateCodegenPropertyEnum, updateDataTypeWithEnumForArray, updateDataTypeWithEnumForMap, updateEnumVarsWithExtensions, updateModelForAnyType, updateModelForComposedSchema, updateModelForInteger, updateModelForNumber, updateModelForString, updateOption, updateParameterForString, updatePropertyForAnyType, updatePropertyForArray, updatePropertyForInteger, updatePropertyForMap, updatePropertyForMap, updatePropertyForNumber, updatePropertyForObject, updatePropertyForString, updateRequestBodyForArray, updateRequestBodyForMap, updateRequestBodyForObject, updateRequestBodyForPrimitiveType, updateRequestBodyForString, useCodegenAsMustacheParentContext, vendorExtensions, writePropertyBack
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.openapitools.codegen.CodegenConfig
additionalProperties, addOperationToGroup, apiDocFilename, apiDocTemplateFiles, apiFilename, apiFilename, apiPackage, apiTemplateFiles, apiTestFilename, apiTestTemplateFiles, cliOptions, defaultIncludes, defaultTemplatingEngine, embeddedTemplateDir, encodePath, enumNameMapping, escapeText, escapeTextWhileAllowingNewLines, fileSuffix, fromOperation, fromSecurity, fromServers, fromServerVariables, generateExamplePath, generatorLanguageVersion, getAddSuffixToDuplicateOperationNicknames, getDocExtension, getFeatureSet, getFilesMetadataFilename, getGeneratorMetadata, getGitHost, getGitRepoId, getGitUserId, getHelp, getHttpUserAgent, getIgnoreFilePathOverride, getInputSpec, getLibrary, getName, getOpenapiGeneratorIgnoreList, getOutputDir, getReleaseNote, getSupportedVendorExtensions, getTag, getTemplatingEngine, getTypeDeclaration, getUseInlineModelResolver, getUseOpenapiNormalizer, getVersionMetadataFilename, importMapping, inlineSchemaNameMapping, inlineSchemaOption, instantiationTypes, isEnableMinimalUpdate, isEnablePostProcessFile, isHideGenerationTimestamp, isRemoveEnumValuePrefix, isRemoveOperationIdPrefix, isSkipOperationExample, isSkipOverwrite, isSkipSortingOperations, isStrictSpecBehavior, isTypeErasedGenerics, languageSpecificPrimitives, modelDocTemplateFiles, modelFilename, modelFilename, modelNameMapping, modelPackage, modelTemplateFiles, modelTestTemplateFiles, nameMapping, openapiGeneratorIgnoreList, openapiNormalizer, operationIdNameMapping, outputFolder, parameterNameMapping, postProcess, postProcessModelProperty, postProcessOperationsWithModels, postProcessParameter, postProcessResponseWithProperty, postProcessSupportingFileData, postProcessWebhooksWithModels, preprocessOpenAPI, processCompiler, processOpenAPI, processTemplatingEngine, reservedWords, reservedWordsMappings, sanitizeName, sanitizeTag, schemaMapping, serverVariableOverrides, setDocExtension, setEnableMinimalUpdate, setEnablePostProcessFile, setGitHost, setGitRepoId, setGitUserId, setHideGenerationTimestamp, setHttpUserAgent, setIgnoreFilePathOverride, setInputSpec, setLibrary, setOpenAPI, setOutputDir, setReleaseNote, setRemoveEnumValuePrefix, setRemoveOperationIdPrefix, setSkipOperationExample, setSkipOverwrite, setSkipSortingOperations, setStrictSpecBehavior, setTemplatingEngine, shouldOverwrite, supportedLibraries, supportingFiles, templateDir, templateOutputDirs, testPackage, toApiDocFilename, toApiFilename, toApiImport, toApiTestFilename, toApiVarName, toBooleanGetter, toGetter, toModelDocFilename, toModelImportMap, toModelTestFilename, toSetter, typeMapping, unaliasSchema, updateAllModels, vendorExtensions
-
-
-
-
Field Detail
-
MODEL_MUTABLE
public static final String MODEL_MUTABLE
- See Also:
- Constant Field Values
-
MODEL_MUTABLE_DESC
public static final String MODEL_MUTABLE_DESC
- See Also:
- Constant Field Values
-
ADDITIONAL_MODEL_TYPE_ANNOTATIONS
public static final String ADDITIONAL_MODEL_TYPE_ANNOTATIONS
- See Also:
- Constant Field Values
-
JAVAX_PACKAGE
public static final String JAVAX_PACKAGE
- See Also:
- Constant Field Values
-
USE_JAKARTA_EE
public static final String USE_JAKARTA_EE
- See Also:
- Constant Field Values
-
artifactId
protected String artifactId
-
artifactVersion
protected String artifactVersion
-
groupId
protected String groupId
-
packageName
protected String packageName
-
apiSuffix
protected String apiSuffix
-
sourceFolder
protected String sourceFolder
-
testFolder
protected String testFolder
-
resourcesFolder
protected String resourcesFolder
-
apiDocPath
protected String apiDocPath
-
modelDocPath
protected String modelDocPath
-
parcelizeModels
protected boolean parcelizeModels
-
serializableModel
protected boolean serializableModel
-
useJakartaEe
protected boolean useJakartaEe
-
nonPublicApi
protected boolean nonPublicApi
-
enumPropertyNaming
protected CodegenConstants.ENUM_PROPERTY_NAMING_TYPE enumPropertyNaming
-
-
Method Detail
-
apiDocFileFolder
public String apiDocFileFolder()
- Specified by:
apiDocFileFolderin interfaceCodegenConfig- Overrides:
apiDocFileFolderin classDefaultCodegen
-
apiFileFolder
public String apiFileFolder()
- Specified by:
apiFileFolderin interfaceCodegenConfig- Overrides:
apiFileFolderin classDefaultCodegen
-
apiTestFileFolder
public String apiTestFileFolder()
- Specified by:
apiTestFileFolderin interfaceCodegenConfig- Overrides:
apiTestFileFolderin classDefaultCodegen
-
modelTestFileFolder
public String modelTestFileFolder()
- Specified by:
modelTestFileFolderin interfaceCodegenConfig- Overrides:
modelTestFileFolderin 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
-
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)
-
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
-
setEnumPropertyNaming
public void setEnumPropertyNaming(String enumPropertyNamingType)
Sets the naming convention for Kotlin enum properties- Parameters:
enumPropertyNamingType- The string representation of the naming convention, as defined byCodegenConstants.ENUM_PROPERTY_NAMING_TYPE
-
getSchemaType
public String getSchemaType(io.swagger.v3.oas.models.media.Schema p)
returns the OpenAPI type for the property- Overrides:
getSchemaTypein classDefaultCodegen- Parameters:
p- OpenAPI property object- Returns:
- string presentation of the type
-
getTypeDeclaration
public String getTypeDeclaration(io.swagger.v3.oas.models.media.Schema p)
Output the type declaration of the property- Specified by:
getTypeDeclarationin interfaceCodegenConfig- Overrides:
getTypeDeclarationin classDefaultCodegen- Parameters:
p- OpenAPI Property object- Returns:
- a string presentation of the property type
-
modelDocFileFolder
public String modelDocFileFolder()
- Specified by:
modelDocFileFolderin interfaceCodegenConfig- Overrides:
modelDocFileFolderin classDefaultCodegen
-
modelFileFolder
public String modelFileFolder()
- Specified by:
modelFileFolderin interfaceCodegenConfig- Overrides:
modelFileFolderin classDefaultCodegen
-
postProcessAllModels
public Map<String,ModelsMap> postProcessAllModels(Map<String,ModelsMap> objs)
- Specified by:
postProcessAllModelsin interfaceCodegenConfig- Overrides:
postProcessAllModelsin classDefaultCodegen
-
postProcessModels
public ModelsMap postProcessModels(ModelsMap objs)
- Specified by:
postProcessModelsin interfaceCodegenConfig- Overrides:
postProcessModelsin classDefaultCodegen
-
processOpts
public void processOpts()
- Specified by:
processOptsin interfaceCodegenConfig- Overrides:
processOptsin classDefaultCodegen
-
isModelMutable
protected boolean isModelMutable()
-
getParcelizeModels
public Boolean getParcelizeModels()
-
setParcelizeModels
public void setParcelizeModels(Boolean parcelizeModels)
-
nonPublicApi
public boolean nonPublicApi()
-
toEnumVarName
public String toEnumVarName(String value, String datatype)
Return the sanitized variable name for enum- Overrides:
toEnumVarNamein classDefaultCodegen- Parameters:
value- 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
-
toApiName
public String toApiName(String name)
Description copied from class:DefaultCodegenOutput the API (class) name (capitalized) ending with the specified or default suffix Return DefaultApi if name is empty- Specified by:
toApiNamein interfaceCodegenConfig- Overrides:
toApiNamein classDefaultCodegen- Parameters:
name- the name of the Api- Returns:
- capitalized Api name
-
toModelImport
public String toModelImport(String name)
Return the fully-qualified "Model" name for import- Specified by:
toModelImportin interfaceCodegenConfig- Overrides:
toModelImportin classDefaultCodegen- Parameters:
name- the name of the "Model"- Returns:
- the fully-qualified "Model" name for import
-
toModelName
public String toModelName(String name)
Output 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
-
toOperationId
public String toOperationId(String operationId)
Return the operation ID (method name)- Overrides:
toOperationIdin classDefaultCodegen- Parameters:
operationId- operation ID- Returns:
- the sanitized method 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
-
applyJavaxPackage
protected void applyJavaxPackage()
-
applyJakartaPackage
protected void applyJakartaPackage()
-
isReservedWord
protected boolean isReservedWord(String word)
- Overrides:
isReservedWordin classDefaultCodegen
-
needToImport
protected boolean needToImport(String type)
Check the type to see if it needs import the library/module/package- Overrides:
needToImportin classDefaultCodegen- Parameters:
type- name of the type- Returns:
- true if the library/module/package of the corresponding type needs to be imported
-
fromModel
public CodegenModel fromModel(String name, io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenConvert OAS Model object to Codegen Model object.- Specified by:
fromModelin interfaceCodegenConfig- Overrides:
fromModelin classDefaultCodegen- Parameters:
name- the name of the modelschema- OAS Model object- Returns:
- Codegen Model 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
-
isDataTypeString
public boolean isDataTypeString(String dataType)
Description copied from class:DefaultCodegenchecks 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"- Overrides:
isDataTypeStringin classDefaultCodegen- Parameters:
dataType- data type- Returns:
- true if it's a enum string
-
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
-
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
-
toRegularExpression
public String toRegularExpression(String pattern)
Description copied from class:DefaultCodegenReturn the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)- Overrides:
toRegularExpressionin classDefaultCodegen- Parameters:
pattern- the pattern (regular expression)- Returns:
- properly-escaped pattern
-
postProcessFile
public void postProcessFile(File file, String fileType)
Description copied from class:DefaultCodegenPost-process the auto-generated file, e.g. using go-fmt to format the Go code. The file type can be "model-test", "model-doc", "model", "api", "api-test", "api-doc", "supporting-file", "openapi-generator-ignore", "openapi-generator-version"TODO: store these values in enum instead
- Specified by:
postProcessFilein interfaceCodegenConfig- Overrides:
postProcessFilein classDefaultCodegen- Parameters:
file- file to be processedfileType- file type
-
toDefaultValue
public String toDefaultValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenReturn the default value of the propertyReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Overrides:
toDefaultValuein classDefaultCodegen- Parameters:
cp- Codegen propertyschema- Property schema- Returns:
- string presentation of the default value of the property
-
toDefaultParameterValue
public String toDefaultParameterValue(CodegenProperty cp, io.swagger.v3.oas.models.media.Schema schema)
Description copied from class:DefaultCodegenReturn the default value of the parameterReturn null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.
- Overrides:
toDefaultParameterValuein classDefaultCodegen- Parameters:
cp- Codegen Propertyschema- Parameter schema- Returns:
- string presentation of the default value of the parameter
-
generatorLanguage
public GeneratorLanguage generatorLanguage()
- Specified by:
generatorLanguagein interfaceCodegenConfig- Overrides:
generatorLanguagein classDefaultCodegen
-
updateModelForObject
protected void updateModelForObject(CodegenModel m, io.swagger.v3.oas.models.media.Schema schema)
- Overrides:
updateModelForObjectin classDefaultCodegen
-
addMustacheLambdas
protected com.google.common.collect.ImmutableMap.Builder<String,com.samskivert.mustache.Mustache.Lambda> addMustacheLambdas()
Description copied from class:DefaultCodegenPreset map builder with commonly used Mustache lambdas. To extend the map, override addMustacheLambdas(), call parent method first and then add additional lambdas to the returned builder. If common lambdas are not desired, override addMustacheLambdas() method and return empty builder.- Overrides:
addMustacheLambdasin classDefaultCodegen- Returns:
- preinitialized map with common lambdas
-
doDataTypeAssignment
protected void doDataTypeAssignment(String returnType, AbstractKotlinCodegen.DataTypeAssigner dataTypeAssigner)
- Parameters:
returnType- The return type that needs to be converteddataTypeAssigner- An object that will assign the data to the respective fields in the model.
-
-