Class AbstractKotlinCodegen

    • Field Detail

      • artifactId

        protected String artifactId
      • artifactVersion

        protected String artifactVersion
      • groupId

        protected String groupId
      • packageName

        protected String packageName
      • sourceFolder

        protected String sourceFolder
      • apiDocPath

        protected String apiDocPath
      • modelDocPath

        protected String modelDocPath
    • Constructor Detail

      • AbstractKotlinCodegen

        public AbstractKotlinCodegen()
    • Method Detail

      • escapeQuotationMark

        public String escapeQuotationMark​(String input)
        Description copied from class: DefaultCodegenConfig
        Escape single and/or double quote to avoid code injection
        Specified by:
        escapeQuotationMark in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        escapeQuotationMark in class DefaultCodegenConfig
        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: DefaultCodegenConfig
        Return the escaped name of the reserved word
        Specified by:
        escapeReservedWord in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        escapeReservedWord in class DefaultCodegenConfig
        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: DefaultCodegenConfig
        override with any special text escaping logic to handle unsafe characters so as to avoid code injection
        Specified by:
        escapeUnsafeCharacters in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        escapeUnsafeCharacters in class DefaultCodegenConfig
        Parameters:
        input - String to be cleaned up
        Returns:
        string with unsafe characters removed or escaped
      • updateCodegenModelEnumVars

        protected void updateCodegenModelEnumVars​(io.swagger.codegen.v3.CodegenModel codegenModel)
        Description copied from class: DefaultCodegenConfig
        update codegen property enum with proper naming convention and handling of numbers, special characters
        Overrides:
        updateCodegenModelEnumVars in class DefaultCodegenConfig
      • getTypeDeclaration

        public String getTypeDeclaration​(io.swagger.v3.oas.models.media.Schema propertySchema)
        Output the type declaration of the property
        Specified by:
        getTypeDeclaration in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        getTypeDeclaration in class DefaultCodegenConfig
        Parameters:
        propertySchema - Swagger Property object
        Returns:
        a string presentation of the property type
      • getAlias

        public String getAlias​(String name)
        Description copied from class: DefaultCodegenConfig
        Determine the type alias for the given type if it exists. This feature is only used for Java, because the language does not have a aliasing mechanism of its own.
        Overrides:
        getAlias in class DefaultCodegenConfig
        Parameters:
        name - The type name.
        Returns:
        The alias of the given type, if it exists. If there is no alias for this type, then returns the input type name.
      • getSchemaType

        public String getSchemaType​(io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegenConfig
        returns the swagger type for the property
        Overrides:
        getSchemaType in class DefaultCodegenConfig
        Parameters:
        schema - Schema property object
        Returns:
        string presentation of the type
      • processOpts

        public void processOpts()
        Specified by:
        processOpts in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        processOpts in class DefaultCodegenConfig
      • setArtifactId

        public void setArtifactId​(String artifactId)
      • setArtifactVersion

        public void setArtifactVersion​(String artifactVersion)
      • setGroupId

        public void setGroupId​(String groupId)
      • setPackageName

        public void setPackageName​(String packageName)
      • setSourceFolder

        public void setSourceFolder​(String sourceFolder)
      • toEnumVarName

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

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

        public String toInstantiationType​(io.swagger.v3.oas.models.media.Schema p)
        Description copied from class: DefaultCodegenConfig
        Return the instantiation type of the property, especially for map and array
        Overrides:
        toInstantiationType in class DefaultCodegenConfig
        Parameters:
        p - Swagger property object
        Returns:
        string presentation of the instantiation type of the property
      • toModelImport

        public String toModelImport​(String name)
        Return the fully-qualified "Model" name for import
        Specified by:
        toModelImport in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelImport in class DefaultCodegenConfig
        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:
        toModelName in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelName in class DefaultCodegenConfig
        Parameters:
        name - the name of the model
        Returns:
        capitalized model name
      • toVarName

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

        public String toEnumName​(io.swagger.codegen.v3.CodegenProperty property)
        Description copied from class: DefaultCodegenConfig
        Return the Enum name (e.g. StatusEnum given 'status')
        Overrides:
        toEnumName in class DefaultCodegenConfig
        Parameters:
        property - Codegen property
        Returns:
        the Enum name
      • addHandlebarHelpers

        public void addHandlebarHelpers​(com.github.jknack.handlebars.Handlebars handlebars)
        Specified by:
        addHandlebarHelpers in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        addHandlebarHelpers in class DefaultCodegenConfig
      • needToImport

        protected boolean needToImport​(String type)
        Check the type to see if it needs import the library/module/package
        Overrides:
        needToImport in class DefaultCodegenConfig
        Parameters:
        type - name of the type
        Returns:
        true if the library/module/package of the corresponding type needs to be imported