I'm trying to deserialise an a JSON input using a class that is annotated with @JsonComponent. However, even though I manually register this class, it is still not invoked when I call the endpoint with the input. I use openapi-generator-maven-plugin for generating controllers and aspectj for compile-time weaving. Can this interfere with the objects being recognised?
Note: The same setup works in a different poc application that I made but not this one. The main difference I see is the code generation. Hence I'm wondering if using the open-api-generation interferes with the Deserializer being recognised during the call to the Controller
@JsonComponent
public class UserDeserializer extends JsonDeserializer<User> {
@Override
public User deserialize (JsonParser jsonParser, DeserializationContext
deserializationContext) throws IOException {
log.info("***********INVOKED***************");
TreeNode treeNode = jsonParser.getCodec().readTree(jsonParser);
ObjectMapper objectMapper = new ObjectMapper();
//Some logic here
}
}
Config class has
@Bean
public Module userDeserializer() {
SimpleModule module = new SimpleModule();
module.addDeserializer(User.class, new UserDeserializer());
return module;
}