Description
Hello, running into a bit of a weird case here. Our project is in scala, but I have reproduced minimally with the code below. When I run the following
`
ObjectMapper mapper = new ObjectMapper();
mapper.registerModule(new DefaultScalaModule());
Model model = new ModelImpl();
Property property = new IntegerProperty();
Map<String, Property> map = new HashMap<String, Property>();
map.put("foo", property);
model.setProperties(map);
System.out.println(mapper.writeValueAsString(model));
`
I end up with the following exception com.fasterxml.jackson.databind.exc.InvalidDefinitionException: Direct self-reference leading to cycle
When I remove
mapper.registerModule(new DefaultScalaModule());
Things deserialize as I would expect. It could be that I have something misconfigured somewhere, but I am surprised that the inclusion of the DefaultScalaModule makes a difference as ModelImpl
is not a scala collection or class. More details on ModelImpl
: https://www.javadoc.io/doc/io.swagger/swagger-models/1.5.13/io/swagger/models/ModelImpl.html
Any thoughts?
From my minimal example:
compile "io.dropwizard:dropwizard-jackson:2.0.10" compile "io.swagger:swagger-jersey2-jaxrs:1.5.13" compile "com.fasterxml.jackson.module:jackson-module-scala_2.12:+"