OpenAPITools / OpenAPITools/openapi-generator
[REQ][Java][Microprofile] Use WebApplicationException as default API exception
Nobody has claimed this yet.
- Dominant language
- Java
- Stars
- 26.8k
- Forks
- 7.7k
- PR merge metrics
- PR metrics pending
Description
Is your feature request related to a problem? Please describe.
Currently each Api generates a custom ApiException and its accompanying ApiExceptionMapper implementation although the JavaEE/JakartaEE would define the WebApplicationException as the matching exception in this case making those two classes obsolete in the default configuration.
In our usecase we run into problems when using more than one generated OpenAPI definition as the two separate interfaces create their own ApiException and ApiExceptionMapper where as the mapper implementation can not distinguish between each other by only taking the HTTP response code into account and therefore allways the first one found will win and the resulting ApiException is wrong for the second one.
Describe the solution you'd like
I would propose:
- using
WebApplicationExceptionwithin the API interface in favor of generating a customApiExceptionandApiExceptionMapperimplementations. - drop
microprofileGlobalExceptionMapperandmicroprofileRegisterExceptionMapperoptions all together
Describe alternatives you've considered
Disabling the use of ApiExceptionMapper by setting microprofileGlobalExceptionMapper and microprofileRegisterExceptionMapper to false. Those will relax the wrong type creation for now. The downside is that the both classes are superflows.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by reviewing the generated API interface and the ApiException and ApiExceptionMapper generation paths, then trace how microprofileGlobalExceptionMapper and microprofileRegisterExceptionMapper affect them. Done means the default generated API uses WebApplicationException, the custom exception and mapper are no longer generated by default, and the related options are removed or accounted for.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- java
- Domain
- api, tooling
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100