Class AbstractJavaCodegen

    • Constructor Detail

      • AbstractJavaCodegen

        public AbstractJavaCodegen()
    • Method Detail

      • applyJavaxPackage

        protected void applyJavaxPackage()
      • applyJakartaPackage

        protected void applyJakartaPackage()
      • 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
      • 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
      • toModelName

        public String toModelName​(String name)
        Description copied from class: DefaultCodegen
        Converts the OpenAPI schema name to a model name suitable for the current code generator. May be overridden for each programming language. 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
      • getAlias

        public String getAlias​(String name)
        Description copied from class: DefaultCodegen
        Determine the type alias for the given type if it exists. This feature was originally developed for Java because the language does not have an aliasing mechanism of its own but later extends to handle other languages
        Overrides:
        getAlias in class DefaultCodegen
        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.
      • toArrayDefaultValue

        public String toArrayDefaultValue​(CodegenProperty cp,
                                          io.swagger.v3.oas.models.media.Schema schema)
        Return the default value of array property

        Return null if there's no default value. Any non-null value will cause {{#defaultValue} check to pass.

        Parameters:
        cp - Codegen property
        schema - Property schema
        Returns:
        string presentation of the default value of the property
      • toDefaultValue

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

        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:
        cp - Codegen property
        schema - Property schema
        Returns:
        string presentation of the default value of the property
      • toDefaultParameterValue

        public String toDefaultParameterValue​(io.swagger.v3.oas.models.media.Schema<?> schema)
        Description copied from class: DefaultCodegen
        Return the default value of the parameter

        Return null if you do NOT want a default value. Any non-null value will cause {{#defaultValue} check to pass.

        Overrides:
        toDefaultParameterValue in class DefaultCodegen
        Parameters:
        schema - Parameter schema
        Returns:
        string presentation of the default value of the parameter
      • setParameterExampleValue

        public void setParameterExampleValue​(CodegenParameter codegenParameter,
                                             io.swagger.v3.oas.models.parameters.Parameter parameter)
        Return the example value of the parameter. Overrides the setParameterExampleValue(CodegenParameter, Parameter) method in DefaultCodegen to always call setParameterExampleValue(CodegenParameter) in this class, which adds single quotes around strings from the x-example property.
        Overrides:
        setParameterExampleValue in class DefaultCodegen
        Parameters:
        codegenParameter - Codegen parameter
        parameter - Parameter
      • setParameterExampleValue

        public void setParameterExampleValue​(CodegenParameter codegenParameter,
                                             io.swagger.v3.oas.models.parameters.RequestBody requestBody)
        Return the example value of the parameter. Overrides the parent method in DefaultCodegen to not set examples on complex models, as they don't compile properly.
        Overrides:
        setParameterExampleValue in class DefaultCodegen
        Parameters:
        codegenParameter - Codegen parameter
        requestBody - Request body
      • toExampleValue

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

        This method should be overridden in the generator to meet its requirement.

        Overrides:
        toExampleValue in class DefaultCodegen
        Parameters:
        p - Property schema
        Returns:
        string presentation of the example value of the property
      • getSchemaType

        public String getSchemaType​(io.swagger.v3.oas.models.media.Schema p)
        Description copied from class: DefaultCodegen
        returns the OpenAPI type for the property. Use getAlias to handle $ref of primitive type
        Overrides:
        getSchemaType in class DefaultCodegen
        Parameters:
        p - property schema
        Returns:
        string presentation of the type
      • toOperationId

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

        public CodegenModel fromModel​(String name,
                                      io.swagger.v3.oas.models.media.Schema model)
        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
        model - OAS Model object
        Returns:
        Codegen Model object
      • needToImport

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

        public String toEnumVarName​(String value,
                                    String datatype)
        Description copied from class: DefaultCodegen
        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
      • 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
      • fromOperation

        public CodegenOperation fromOperation​(String path,
                                              String httpMethod,
                                              io.swagger.v3.oas.models.Operation operation,
                                              List<io.swagger.v3.oas.models.servers.Server> servers)
        Description copied from class: DefaultCodegen
        Convert OAS Operation object to Codegen Operation object
        Specified by:
        fromOperation in interface CodegenConfig
        Overrides:
        fromOperation in class DefaultCodegen
        Parameters:
        path - the path of the operation
        httpMethod - HTTP method
        operation - OAS operation object
        servers - list of servers
        Returns:
        Codegen Operation object
      • getInvokerPackage

        public String getInvokerPackage()
      • setInvokerPackage

        public void setInvokerPackage​(String invokerPackage)
      • getGroupId

        public String getGroupId()
      • setGroupId

        public void setGroupId​(String groupId)
      • getArtifactId

        public String getArtifactId()
      • setArtifactId

        public void setArtifactId​(String artifactId)
      • getArtifactVersion

        public String getArtifactVersion()
      • setArtifactVersion

        public void setArtifactVersion​(String artifactVersion)
      • getArtifactUrl

        public String getArtifactUrl()
      • setArtifactUrl

        public void setArtifactUrl​(String artifactUrl)
      • getArtifactDescription

        public String getArtifactDescription()
      • setArtifactDescription

        public void setArtifactDescription​(String artifactDescription)
      • getScmConnection

        public String getScmConnection()
      • setScmConnection

        public void setScmConnection​(String scmConnection)
      • getScmDeveloperConnection

        public String getScmDeveloperConnection()
      • setScmDeveloperConnection

        public void setScmDeveloperConnection​(String scmDeveloperConnection)
      • getScmUrl

        public String getScmUrl()
      • setScmUrl

        public void setScmUrl​(String scmUrl)
      • getDeveloperName

        public String getDeveloperName()
      • setDeveloperName

        public void setDeveloperName​(String developerName)
      • getDeveloperEmail

        public String getDeveloperEmail()
      • setDeveloperEmail

        public void setDeveloperEmail​(String developerEmail)
      • getDeveloperOrganization

        public String getDeveloperOrganization()
      • setDeveloperOrganization

        public void setDeveloperOrganization​(String developerOrganization)
      • getDeveloperOrganizationUrl

        public String getDeveloperOrganizationUrl()
      • setDeveloperOrganizationUrl

        public void setDeveloperOrganizationUrl​(String developerOrganizationUrl)
      • getLicenseName

        public String getLicenseName()
      • setLicenseName

        public void setLicenseName​(String licenseName)
      • getLicenseUrl

        public String getLicenseUrl()
      • setLicenseUrl

        public void setLicenseUrl​(String licenseUrl)
      • getSourceFolder

        public String getSourceFolder()
      • setSourceFolder

        public void setSourceFolder​(String sourceFolder)
      • getTestFolder

        public String getTestFolder()
      • setTestFolder

        public void setTestFolder​(String testFolder)
      • setSerializeBigDecimalAsString

        public void setSerializeBigDecimalAsString​(boolean s)
      • getSerializableModel

        public Boolean getSerializableModel()
      • setSerializableModel

        public void setSerializableModel​(Boolean serializableModel)
      • setDiscriminatorCaseSensitive

        public void setDiscriminatorCaseSensitive​(boolean discriminatorCaseSensitive)
        Set whether discriminator value lookup is case-sensitive or not.
        Parameters:
        discriminatorCaseSensitive - true if the discriminator value lookup should be case sensitive.
      • setWithXml

        public void setWithXml​(boolean withXml)
      • getDateLibrary

        public String getDateLibrary()
      • setDateLibrary

        public void setDateLibrary​(String library)
      • setSupportAsync

        public void setSupportAsync​(boolean enabled)
      • setDisableHtmlEscaping

        public void setDisableHtmlEscaping​(boolean disabled)
      • getBooleanGetterPrefix

        public String getBooleanGetterPrefix()
      • setBooleanGetterPrefix

        public void setBooleanGetterPrefix​(String booleanGetterPrefix)
      • setIgnoreAnyOfInEnum

        public void setIgnoreAnyOfInEnum​(boolean ignoreAnyOfInEnum)
      • isOpenApiNullable

        public boolean isOpenApiNullable()
      • setOpenApiNullable

        public void setOpenApiNullable​(boolean openApiNullable)
      • getOutputTestFolder

        public String getOutputTestFolder()
      • setOutputTestFolder

        public void setOutputTestFolder​(String outputTestFolder)
      • setImplicitHeaders

        public void setImplicitHeaders​(boolean implicitHeaders)
      • setImplicitHeadersRegex

        public void setImplicitHeadersRegex​(String implicitHeadersRegex)
      • setCamelCaseDollarSign

        public void setCamelCaseDollarSign​(boolean camelCaseDollarSign)
      • setUseJakartaEe

        public void setUseJakartaEe​(boolean useJakartaEe)
      • setContainerDefaultToNull

        public void setContainerDefaultToNull​(boolean containerDefaultToNull)
      • setSupportJava6

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

        public String getterAndSetterCapitalize​(String name)
        Camelize the method name of the getter and setter
        Overrides:
        getterAndSetterCapitalize in class DefaultCodegen
        Parameters:
        name - string to be camelized
        Returns:
        Camelized string
      • 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
      • setParentGroupId

        public void setParentGroupId​(String parentGroupId)
      • setParentArtifactId

        public void setParentArtifactId​(String parentArtifactId)
      • setParentVersion

        public void setParentVersion​(String parentVersion)
      • setParentOverridden

        public void setParentOverridden​(boolean parentOverridden)
      • getAdditionalModelTypeAnnotations

        public List<String> getAdditionalModelTypeAnnotations()
      • setAdditionalModelTypeAnnotations

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

        public List<String> getAdditionalOneOfTypeAnnotations()
      • setAdditionalOneOfTypeAnnotations

        public void setAdditionalOneOfTypeAnnotations​(List<String> additionalOneOfTypeAnnotations)
      • setAdditionalEnumTypeAnnotations

        public void setAdditionalEnumTypeAnnotations​(List<String> additionalEnumTypeAnnotations)
      • addAdditionPropertiesToCodeGenModel

        protected void addAdditionPropertiesToCodeGenModel​(CodegenModel codegenModel,
                                                           io.swagger.v3.oas.models.media.Schema schema)
        Description copied from class: DefaultCodegen
        Handle the model for the 'additionalProperties' keyword in the OAS schema.
        Overrides:
        addAdditionPropertiesToCodeGenModel in class DefaultCodegen
        Parameters:
        codegenModel - The codegen representation of the schema.
        schema - The input OAS schema.
      • handleImplicitHeaders

        protected void handleImplicitHeaders​(CodegenOperation operation)
        This method removes all implicit header parameters from the list of parameters
        Parameters:
        operation - - operation to be processed