-
Notifications
You must be signed in to change notification settings - Fork 46
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
ApiDocumentationController - getResources() doesnt convert to JSON #33
Comments
Hi Eibach, I faced the same issue and you're absolutely correct about the ResourceListing object not getting serialized. I got around the problem by hacking up the code to serialize the object using custom jackson serializer. By custom serializer, I mean simply adding the scala module: https://github.com/FasterXML/jackson-module-scala This is still a hacky way of doing it, and I am a newb when it comes to Spring and Scala. :) It would be nice to know the 'right' way of doing this. |
Hi @faddy, I did see that module as well, but I refrained from using it because it looks like it is already being included when you import swagger-core. I just tried using: com.fasterxml.jackson.module jackson-module-scala_2.10 2.3.0and it didnt seem to work |
@faddy can you create a pull request so we can integrate this fix into the main branch. Thanks |
@eibach The hack I used was to quickly get around the serialization issue for my specific use case. I am not sure how to actually fix the problem. IMO, a good way would be to use a custom JSON serializer in Spring itself, hence automatically serializing the scala objects into json objects. As I said, I am a noob at Spring, so not sure how to do that. :) If you're interested, here is my APIDocumentationController: http://pastebin.com/UiAVn9kJ Again, this is just a hack and not an actual fix. |
Thanks that did fix the issue. Now I am having another problem. Issue #32 |
Thank you for finding this issue. Here is a way to get around this problem. Add the following to the appropriate Spring context file for your application:
Please let me know if you are still seeing issues. Thanks! |
When I insert that into my applicationContext.xml it gives me an error "Element beans:bean does not belong here" |
Moving some of the comments over from #34: I have tried the approaches above with no joy. Regardless of version 0.2.0 or 0.3.0 the library does not seem to be building the list of API endpoints at all. |
After I implemented @faddy 's solution I am now seeing at the bottom of the swagger ui, and before it was showing the correct base "https://localhost/api/v1" Any ideas? |
@eibach and @andrewrutter
from the Jackson message converters. If you don't want to post them you can email me at [email protected] Thanks! |
So, it looks like this is most likely an issue if you have a dependency or transitive dependency on jackson-databind with a version greater than 2.1.5. If this is the case try adding the following dependency on jackson-module-scala_2.10 and excluding the one in swagger4spring-web. For example:
I'll create an issue on Swagger's GitHub site to update jackson-module-scala_2.10 to at least 2.3. I'll also update the swagger4spring-web pom to exclude the older version of jackson-module-scala_2.10 and include the newer one. |
I just tried this out with no luck. |
…est jackson-module-scala_2.10 dependency. See: #33
Other than dependency problems which is just the usual Maven fun and games, I have finally tracked the issue here down to the version of Reflections in use. Looks like there is a known problem with that lib on WebSphere: https://code.google.com/p/reflections/issues/detail?id=124 I think it is fixed in the current version but that is RC only and also breaks the build of swagger4spring due to some api changes! Back to the drawing board here I think unless there is a way to up the reflections version? I see a couple of proposed workarounds so will carry on looking. Thanks for digging into it, at least I know what my issue is now!! Andrew Rutter [email protected] | 404.372.7430 | @ClearCreativity On Jan 17, 2014, at 4:46 PM, Will Kennedy [email protected] wrote:
|
I got the same issue. I made the mistake of appending the message converter at the end of the converters list At the beginning I get the correct result.... ;) |
I have just upgraded swagger to the following versions
swagger-core -> 1.3.1
swagger-annotations -> 1.3.0
swagger-ui -> 2.0.3
swagger4spring-web -> 0.3.0
After doing so I tried to go to /api/docs/resourceList and it returns "{ }"
When I step through your code in ApiDocumentationController - getResources() it looks like it creates the correct ResourceListing object however it looks like Spring/Jackson does not correctly convert it to a JSON object before it gets past back to the client.
I am using
Spring - 3.2.4.RELEASE
Jackson - 2.2.2
I have already tried to exclude jackson from getting imported from swagger-core
Any ideas on what could be happening here?
The text was updated successfully, but these errors were encountered: