[BUG][Java][Spring] Unhandled exception ignored
Created by: RaduFurnea
Bug Report Checklist
-
Have you provided a full/minimal spec to reproduce the issue? -
Have you validated the input using an OpenAPI validator (example)? -
What's the version of OpenAPI Generator used? -
Have you search for related issues/PRs? -
What's the actual output vs expected output? -
[Optional] Bounty to sponsor the fix (example)
Description
The option to add unhandledException is ignored when skipDefaultInterface is set to true. This behaviour is obvious by inspecting line 132 of the api.mustache.
openapi-generator version
4.3.0
Steps to reproduce
- Generate Spring server code from any specification with unhandledException=true. Observe how the default interface methods have 'throws Exception' declared.
- Generate Spring server code from any specification with unhandledException=true and skipDefaultInterface=true. Observe how the interface methods don't have 'throws Exception' declared.
Related issues/PRs
The PR that added the option. https://github.com/OpenAPITools/openapi-generator/pull/2482
Suggest a fix
I suggest moving the parameter outside of the skipDefaultInterface block so that the 2 options are independent. @jimschubert mentioned on Slack that this could affect people that unknowingly have unhandledException set to true, and skipDefaultInterface set to true also, which is correct to some extent, but having an exception thrown in the interface does not force the implementation to throw it too, so the change is definitely backwards compatible.