-
-
Notifications
You must be signed in to change notification settings - Fork 142
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Jackson module scala potentially breaks serialization for swagger Model #454
Comments
swagger 1.5 is compiled with an older version of jackson and is very dependent on using the version that appears in its dependency list - arbitrarily updating jackson to latest version does not work - if you update both jackson and swagger, you'll find latest version of swagger is built with latest version of jackson https://mvnrepository.com/artifact/io.swagger/swagger-jaxrs/1.5.23 -- depends on jackson 2.9.9 |
That did it! I would have had a very hard time finding that out on my own. Thanks! |
@pjfanning I did a bit more poking around. It seems I am able to use other versions of jackson, but I still run into the error depending on my version of jackson-module-scala. Here is my build.gradle
Does it even make sense to you that jackson-module-scala would come into play serializing a non scala collection? |
similar issue - swagger-akka-http/swagger-akka-http#171 - but I was able to code around that problem |
I added a test case to the 2.11 branch that reproduces the problem (SwaggerTest) - still need to find time to debug why adding the DefaultScalaModule makes the code fail |
I have added a hacky fix in 2.11 branch, targeted for 2.11.2 release. I modified the code to get the jackson scala module to ignore the swagger model classes. I hope I can find a better solution but this will do as a transitional fix. |
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());
`
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 onModelImpl
: https://www.javadoc.io/doc/io.swagger/swagger-models/1.5.13/io/swagger/models/ModelImpl.htmlAny 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:+"
The text was updated successfully, but these errors were encountered: