Class AbstractJavaCodegen

    • Field Detail

      • dateLibrary

        protected String dateLibrary
      • java8Mode

        protected boolean java8Mode
      • java11Mode

        protected boolean java11Mode
      • withXml

        protected boolean withXml
      • invokerPackage

        protected String invokerPackage
      • groupId

        protected String groupId
      • artifactId

        protected String artifactId
      • artifactVersion

        protected String artifactVersion
      • artifactUrl

        protected String artifactUrl
      • artifactDescription

        protected String artifactDescription
      • developerName

        protected String developerName
      • developerEmail

        protected String developerEmail
      • developerOrganization

        protected String developerOrganization
      • developerOrganizationUrl

        protected String developerOrganizationUrl
      • scmConnection

        protected String scmConnection
      • scmDeveloperConnection

        protected String scmDeveloperConnection
      • scmUrl

        protected String scmUrl
      • licenseName

        protected String licenseName
      • licenseUrl

        protected String licenseUrl
      • projectFolder

        protected String projectFolder
      • projectTestFolder

        protected String projectTestFolder
      • sourceFolder

        protected String sourceFolder
      • testFolder

        protected String testFolder
      • localVariablePrefix

        protected String localVariablePrefix
      • fullJavaUtil

        protected boolean fullJavaUtil
      • javaUtilPrefix

        protected String javaUtilPrefix
      • serializableModel

        protected Boolean serializableModel
      • serializeBigDecimalAsString

        protected boolean serializeBigDecimalAsString
      • apiDocPath

        protected String apiDocPath
      • modelDocPath

        protected String modelDocPath
      • supportJava6

        protected boolean supportJava6
    • Constructor Detail

      • AbstractJavaCodegen

        public AbstractJavaCodegen()
    • Method Detail

      • processOpts

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

        protected String escapeUnderscore​(String name)
      • 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)
      • toApiDocFilename

        public String toApiDocFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the file name of the Api Documentation
        Specified by:
        toApiDocFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiDocFilename in class DefaultCodegenConfig
        Parameters:
        name - the file name of the Api
        Returns:
        the file name of the Api
      • toModelDocFilename

        public String toModelDocFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the capitalized file name of the model documentation
        Specified by:
        toModelDocFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelDocFilename in class DefaultCodegenConfig
        Parameters:
        name - the model name
        Returns:
        the file name of the model
      • toApiTestFilename

        public String toApiTestFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the file name of the Api Test
        Specified by:
        toApiTestFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiTestFilename in class DefaultCodegenConfig
        Parameters:
        name - the file name of the Api
        Returns:
        the file name of the Api
      • toApiName

        public String toApiName​(String name)
        Description copied from class: DefaultCodegenConfig
        Output the API (class) name (capitalized) ending with "Api" Return DefaultApi if name is empty
        Specified by:
        toApiName in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiName in class DefaultCodegenConfig
        Parameters:
        name - the name of the Api
        Returns:
        capitalized Api name ending with "Api"
      • toApiFilename

        public String toApiFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the file name of the Api Test
        Specified by:
        toApiFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toApiFilename in class DefaultCodegenConfig
        Parameters:
        name - the file name of the Api
        Returns:
        the file name of the Api
      • 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
      • camelizeVarName

        public String camelizeVarName​(String word,
                                      boolean lowercaseFirstLetter)
      • toParamName

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

        public String toModelName​(String name)
        Description copied from class: DefaultCodegenConfig
        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
      • toModelFilename

        public String toModelFilename​(String name)
        Description copied from class: DefaultCodegenConfig
        Return the capitalized file name of the model
        Specified by:
        toModelFilename in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toModelFilename in class DefaultCodegenConfig
        Parameters:
        name - the model name
        Returns:
        the file name of the model
      • getTypeDeclaration

        public String getTypeDeclaration​(io.swagger.v3.oas.models.media.Schema propertySchema)
        Description copied from class: DefaultCodegenConfig
        Output the type declaration of the property
        Specified by:
        getTypeDeclaration in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        getTypeDeclaration in class DefaultCodegenConfig
        Parameters:
        propertySchema - Schema 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.
      • toDefaultValue

        public String toDefaultValue​(io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegenConfig
        Return the default value of the property
        Overrides:
        toDefaultValue in class DefaultCodegenConfig
        Parameters:
        schema - Schema property object
        Returns:
        string presentation of the default value of the property
      • toExampleValue

        public String toExampleValue​(io.swagger.v3.oas.models.media.Schema schemaProperty)
        Description copied from class: DefaultCodegenConfig
        Return the example value of the property
        Overrides:
        toExampleValue in class DefaultCodegenConfig
        Parameters:
        schemaProperty - Schema property object
        Returns:
        string presentation of the example value of the property
      • 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
      • fromModel

        public io.swagger.codegen.v3.CodegenModel fromModel​(String name,
                                                            io.swagger.v3.oas.models.media.Schema schema,
                                                            Map<String,​io.swagger.v3.oas.models.media.Schema> allSchemas)
        Description copied from class: DefaultCodegenConfig
        Convert Swagger Model object to Codegen Model object
        Specified by:
        fromModel in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        fromModel in class DefaultCodegenConfig
        Parameters:
        name - the name of the model
        schema - Swagger Model object
        allSchemas - a map of all Swagger models from the spec
        Returns:
        Codegen Model object
      • postProcessModelProperty

        public void postProcessModelProperty​(io.swagger.codegen.v3.CodegenModel model,
                                             io.swagger.codegen.v3.CodegenProperty property)
        Specified by:
        postProcessModelProperty in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        postProcessModelProperty in class DefaultCodegenConfig
      • postProcessParameter

        public void postProcessParameter​(io.swagger.codegen.v3.CodegenParameter parameter)
        Specified by:
        postProcessParameter in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        postProcessParameter in class DefaultCodegenConfig
      • preprocessOpenAPI

        public void preprocessOpenAPI​(io.swagger.v3.oas.models.OpenAPI openAPI)
        Specified by:
        preprocessOpenAPI in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        preprocessOpenAPI in class DefaultCodegenConfig
      • needToImport

        protected boolean needToImport​(String type)
        Description copied from class: DefaultCodegenConfig
        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
      • checkDuplicatedModelNameIgnoringCase

        protected void checkDuplicatedModelNameIgnoringCase​(io.swagger.v3.oas.models.OpenAPI openAPI)
      • replaceDuplicatedInPaths

        protected void replaceDuplicatedInPaths​(io.swagger.v3.oas.models.Paths paths,
                                                String modelName,
                                                String newModelName)
      • replaceDuplicatedInModelProperties

        protected void replaceDuplicatedInModelProperties​(Map<String,​io.swagger.v3.oas.models.media.Schema> definitions,
                                                          String modelName,
                                                          String newModelName)
      • 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
      • 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
      • fromOperation

        public io.swagger.codegen.v3.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)
        Description copied from class: DefaultCodegenConfig
        Convert Swagger Operation object to Codegen Operation object
        Specified by:
        fromOperation in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        fromOperation in class DefaultCodegenConfig
        Parameters:
        path - the path of the operation
        httpMethod - HTTP method
        operation - Swagger operation object
        schemas - a map of schemas
        openAPI - a OpenAPI object representing the spec
        Returns:
        Codegen Operation object
      • sanitizeVarName

        public String sanitizeVarName​(String name)
      • isSameEnum

        protected static boolean isSameEnum​(io.swagger.codegen.v3.CodegenProperty actual,
                                            io.swagger.codegen.v3.CodegenProperty other)
      • setInvokerPackage

        public void setInvokerPackage​(String invokerPackage)
      • setGroupId

        public void setGroupId​(String groupId)
      • setArtifactId

        public void setArtifactId​(String artifactId)
      • setArtifactVersion

        public void setArtifactVersion​(String artifactVersion)
      • setArtifactUrl

        public void setArtifactUrl​(String artifactUrl)
      • setArtifactDescription

        public void setArtifactDescription​(String artifactDescription)
      • setScmConnection

        public void setScmConnection​(String scmConnection)
      • setScmDeveloperConnection

        public void setScmDeveloperConnection​(String scmDeveloperConnection)
      • setScmUrl

        public void setScmUrl​(String scmUrl)
      • setDeveloperName

        public void setDeveloperName​(String developerName)
      • setDeveloperEmail

        public void setDeveloperEmail​(String developerEmail)
      • setDeveloperOrganization

        public void setDeveloperOrganization​(String developerOrganization)
      • setDeveloperOrganizationUrl

        public void setDeveloperOrganizationUrl​(String developerOrganizationUrl)
      • setLicenseName

        public void setLicenseName​(String licenseName)
      • setLicenseUrl

        public void setLicenseUrl​(String licenseUrl)
      • setSourceFolder

        public void setSourceFolder​(String sourceFolder)
      • setTestFolder

        public void setTestFolder​(String testFolder)
      • setLocalVariablePrefix

        public void setLocalVariablePrefix​(String localVariablePrefix)
      • setSerializeBigDecimalAsString

        public void setSerializeBigDecimalAsString​(boolean s)
      • setSerializableModel

        public void setSerializableModel​(Boolean serializableModel)
      • setFullJavaUtil

        public void setFullJavaUtil​(boolean fullJavaUtil)
      • setWithXml

        public void setWithXml​(boolean withXml)
      • setDateLibrary

        public void setDateLibrary​(String library)
      • setJava8Mode

        public void setJava8Mode​(boolean enabled)
      • setJava11Mode

        public void setJava11Mode​(boolean java11Mode)
      • 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
      • 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
      • setSupportJava6

        public void setSupportJava6​(boolean value)
      • toRegularExpression

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

        public String toBooleanGetter​(String name)
        Output the Getter name for boolean property, e.g. isActive
        Specified by:
        toBooleanGetter in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        toBooleanGetter in class DefaultCodegenConfig
        Parameters:
        name - the name of the property
        Returns:
        getter name based on naming convention
      • 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
      • setLanguageArguments

        public void setLanguageArguments​(List<io.swagger.codegen.v3.CodegenArgument> languageArguments)
        Specified by:
        setLanguageArguments in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        setLanguageArguments in class DefaultCodegenConfig
      • defaultIgnoreImportMappingOption

        public boolean defaultIgnoreImportMappingOption()
        Specified by:
        defaultIgnoreImportMappingOption in interface io.swagger.codegen.v3.CodegenConfig
        Overrides:
        defaultIgnoreImportMappingOption in class DefaultCodegenConfig
      • checkAliasModel

        public boolean checkAliasModel()