-
-
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][Microprofile] add config options to disable usage of ApiExceptionMapper #20762
base: master
Are you sure you want to change the base?
Conversation
I see that CircleCI is failing. I'm not sure what the error is or how to fix it |
Thanks for the PR but your commit (as shown in the Commits tab) is not linked to your Github account, which means this PR won't count as your contribution in https://github.com/OpenAPITools/openapi-generator/graphs/contributors. Let me know if you need help fixing it. |
for the circleci failure, please ignore it for the time being |
looks like a rebase went wrong as the PR contains commits from others. please submit a new one by cherry-picking commits authored by you. |
On it :) |
It looks to be fixed now |
@wing328 Any update on this? |
@@ -375,6 +381,9 @@ public void processOpts() { | |||
} | |||
convertPropertyToStringAndWriteBack(MICROPROFILE_FRAMEWORK, this::setMicroprofileFramework); | |||
|
|||
additionalProperties.put(MICROPROFILE_GLOBAL_EXCEPTION_MAPPER, microProfileGlobalExceptionMapper); | |||
additionalProperties.put(MICROPROFILE_REGISTER_EXCEPTION_MAPPER, microProfileRegisterExceptionMapper); | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i think you will need to follow how the rest of microprofile options are set:
convertPropertyToBooleanAndWriteBack(MICROPROFILE_MUTINY, this::setMicroprofileMutiny);
convertPropertyToStringAndWriteBack(MICROPROFILE_REST_CLIENT_VERSION, value->microprofileRestClientVersion=value);
as my test shows setting these options to false have no effect in the output
did you test the options locally by setting them to false?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@wing328 Yes, you were right. I changed the code and tested the cli locally.
It works as expected now
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
👍
i'll run some tests later this week and merge if no more question from me or the community
...es/openapi-generator/src/main/java/org/openapitools/codegen/languages/JavaClientCodegen.java
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems removing the @Provider
annotation makes the generated class useless. If you agree, could you please make it so that microprofileGlobalExceptionMapper
controls if this class is generated at all?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Without the @Provider annotation, the mapper does nothing on its own, but you can still register it on RestClients using @RegisterProvider(ApiExceptionMapper.class)
I don't know if that's enough to keep the mapper?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point. Let's keep it then.
…en/languages/JavaClientCodegen.java Co-authored-by: martin-mfg <2026226+martin-mfg@users.noreply.github.com>
This PR fixes issue #20751 made by @Munken
It is made configurable whether generated Microprofile API clients should RegisterProvider ApiExceptionMapper.
It is also made configurable whether ApiExceptionMapper should be annotated with @Provider, making it a global exception mapper.
Both properties default to true in order to make this a non-breaking change.
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)@bbdouglas @sreeshas @jfiala @lukoyanov @cbornet @jeff9finger @karismann @Zomzog @lwlee2608 @martin-mfg