Skip to content

[Java/GSON] Fix error with enums of integer type #7059

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

Open
wants to merge 4 commits into
base: master
Choose a base branch
from

Conversation

craffael
Copy link
Contributor

@craffael craffael commented Nov 26, 2017

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. @JFCote

Description of the PR

This is the second attempt to fix issue #6806 . The first attempt (PR #7051) introduced a new variable to CodegenModel.java which was rather ugly. The present fix uses an entirely different approach by rewriting the GSON adapter for enums, i.e. only two mustache templates have to be changed.

I have tested the generated code with enums of type string and integer and it worked in both cases. This solution essentially relies on special behavior of com.google.gson.stream.JsonReader#nextString().

@craffael craffael changed the title Second attempt to fix Issue 6806 [Java/GSON] Fix error with enums of integer type Nov 30, 2017
# Conflicts:
#	samples/client/petstore/java/okhttp-gson-parcelableModel/pom.xml
#	samples/server/petstore/java-msf4j/src/gen/java/io/swagger/api/FakeApi.java
@craffael
Copy link
Contributor Author

craffael commented Dec 7, 2017

@bbdouglas @sreeshas @jfiala @lukoyanov What do you think?

@svhi
Copy link

svhi commented Mar 26, 2019

Any Chance this will be part of an upcoming release soon?

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