OpenAPITools / OpenAPITools/openapi-generator
[BUG][Kotlin] Data class generated with unneded { } and backspaces
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Bug Report Checklist
- Have you provided a full/minimal spec to reproduce the issue?
- Have you validated the input using an OpenAPI validator (example)?
- Have you tested with the latest master to confirm the issue still exists?
- Have you searched for related issues/PRs?
- What's the actual output vs expected output?
- [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description
I inherited a work project using Swagger and OpenAPI. When updating the classes with openapi-generator-cli , the DTO data classes have unwanted / unneeded { } at the end of the file:
data class MyModelRequestDto (
...
) {
}
openapi-generator version
I'm using openapi-generator-cli-7.9.0 (previous one was 7.4.0).
OpenAPI declaration file content or url
This is the script the previous developer used to launch the generator:
#!/bin/sh
echo "Start generation API for mobile"
java -jar openapi-generator-cli-7.9.0.jar generate \
-i https://my.work/swagger/v7/swagger.json \
-g kotlin \
--package-name com.work.services.mobile \
--library jvm-retrofit2 \
--additional-properties=additionalModelTypeAnnotations=@kotlinx.serialization.Serializable \
--additional-properties=dateLibrary=string \
--additional-properties=useCoroutines=true \
--additional-properties=omitGradleWrapper=true \
--type-mappings=java.util.UUID=String \
--language-specific-primitives=Int \
--type-mappings=integer=Int \
--language-specific-primitives=String \
--type-mappings=string=String \
--language-specific-primitives=Boolean \
--type-mappings=boolean=Boolean \
--additional-properties=groupId=com.work.services \
--global-property=modelDocs=false \
--global-property=modelTests=false \
--global-property=apiDocs=false \
--global-property=apiTests=false \
-o ../mobile-api/
echo "Generation API for mobile ended"
Generation Details
Nothing to declare (I suppose).
Steps to reproduce
Update generator from a previous version.
Launch the script .sh above.
See issues on data classes.
Related issues/PRs
Didn't find any similar issues by searching with "kotlin", "data class", "{" keywords.
Suggest a fix
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 shell script and compare the Kotlin model output from openapi-generator-cli 7.9.0 with 7.4.0, using the referenced Swagger JSON input if available. Trace the Kotlin model-generation entry point responsible for the data class declaration. Done means generated data classes no longer contain the unwanted empty braces or backspaces, with the behavior verified against a minimal reproducible input.
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
- 25/100