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][Spring] Config options for Pageable & ApiIgnore #8360

Closed
5 tasks done
morphlne opened this issue Jan 6, 2021 · 11 comments
Closed
5 tasks done

[BUG][JAVA][Spring] Config options for Pageable & ApiIgnore #8360

morphlne opened this issue Jan 6, 2021 · 11 comments

Comments

@morphlne
Copy link
Contributor

morphlne commented Jan 6, 2021

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

Trying to generate pure interfaces using next config:

<generateSupportingFiles>false</generateSupportingFiles>
<configOptions>
    <openApiNullable>false</openApiNullable>
    <java8>false</java8>
    <interfaceOnly>true</interfaceOnly>
    <hideGenerationTimestamp>true</hideGenerationTimestamp>
</configOptions>

Following lines are added to generated api file:

import org.springframework.data.domain.Pageable;
import springfox.documentation.annotations.ApiIgnore;

and produced compilation error due those classes needed additional dependencies (spring-data-commons&springfox-core)

Didn't manage to find any option to disable those imports (like openApiNullable for disabling org.openapitools.jackson.nullable.JsonNullable)

openapi-generator version

5.0.0

OpenAPI declaration file content or url

Sample project for quick reproducing https://github.com/morphlne/openapi-generator-demo

Steps to reproduce

Clone https://github.com/morphlne/openapi-generator-demo.git
run mvn compile

Related issues/PRs

Both imports added in mustache files in PR: #5022

Suggest a fix

Add support for next config options:

<usePageable>false</usePageable>
<useApiIgnore>false</useApiIgnore>
@feliperuiz
Copy link

I believe #8192 also relates to this. It seems to have been introduced by #5022, which added the imports for @ApiIgnore and Pageable without checking they are indeed required to be present.

There seems to exist a computed flag/setting for the use of @ApiIgnore—springfox as a whole, more accurately—but it gets imported without checking it.

I was actually facing the same issue and was planning on coming up with a patch to only add those imports when they're needed, but I couldn't find my way around the test suite—which test methods/resources would need to be updated, or even how to properly run the tests in the first place =/

@borsch
Copy link
Member

borsch commented Jan 9, 2021

@feliperuiz there is no need to run tests. after you fix templates you simply has to re-generate all related samples via ./bin/generate-samples.sh to generate all or ./bin/generate-samples.sh bin/configs/CONFIG.yaml to generate specific (ex: ./bin/generate-samples.sh bin/configs/java-vertex.yaml

@morphlne
Copy link
Contributor Author

morphlne commented Jan 9, 2021

Fixed locally by adding new config options & changing mustache template. Will prepare PR for this fix

@MatCyg
Copy link

MatCyg commented Feb 16, 2021

Is there any workaround available already? (beside adding unnecessary imports to you project)

@morphlne
Copy link
Contributor Author

@MatCyg As quick solution you can use 5.0.0-beta2 and any earlier version

@pierrefevrier
Copy link

Same problem with version 5.0.1

@bruteforce
Copy link

Any workaround?

@morphlne
Copy link
Contributor Author

@bruteforce partially resolved in #8915, 5.1.0 release
My proposed solution (#8421) still waiting for review

@samjingwen
Copy link

Is this issue fixed in the latest release?

@flabbamann
Copy link

Seems to be fixed in 5.3.0

@morphlne
Copy link
Contributor Author

Resolved in 5.3.0

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.

8 participants