SingleRequestParameter setter parameter construction#20679
Merged
wing328 merged 6 commits intoOpenAPITools:masterfrom Feb 26, 2025
Merged
SingleRequestParameter setter parameter construction#20679wing328 merged 6 commits intoOpenAPITools:masterfrom
wing328 merged 6 commits intoOpenAPITools:masterfrom
Conversation
Member
|
thanks for the PR also cc @cchacin |
Member
|
@Mattias-Sehlstedt can you please review the CI failure when you've time? |
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object o) { |
Contributor
Author
There was a problem hiding this comment.
Just copying the pojo implementation obviously doesn't get the job done properly. Will investigate if I am able to adjust it or if I will drop equals/hashcode entirely.
I assume the change is to replace Vars with Params in the mustache. But I am not sure what extension settings that would be relevant.
Contributor
|
LGTM 👍 |
martin-mfg
suggested changes
Feb 20, 2025
Contributor
martin-mfg
left a comment
There was a problem hiding this comment.
With both webclient and restclient, when using the new option useSingleRequestParameter=static the generated code doesn't compile. Please fix.
martin-mfg
approved these changes
Feb 21, 2025
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
fix #20668
Introduces so that the argument class which is generated for
useSingleRequestParametercan be constructed similar to the POJO models. The implementation uses the new (but yet to be released) "static" setting to further expand on the behavior ofuseSingleRequestParameter.I have realize this behavior with mustache configuration rather than lombok to make it easier to make the behavior even more similar to that of POJOs in the future (e.g., sort parameters so required ones are highlighed in some sense, adding nullable annotations to class fields to highlight/trigger runtime errors when they are required).
A single lombok annotation is used to provide. I will investigate how to add an equals implementation as a separate issue.equalsto the class, to facilitate easier testing when working with mocks and verifying themThe current implementation for
useSingleRequestParameteruses a record for RestClient, and a class for WebClient. In order to bring these SpringClients closer to each other, I have made it so that the RestClient will switch to also using a class when "static" is provided (but retain a record for "true" as to not make a breaking change).A better description than
..., but also makes the generated arguments class static with single parameter instantiationcan probably be made.cc @bbdouglas (2017/07) @sreeshas (2017/08) @jfiala (2017/08) @lukoyanov (2017/09) @cbornet (2017/09) @jeff9finger (2018/01) @karismann (2019/03) @Zomzog (2019/04) @lwlee2608 (2019/10) @martin-mfg (2023/08)
Edit notes: clarified that I will omit the equals implementation and instead do it separately so I can have time to investigate how to properly express it with mustache syntax.
PR checklist
Commit all changed files.
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*.IMPORTANT: Do NOT purge/delete any folders/files (e.g. tests) when regenerating the samples as manually written tests may be removed.
master(upcoming7.x.0minor release - breaking changes with fallbacks),8.0.x(breaking changes without fallbacks)