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] Import mapping not working for return type #14525

Closed
6 tasks
timmisset opened this issue Jan 25, 2023 · 2 comments · Fixed by #15719
Closed
6 tasks

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

timmisset opened this issue Jan 25, 2023 · 2 comments · Fixed by #15719

Comments

@timmisset
Copy link

timmisset commented Jan 25, 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

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
martin-mfg added a commit to martin-mfg/openapi-generator that referenced this issue Apr 25, 2023
@martin-mfg
Copy link
Contributor

Hi, did you use the java generator, or a different one?

@timmisset
Copy link
Author

Hi @martin-mfg,
I used the jaxrs-spec generator

wing328 pushed a commit that referenced this issue Jun 21, 2023
* importContainerType = true

* add unit test

* disable MyImportTest

* build all samples, add import exceptions

* simplify code

* delete myImportTest

* generate docs

* extend comment

* remove inline comment
fmoraespadtec pushed a commit to padteclab/openapi-generator that referenced this issue Jun 26, 2023
…s#15719)

* importContainerType = true

* add unit test

* disable MyImportTest

* build all samples, add import exceptions

* simplify code

* delete myImportTest

* generate docs

* extend comment

* remove inline comment
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.

2 participants