Skip to content

[JAVA] 4709: codegen with parcelableMode fails to build if using arra…#7867

Merged
wing328 merged 1 commit intoswagger-api:masterfrom
SergeyLyakhov:java-parcelable-issue-4709
Mar 20, 2018
Merged

[JAVA] 4709: codegen with parcelableMode fails to build if using arra…#7867
wing328 merged 1 commit intoswagger-api:masterfrom
SergeyLyakhov:java-parcelable-issue-4709

Conversation

@SergeyLyakhov
Copy link
Copy Markdown
Contributor

…ys in swagger.

PR checklist

[+] Read the contribution guidelines.
[+] Ran the shell script under ./bin/ to update Petstore sample so that CIs can verify the change. (For instance, only need to run ./bin/{LANG}-petstore.sh and ./bin/security/{LANG}-petstore.sh if updating the {LANG} (e.g. php, ruby, python, etc) code generator or {LANG} client's mustache templates). Windows batch files can be found in .\bin\windows\.
[+] Filed the PR against the correct branch: 3.0.0 branch for changes related to OpenAPI spec 3.0. Default: master.
[+ ] Copied the technical committee to review the pull request if your PR is targeting a particular programming language.
@wing328 @bbdouglas @JFCote @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger

Description of the PR

Fix issue #4709 for android parcelable array (blocker for PR #7060 which I need to have in codegen).

@JFCote
Copy link
Copy Markdown
Contributor

JFCote commented Mar 19, 2018

Don't know what a parcelable is or what it does but the code looks good. If @wing328 is ok with the feature itself, it LGTM.

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Mar 19, 2018 via email

@SergeyLyakhov
Copy link
Copy Markdown
Contributor Author

SergeyLyakhov commented Mar 19, 2018

@wing328 I'm not familiar with Android, but tested it with AndroidStudio and it looks workable:

    Animal animal = new Animal();
    animal.setColor("red");
    animal.setClassName("testclass");
    Animal animal2 = new Animal();
    animal2.setColor("gold");
    animal2.setClassName("main");
    AnimalFarm farm = new AnimalFarm();
    farm.add(animal);
    farm.add(animal2);
    final Parcel p1 = Parcel.obtain();
    p1.writeValue(farm);
    final byte[] bytes = p1.marshall();
    final Parcel p2 = Parcel.obtain();
    p2.unmarshall(bytes, 0, bytes.length);
    p2.setDataPosition(0);
    final AnimalFarm result = (AnimalFarm) p2.readValue(AnimalFarm.class.getClassLoader());
    System.out.println( result  );

@wing328
Copy link
Copy Markdown
Contributor

wing328 commented Mar 20, 2018

@SergeyLyakhov thanks for the fix, which looks good to me.

For #7060, I'll ping you via email to discuss the best way to move forward with it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants