Skip to content

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

Closed

Description

@rignicat

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.

Activity

  1. mvanglabbeek commented on Mar 2, 2023

    @mvanglabbeek

    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.

  2. rignicat commented on Mar 6, 2023

    @rignicat
    ContributorAuthor

    @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?

  3. wing328 commented on Mar 15, 2023

    @wing328
    Member

    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
    
  4. wing328 commented on Mar 15, 2023

    @wing328
    Member

    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

  5. wing328 commented on Mar 17, 2023

    @wing328
    Member

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

  6. rignicat commented on Mar 22, 2023

    @rignicat
    ContributorAuthor

    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

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions