OpenAPITools / OpenAPITools/openapi-generator
[BUG][KOTLIN] When generating apis and modals only using retrofit2 api files contain invalid import
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When generating code using kotlin generator with options to generate APIs and models files only, and using retrofit2 library, generator generates API files without infrastructure package, but API files contain imports of infrastructure classes which results into an error. In particular this one:
import com.example.api.infrastructure.CollectionFormats.*
openapi-generator version
6.3.0
OpenAPI declaration file content or url
task generateApi(type: GenerateTask) {
generateApi.generatorName = "kotlin"
generateApi.packageName = "com.example.api"
generateApi.inputSpec = "api.json"
generateApi.outputDir = "$rootDir/api"
generateApi.skipValidateSpec = true
generateApi.additionalProperties = [
useCoroutines: "true",
library : "jvm-retrofit2",
sourceFolder : "src/main/java",
]
generateApi.globalProperties = [
apiDocs : "false",
modelDocs: "false",
apis : "",
models : "",
]
}
Steps to reproduce
generate API files using provided options
open any API file
check imports
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the provided Gradle GenerateTask configuration and api.json, using the Kotlin generator with the jvm-retrofit2 library and APIs/models-only global properties. Inspect the generated API files for infrastructure imports such as CollectionFormats; done means API-only generation produces files without imports for omitted infrastructure classes.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 42/100