OpenAPITools / OpenAPITools/openapi-generator
[BUG] Kotlin generator not generating compilable code, enum import issue
Open
Nobody has claimed this yet.
Issue: Bug
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- I have validated the input using an validator
- I have tested with the latest master to confirm the issue still exists.
- I have searched for related issues/PRs.
Description
The kotlin generator and the generated code will not compile as imports for enum are missing.
openapi-generator version
v7.10.0, also tried latest (as of 2025/01/10).
OpenAPI declaration file content or url
Please provide email to send url in private.
Steps to reproduce
- Run generator
openapi-generator \
generate \
--package-name com.name.generated \
-i https://.../...-swagger.json \
--global-property models,modelDocs=false,modelTests=false,apis,apiDocs=false,apiTests=false,supportingFiles \
-g kotlin \
-o .
- Try and compile code.
- Several files will not compile, e.g: CancelPoliciesApi.kt line 156 COMPACT enum has not been imported.
- If I go through each file with issues and add the import for the enum by hand the issue is resolved.
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 Kotlin generator by reproducing the issue using the provided openapi-generator command, then inspect the generated CancelPoliciesApi.kt around line 156 and its referenced enum. Done means the generated Kotlin files include the required enum imports and compile without manual edits.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- tooling
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100