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

[BUG][JAVA][NATIVE] Pojo with Set uses Arraylist, wrong datatype in for loop #14833

Closed
5 of 6 tasks
RInverid opened this issue Feb 28, 2023 · 6 comments · Fixed by #14961
Closed
5 of 6 tasks

[BUG][JAVA][NATIVE] Pojo with Set uses Arraylist, wrong datatype in for loop #14833

RInverid opened this issue Feb 28, 2023 · 6 comments · Fixed by #14961

Comments

@RInverid
Copy link
Contributor

RInverid commented Feb 28, 2023

Bug Report Checklist

  • Have you provided a full/minimal spec to reproduce the issue?
  • Have you validated the input using an OpenAPI validator (example)?
  • Have you tested with the latest master to confirm the issue still exists?
  • Have you searched for related issues/PRs?
  • What's the actual output vs expected output?
  • [Optional] Sponsorship to speed up the bug fix or feature request (example)
Description

When using an object with a set, I ran into two separate issues:

  1. The generated add to set method assigns ArrayList to the set, which fails compilation
  2. The generated toUrlQueryString uses the wrong datatype in a for loop with the set, which fails compilation
openapi-generator version

6.4.0

OpenAPI declaration file content or url

https://gist.github.com/RInverid/417213fbba82782204ddce87b22d5d62

Generation Details

Java, native http library

Steps to reproduce

Try to build the generated client, it fails to build due assigning a list to a set, and looping over the enum instead of an array

Suggest a fix

Issue 1:
variable is correctly assigned here and incorrectly assigned here. Caused by commit fd45b74

Issue 2:
Datatype is incorrect here, in this case it should be an enum.

@mvanglabbeek
Copy link

I experience the same issue. Version 6.2.1 initialized the java.util.Set with this.fieldName = new LinkedHashSet<>();, which is correct. Version 6.3.0 and version 6.4.0 initializes the java.util.Set with this.fieldName = new ArrayList<>(); (without importing java.util.ArrayList), which is broken code.

@RInverid
Copy link
Contributor Author

RInverid commented Mar 6, 2023

@wing328 the official maintainer of Java (Java 11 Native HTTP client) @bbdouglas, has been inactive since 2019. Maybe this API client should be marked as unsupported?

@wing328
Copy link
Member

wing328 commented Mar 15, 2023

I've filed #14961 to fix the issue. Please pull it to give it a try. You may need the option --additional-properties supportUrlQuery=false to skip the toUrlQuery method, e.g.

java -jar modules/openapi-generator-cli/target/openapi-generator-cli.jar generate -g java --library native -i https://gist.githubusercontent.com/RInverid/417213fbba82782204ddce87b22d5d62/raw/d85d89ec41db9e6a93400426ffc8178b5879305b/spec.json -o /tmp/native --additional-properties supportUrlQuery=false

@wing328
Copy link
Member

wing328 commented Mar 15, 2023

Maybe this API client should be marked as unsupported?

The native library support is maintained by the community. There has been a lot of enhancements (PRs) so I don't think we should deprecate it.

We appreciate @bbdouglas for contributing the first version of native library support

@wing328
Copy link
Member

wing328 commented Mar 17, 2023

the fix has been merged and will be included in the upcoming 6.5.0 release

@RInverid
Copy link
Contributor Author

Yeah that fixed the first issue, and the additional property circumvents the second issue. Thanks a bunch :)

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

Successfully merging a pull request may close this issue.

3 participants