I use the openapi generator kotlin module to generate kotlin classes from my openapi.yaml file. The process works fine until I try to deserialize the received JSON in my code to a kotlin class using Jackson.
This is the generated class
data class Request (
@field:JsonProperty("name")
var name: kotlin.String,
)
This is the error I get
java.lang.IllegalArgumentException: Cannot construct instance of `...package.Request` (although at least one Creator exists): cannot deserialize from Object value (no delegate- or property-based Creator)
at [Source: UNKNOWN; byte offset: #UNKNOWN]
I noticed that when I remove the "@field:"
part in the generated code, then everything works like a charm.
So now my question is can I either remove the @field from the generator or make Jackson deserialize it correctly?
The versions that I use are
- jackson: 2.13.1
- open-api-generator (gradle plugin): 5.3.0