Skip to content

[BUG] Import mapping not working for return type #14525

@timmisset

Description

@timmisset

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

I override the type array from java.util.List to java.util.Collection. This works perfectly fine for input arguments. However, when only the return class of the interface method is a Collection the import is not added.

pom.xml

                    <typeMappings>array=Collection</typeMappings>
                    <importMappings>
                        <importMapping>Collection=java.util.Collection</importMapping>
                    </importMappings>

generatedResource.java

package ...
<-- expecting java.util.Collection import here, but not added

...
Collection<MyClass> myMethod()
...
openapi-generator version

6.2.1

OpenAPI declaration file content or url

If you post the code inline, please wrap it with

      responses:
        '200':
          content:
            application/json:
              schema:
                type: array
                items:
                  $ref: '#/components/schemas/MyClass'
Generation Details

generated with maven plugin

Steps to reproduce

generate code with yaml as input and the specified configuration

Related issues/PRs
Suggest a fix

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