Class AbstractKotlinCodegen

    • Constructor Detail

      • AbstractKotlinCodegen

        public AbstractKotlinCodegen()
    • Method Detail

      • 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 by CodegenConstants.ENUM_PROPERTY_NAMING_TYPE
      • setSerializationLibrary

        public void setSerializationLibrary​(String enumSerializationLibrary)
        Sets the serialization engine for Kotlin
        Parameters:
        enumSerializationLibrary - The string representation of the serialization library as defined by AbstractKotlinCodegen.SERIALIZATION_LIBRARY_TYPE
      • getSchemaType

        public String getSchemaType​(io.swagger.v3.oas.models.media.Schema p)
        returns the OpenAPI type for the property
        Overrides:
        getSchemaType in class DefaultCodegen
        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:
        getTypeDeclaration in interface CodegenConfig
        Overrides:
        getTypeDeclaration in class DefaultCodegen
        Parameters:
        p - OpenAPI Property object
        Returns:
        a string presentation of the property type
      • isModelMutable

        protected boolean isModelMutable()
      • setArtifactId

        public void setArtifactId​(String artifactId)
      • setArtifactVersion

        public void setArtifactVersion​(String artifactVersion)
      • setGroupId

        public void setGroupId​(String groupId)
      • setPackageName

        public void setPackageName​(String packageName)
      • setApiSuffix

        public void setApiSuffix​(String apiSuffix)
      • setSourceFolder

        public void setSourceFolder​(String sourceFolder)
      • setTestFolder

        public void setTestFolder​(String testFolder)
      • getParcelizeModels

        public Boolean getParcelizeModels()
      • setParcelizeModels

        public void setParcelizeModels​(Boolean parcelizeModels)
      • isSerializableModel

        public boolean isSerializableModel()
      • setSerializableModel

        public void setSerializableModel​(boolean serializableModel)
      • setUseJakartaEe

        public void setUseJakartaEe​(boolean useJakartaEe)
      • nonPublicApi

        public boolean nonPublicApi()
      • setNonPublicApi

        public void setNonPublicApi​(boolean nonPublicApi)
      • toEnumVarName

        public String toEnumVarName​(String value,
                                    String datatype)
        Return the sanitized variable name for enum
        Overrides:
        toEnumVarName in class DefaultCodegen
        Parameters:
        value - enum variable name
        datatype - data type
        Returns:
        the sanitized variable name for enum
      • toApiName

        public String toApiName​(String name)
        Description copied from class: DefaultCodegen
        Output the API (class) name (capitalized) ending with the specified or default suffix Return DefaultApi if name is empty
        Specified by:
        toApiName in interface CodegenConfig
        Overrides:
        toApiName in class DefaultCodegen
        Parameters:
        name - the name of the Api
        Returns:
        capitalized Api name
      • 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:
        toModelName in interface CodegenConfig
        Overrides:
        toModelName in class DefaultCodegen
        Parameters:
        name - the name of the model
        Returns:
        capitalized model name
      • toOperationId

        public String toOperationId​(String operationId)
        Return the operation ID (method name)
        Overrides:
        toOperationId in class DefaultCodegen
        Parameters:
        operationId - operation ID
        Returns:
        the sanitized method name
      • applyJavaxPackage

        protected void applyJavaxPackage()
      • applyJakartaPackage

        protected void applyJakartaPackage()
      • needToImport

        protected boolean needToImport​(String type)
        Check the type to see if it needs import the library/module/package
        Overrides:
        needToImport in class DefaultCodegen
        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: DefaultCodegen
        Convert OAS Model object to Codegen Model object.
        Specified by:
        fromModel in interface CodegenConfig
        Overrides:
        fromModel in class DefaultCodegen
        Parameters:
        name - the name of the model
        schema - OAS Model object
        Returns:
        Codegen Model object
      • toEnumValue

        public String toEnumValue​(String value,
                                  String datatype)
        Description copied from class: DefaultCodegen
        Return the enum value in the language specified format e.g. status becomes "status"
        Overrides:
        toEnumValue in class DefaultCodegen
        Parameters:
        value - enum variable name
        datatype - data type
        Returns:
        the sanitized value for enum
      • isDataTypeString

        public boolean isDataTypeString​(String dataType)
        Description copied from class: DefaultCodegen
        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"
        Overrides:
        isDataTypeString in class DefaultCodegen
        Parameters:
        dataType - data type
        Returns:
        true if it's a enum string
      • toParamName

        public String toParamName​(String name)
        Description copied from class: DefaultCodegen
        Return the parameter name by removing invalid characters and proper escaping if it's a reserved word.
        Specified by:
        toParamName in interface CodegenConfig
        Overrides:
        toParamName in class DefaultCodegen
        Parameters:
        name - Codegen property object
        Returns:
        the sanitized parameter name
      • toVarName

        public String toVarName​(String name)
        Description copied from class: DefaultCodegen
        Return the variable name by removing invalid characters and proper escaping if it's a reserved word.
        Overrides:
        toVarName in class DefaultCodegen
        Parameters:
        name - the variable name
        Returns:
        the sanitized variable name
      • toVariableName

        protected String toVariableName​(String name)
      • toRegularExpression

        public String toRegularExpression​(String pattern)
        Description copied from class: DefaultCodegen
        Return the regular expression/JSON schema pattern (http://json-schema.org/latest/json-schema-validation.html#anchor33)
        Overrides:
        toRegularExpression in class DefaultCodegen
        Parameters:
        pattern - the pattern (regular expression)
        Returns:
        properly-escaped pattern
      • postProcessFile

        public void postProcessFile​(File file,
                                    String fileType)
        Description copied from class: DefaultCodegen
        Post-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-mustache", "supporting-common", "openapi-generator-ignore", "openapi-generator-version"

        TODO: store these values in enum instead

        Specified by:
        postProcessFile in interface CodegenConfig
        Overrides:
        postProcessFile in class DefaultCodegen
        Parameters:
        file - file to be processed
        fileType - file type
      • toDefaultValue

        public String toDefaultValue​(io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegen
        Return the default value of the property

        This method should be overridden in the generator to meet its requirement. Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.

        Overrides:
        toDefaultValue in class DefaultCodegen
        Parameters:
        schema - Property schema
        Returns:
        string presentation of the default value of the property
      • getAdditionalModelTypeAnnotations

        public List<String> getAdditionalModelTypeAnnotations()
      • setAdditionalModelTypeAnnotations

        public void setAdditionalModelTypeAnnotations​(List<String> additionalModelTypeAnnotations)
      • addMustacheLambdas

        protected com.google.common.collect.ImmutableMap.Builder<String,​com.samskivert.mustache.Mustache.Lambda> addMustacheLambdas()
        Description copied from class: DefaultCodegen
        Preset 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:
        addMustacheLambdas in class DefaultCodegen
        Returns:
        preinitialized map with common lambdas