-
Notifications
You must be signed in to change notification settings - Fork 6k
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
Generated Android client has high number of referenced methods #687
Comments
The main culprits will be JSON and HTTP support. using gson should help considerably as we don't need all of Jackson's fancy methods for android. |
@fehguy Yes, swapping for gson would be good start. The Jackson libs alone contribute 7-8k to the limit. |
I have been looking into this. Here is what I propose: We should change the swagger-codegen templates to, wherever possible, use libraries contained within the Android API bucket. If these libraries are used, they do not count against the method limit. |
@who that's the right move. |
I found that using the basic Android API to parse a string of JSON into a pojo instance is tough and ugly. So, the JSON stack is still one area that probably would be best left up to other libs. It makes more sense to use gson over jackson for this, as we are currently only using a small fraction of jackson's capabilities, and gson is only 1200 methods compared to jackson's ~7500. |
@who I get it. The code generator, though doesn't have feelings so we can make it do a bit more work than we'd like to write manually, if it makes more efficient code. I'll look in a while to see if we can put some generalizations on top of the android generator. |
Out of curiosity, won't jackson-jr alleviate the issue with the methods? |
@webron I just cloned the jackson-jr repo, compiled it, and counted the methods in the resulting jar. The method count is 2852, still higher than gson's 1233. |
Cool, thanks for checking. The reason I asked is from my limited experience (including in Android), Jackson tends to perform significantly better than Gson which is why many developers opt to use it. Eventually, people can customize the codegen to suit their needs. I definitely don't have a preference for one over the other (in this context). |
@webron Actually, Jackson performs significally better when it's used in the stream mode, as pull-parser. In mapping mode it's not overperforming Gson so much. |
@0legg - guess we had a different experience ;) |
In an Android app, there is a limit on the number of methods you can have. This limit is ~65k.
Because of the dependencies that it imports, the android-java client generated by swagger-codegen has a significantly high number of methods referenced. We should see if this can be reduced.
Below is an example. Note: the example relies on https://gist.github.com/who/cdb37baffa7f64d27180
The text was updated successfully, but these errors were encountered: