-
-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
[java][client] fix: Add static modifier to inner class in Java when useSingleRequestParameter=true #20590
Conversation
77952f4
to
f0016d1
Compare
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) |
...va/webclient-useSingleRequestParameter/src/main/java/org/openapitools/client/api/PetApi.java
Outdated
Show resolved
Hide resolved
f0016d1
to
4ed1fd3
Compare
Hi sorry for intruding in the PR (I'll make an issue (and a PR for my suggestion) if you think this is misplaced), but I was just myself about to contribute something similar to this). I had been looking into extending the functionality of the public static class DeletePetRequest {
private String parameter1;
private String parameter2;
...
public DeletePetRequest() {}
public DeletePetRequest(String parameter1, String parameter2, ...) {
this.parameter1 = parameter1;
...
}
public DeletePetRequest parameter1(String parameter1) {
this.parameter1 = parameter1;
}
public DeletePetRequest parameter2(String parameter2) {
this.parameter2 = parameter2;
}
...
} This so that it is easy to only interact with the parameters that are relevant. E.g., we generate an api-model for an api that has 5 parameters, for that I would with the current model need to state Whereas with the POJO approach above we would only do This also makes it so that if the api adds new parameters then we are not forced to act on them (e.g., they add a sixth optional parameter, and I have to change the code from Instead we do nothing with the POJO approach, and only if we want to sent that too then we change it to Is this a usecase that makes sense? Or is there some other common way to realize a "null-empty", "parameter-resilient" approach? And if it is a suitable feature, how would one go about introducing it to restclient, where it seems that they have locked the implementation to using a record? |
...es/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
Outdated
Show resolved
Hide resolved
modules/openapi-generator/src/main/resources/Java/libraries/webclient/api.mustache
Outdated
Show resolved
Hide resolved
In my opinion, yes.
Lombok's
Please create a separate issue and PR. Thanks! |
1f30b5f
to
7d9d52c
Compare
Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com>
7d9d52c
to
bd2c149
Compare
When generating Java clients with the option
useSingleRequestParameter
set totrue
, there is a inner class generated that is not set as static.Add a new value to be accepted for the
useSingleRequestParameter
:true
(existent)false
(existent)static
(new)To generate an inner static class.
When
useSingleRequestParameter=true
:When
useSingleRequestParameter=static
:@martin-mfg @Zomzog @lwlee2608
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.0
minor release - breaking changes with fallbacks),8.0.x
(breaking changes without fallbacks)