Skip to content

[BUG] Java: unnecessary imports in generated files? #8016

@hrstoyanov

Description

@hrstoyanov
Description

OpenAPI Gradle plug-in (underlying generator) adds an unnecessary import:

import org.apache.cxf.jaxrs.ext.multipart.*;

when the Java configuration option "library" is set to "microprofile". Such imports are not needed - manually deleting them cause no compile errors.

openapi-generator version

5.0.0-SNAPSHOT

OpenAPI declaration file content or url

https://raw.githubusercontent.com/ory/kratos-client-java/master/api/openapi.yaml

Generation Details

I use the Gradle plugin, but I beleive the problem is in the core generator itself :

plugins {
    id 'org.openapi.generator'
}
openApiGenerate {
        generatorName = "java"
        inputSpec = "$rootDir/ory-kratos.yaml".toString() //get from the url above!
        outputDir = "$rootDir".toString()
        apiPackage = "kratos.api"
        invokerPackage = "kratos.invoker"
        modelPackage = "kratos.model"
        configOptions = [
                dateLibrary: "java8",
                java8: "true",
                library:"microprofile"
        ]
    }
Steps to reproduce

generate source code with the above configuration, see file kratos.api.AdminApi.java - the problematic import is there.

Related issues/PRs
Suggest a fix

Manually deleting the necessary import after each generation .

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions