spring: fix spring pageable used without any config#15113
spring: fix spring pageable used without any config#15113borsch merged 3 commits intoOpenAPITools:masterfrom
Conversation
|
Not part of the project, but LGTM, tests are also good. This should be merged since the current behaviour really only causes issues. |
|
Hello, pinging the Java Spring Technical committee: @cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09) Since I didn't used the PR template at first, hence this PR was perhaps lost. Cheers, |
welshm
left a comment
There was a problem hiding this comment.
This will break anyone relying on the existing unintended behaviour.
We can either do this and announce it as a breaking change - or we can introduce a configuration flag.
I think what you've done is fine, just want to make sure we're being mindful that this is a breaking change.
modules/openapi-generator/src/test/resources/bugs/issue_13052.yaml
Outdated
Show resolved
Hide resolved
I completely agree that this fix changes the current behaviour. we already have the If we want no breaking change, we could:
Or just bite the bullet and advertise the breaking change (adding a note for anyone relying on the previous behaviour to set x-spring-paginated to true). wdyt ? |
I agree and I think we bite the bullet - I was just making sure we're all aware it's breaking :) |
|
sorry, maybe I've missed something, but how this change can break existing clients? |
My understanding is that currently, if you include a Pageable in your spec, then it will import Spring Pageable even if that is not the intended behaviour
This is enforcing the usage of |
I assume that users will face this issue only if they use some custom templates, because otherwise they shouldn't care much about unused import inside generate code |
Fair point - likely to only impact those using custom templates |
|
given above I'll merge this PR once build is green. Also I'll mark this change as "with breaking changes" since still there might be small percentage of users which might rely on previous behavior @gonzalad please update PR & fix failed pipelines |
|
Hi @borsch, the pipeline is failing on I do not reproduce it in my local laptop. I'm running: Some things are quite strange:
Did something similar happened before ? Or am I looking at a wrong location ? Thanks, [1] Failed CI error is available here: https://github.com/OpenAPITools/openapi-generator/actions/runs/5084497711/jobs/9136946749?pr=15113 |
|
@gonzalad I would try rebasing from master and re-pushing the branch. It could be that your branch is out of date which is causing the issues. |
Spring Pageable is imported whenever we have an API with a Pageable Json schema, even if x-spring-paginated is not set. This commit imports Spring Pageable only if x-spring-paginated is set to true.
remove unrelated example
|
I just rebased and pushed, and CI looks good now Thanks @welshm ! |
Edit on 05/25/2023: filled PR template
Spring Pageable is imported whenever we have an API with a Pageable Json schema, even if x-spring-paginated is not set.
This was breaking existing open Api which where using a Pageable (non-Spring) component.
This commit imports Spring Pageable only if x-spring-paginated is set to true.
To achieve that, I need to wait until operation processing (fromOperation method) to alter the importMapping setting.
This fixes #13052
PR checklist
This is important, as CI jobs will verify all generator outputs of your HEAD commit as it would merge with master.
These must match the expectations made by your contribution.
You may regenerate an individual generator by passing the relevant config(s) as an argument to the script, for example
./bin/generate-samples.sh bin/configs/java*.For Windows users, please run the script in Git BASH.
master(6.3.0) (minor release - breaking changes with fallbacks),7.0.x(breaking changes without fallbacks)Java Spring Technical Committee:
@cachescrubber (2022/02) @welshm (2022/02) @MelleD (2022/02) @atextor (2022/02) @manedev79 (2022/02) @javisst (2022/02) @borsch (2022/02) @banlevente (2022/02) @Zomzog (2022/09)