Use explicit use‑site target annotations for @JsonProperty in generated Kotlin code
@jiholee17 is already working on this.
Since Apr 6, 2026.
- Dominant language
- Kotlin
- Stars
- 217
- Forks
- 116
- PR merge metrics
- No merged PRs in 30d
Description
When generating Kotlin classes with Kotlin 2.2+, each @JsonProperty annotation currently produces the following compiler warning:
w: file:///C:/git/dgs-sample/build/generated/sources/dgs-codegen/com/netflix/dgs/codegen/generated/types/SampleType.kt:14:3 This annotation is currently applied to the value parameter only, but in the future it will also be applied to field.
- To opt in to applying to both value parameter and field, add '-Xannotation-default-target=param-property' to your compiler arguments.
- To keep applying to the value parameter only, use the '@param:' annotation target.
See https://youtrack.jetbrains.com/issue/KT-73255 for more details.
Additional context is available here:
https://blog.jetbrains.com/idea/2025/09/improved-annotation-handling-in-kotlin-2-2-less-boilerplate-fewer-surprises/
To avoid these warnings and ensure consistent behavior across Kotlin versions, the code generator should use explicit use‑site targets. Instead of:
@JsonProperty("fieldName")
the generator should emit:
@field:JsonProperty("fieldName")
This explicitly applies the annotation to the field and matches the recommended approach for Kotlin 2.2+.
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.
Assessment
This issue has not been assessed yet.