Skip to content
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

Feature: Use gson for android-client instead of jackson #726

Merged
merged 3 commits into from
May 7, 2015
Merged

Feature: Use gson for android-client instead of jackson #726

merged 3 commits into from
May 7, 2015

Conversation

who
Copy link
Contributor

@who who commented May 7, 2015

As discussed in #687, the generated android client has a high number of methods, which could potentially make it prohibitive to include inside Android apps. One of the proposed changes from #687 was to use gson instead of jackson, which this PR fulfills. With this work, I was able to trim the method counts from 15000-16000 down to ~7600.

I created a fat jar of the petstore android client with and without my modifications, and these are the results I observed:

json lib method count (fat jar)
jackson 15739
gson 7657

@fehguy
Copy link
Contributor

fehguy commented May 7, 2015

@who this is awesome. Can we get the tests to pass with the new library? If the tests pass, I'll merge.

@who
Copy link
Contributor Author

who commented May 7, 2015

@fehguy

All tests passed on my local fresh checkout, but let's see what Travis CI tells us.

@fehguy
Copy link
Contributor

fehguy commented May 7, 2015

Great. Thanks again for the contribution

@who
Copy link
Contributor Author

who commented May 7, 2015

@fehguy

Which tests were you referring to? The tests run as a part of the maven build of swagger-codegen, which are passing according to Travis CI, or the tests that run after the android-java petstore sample is generated? If you are referring to the latter, I don't think these run in Travis CI at all; as far as I know, the only way to run them is to download the code, run the generator, and observe test output.

Here's my script to get a fresh clone and run tests:

cd $(mktemp -d /tmp/tmp.XXXXXX);
git clone https://github.com/who/swagger-codegen.git swagger-codegen;
cd swagger-codegen;
git checkout feature/gson-for-android-client;
./bin/android-java-petstore.sh;
cd samples/client/petstore/android-java;
gradle cleanTest test;
cat build/test-results/debug/*;

And the results:

<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="io.swagger.petstore.test.PetApiTest" tests="7" skipped="0" failures="0" errors="0" timestamp="2015-05-07T06:46:43" hostname="trust-desktop-vm" time="1.204">
  <properties/>
  <testcase name="testCreateAndGetPet" classname="io.swagger.petstore.test.PetApiTest" time="0.09"/>
  <testcase name="testFindPetsByStatus" classname="io.swagger.petstore.test.PetApiTest" time="0.344"/>
  <testcase name="testFindPetsByTags" classname="io.swagger.petstore.test.PetApiTest" time="0.147"/>
  <testcase name="testDeletePet" classname="io.swagger.petstore.test.PetApiTest" time="0.19"/>
  <testcase name="testUpdatePetWithForm" classname="io.swagger.petstore.test.PetApiTest" time="0.192"/>
  <testcase name="testUploadFile" classname="io.swagger.petstore.test.PetApiTest" time="0.133"/>
  <testcase name="testUpdatePet" classname="io.swagger.petstore.test.PetApiTest" time="0.101"/>
  <system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[]]></system-err>
</testsuite>
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="io.swagger.petstore.test.StoreApiTest" tests="3" skipped="0" failures="0" errors="0" timestamp="2015-05-07T06:46:41" hostname="trust-desktop-vm" time="0.873">
  <properties/>
  <testcase name="testPlaceOrder" classname="io.swagger.petstore.test.StoreApiTest" time="0.628"/>
  <testcase name="testDeleteOrder" classname="io.swagger.petstore.test.StoreApiTest" time="0.188"/>
  <testcase name="testGetInventory" classname="io.swagger.petstore.test.StoreApiTest" time="0.055"/>
  <system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[]]></system-err>
</testsuite>
<?xml version="1.0" encoding="UTF-8"?>
<testsuite name="io.swagger.petstore.test.UserApiTest" tests="5" skipped="0" failures="0" errors="0" timestamp="2015-05-07T06:46:42" hostname="trust-desktop-vm" time="0.428">
  <properties/>
  <testcase name="testCreateUser" classname="io.swagger.petstore.test.UserApiTest" time="0.095"/>
  <testcase name="testLoginUser" classname="io.swagger.petstore.test.UserApiTest" time="0.101"/>
  <testcase name="testCreateUsersWithArray" classname="io.swagger.petstore.test.UserApiTest" time="0.091"/>
  <testcase name="testCreateUsersWithList" classname="io.swagger.petstore.test.UserApiTest" time="0.102"/>
  <testcase name="logoutUser" classname="io.swagger.petstore.test.UserApiTest" time="0.037"/>
  <system-out><![CDATA[]]></system-out>
  <system-err><![CDATA[]]></system-err>
</testsuite>
me@box:/tmp/tmp.xP6e94/samples/client/petstore/android-java$ 

@fehguy
Copy link
Contributor

fehguy commented May 7, 2015

@who unfortunately you need to give a flag to execute the tests (looks like you have them passing) when you build from the top level. If we didn't do that, you'd need xcode, php, etc. all installed just to build.

For android, you can run the tests like such:

mvn integration-test -Pandroid-client

If you've removed the pom.xml then we should put something in there so maven can execute the child module.

@who
Copy link
Contributor Author

who commented May 7, 2015

@fehguy Ahhhhh, ok - that makes sense.

The pom was deleted by @0legg in this PR: #699

I'll restore the pom.xml and kick off the tests. In the future we can add a pom plugin for gradle, so we eventually won't need a pom.xml, but for now we should just bring it back so we have integration test capabilities.

@who
Copy link
Contributor Author

who commented May 7, 2015

@fehguy Ok, the pom.xml is restored and integration tests are runnable.

Results :

Tests in error: 
  testUploadFile(io.swagger.petstore.test.PetApiTest): <html>(..)

Tests run: 15, Failures: 0, Errors: 1, Skipped: 0

@fehguy
Copy link
Contributor

fehguy commented May 7, 2015

Great, thank you

fehguy added a commit that referenced this pull request May 7, 2015
Feature: Use gson for android-client instead of jackson
@fehguy fehguy merged commit c7e22b7 into swagger-api:develop_2.0 May 7, 2015
webron added a commit that referenced this pull request May 12, 2015
Reverted JsonUtil.mustache for JavaClientCodegen after PR #726.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants