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

Android: list of enums generates syntax error due to mustache HTML encoding #2124

Open
5 of 6 tasks
jacobweber opened this issue Feb 11, 2019 · 5 comments
Open
5 of 6 tasks

Comments

@jacobweber
Copy link
Contributor

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • What's the version of OpenAPI Generator used?
  • Have you search for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Bounty to sponsor the fix (example)
Description

In my Swagger 2 spec, I have a Definition with an array property. Its items are defined as strings with an enum-erated list of values. When I use the "android" generator, it incorrectly HTML-encodes the List definition, resulting in a syntax error.

The property looks like:

        "gender": {
          "type": "array",
          "items": {
            "type": "string",
            "enum": [
              "Male",
              "Female"
            ]
          }
        },

and the resulting Java code looks like:

  public enum List<GenderEnum> {
     Male,  Female, 
  };
openapi-generator version

4.0.0-SNAPSHOT

OpenAPI declaration file content or url

https://gist.github.com/jacobweber/c21e944d6e627a92ddcfd02242aca117

Command line used for generation
java -jar /path/to/openapi-generator-cli.jar generate -i /path/to/spec.json -g android -o /path/to/output
cd /path/to/output
mvn clean package
Steps to reproduce

See above

Related issues/PRs

None

Suggest a fix

None

@auto-labeler
Copy link

auto-labeler bot commented Feb 11, 2019

👍 Thanks for opening this issue!
🏷 I have applied any labels matching special text in your issue.

The team will review the labels and make any necessary changes.

@jmini
Copy link
Member

jmini commented Feb 13, 2019

Thank you for this issue.

The feature you are describing is supported by the Java generators.

Often the mistake is to use {{type}} instead of {{{type}}} in the template (or vice versa).

@jacobweber
Copy link
Contributor Author

@jmini I think that's likely. I haven't had this issue with the Java generators; only the Android one.

@lemoinem
Copy link
Contributor

The actual problem here, is that the property is recognized as a single value of type GenderEnum, which, in turn, as a value List<String>, whereas it should be a value of type List<GenderEnum> and GenderEnum should use String type.
There is the same issue with the Kotlin-client generator (gradle plugin 3.3.4)
I'm not sure how to fix it.

@jmini
Copy link
Member

jmini commented Jul 10, 2019

I am not familiar with the android and kotlin generator, but what you described is solved in the Java generators (list of enums...).

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

No branches or pull requests

3 participants