OpenAPITools / OpenAPITools/openapi-generator
[BUG][Kotlin] An interface marked with @JsonClass annotation
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Description
When generating models with inheritance, which is done via data class : interface manner, an interface is also marked with a @JsonClass annotation, which results into a compilation error: error: @JsonClass can't be applied to ...
openapi-generator version
6.5.0
Generation Details
Generate kotlin client with jvm-retrofit2 library and "moshiCodeGen" config option is set to "true".
Possible fix
file: data_class.mustache
change:
{{#moshiCodeGen}}@JsonClass(generateAdapter = true){{/moshiCodeGen}}
to:
{{#moshiCodeGen}}{{^discriminator}}@JsonClass(generateAdapter = true){{/discriminator}}{{/moshiCodeGen}}
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 data_class.mustache and generate a Kotlin client using the jvm-retrofit2 library with moshiCodeGen enabled, using an inherited data class and interface. Check the generated interface and compilation result; done means the interface is not given an invalid @JsonClass annotation while concrete models retain the expected generation behavior.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- kotlin
- Domain
- api, tooling
- Issue type
- Bug
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 45/100