You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Add unhandledException to 'spring' generator, which declares all operation methods to throw a generic exception, allowing implementations to unhandle checked exceptions. This is useful whenever it is unnecessary to handle specific exceptions and, more importantly, allow generic constructs (eg. Spring @ControllerAdvice) to tackle unhandled exceptions from a single point (for instance, tackle all unhandled exceptions as an HTTP500 while excluding the stacktrace in the response body). (#2482)
Copy file name to clipboardExpand all lines: docs/generators/spring.md
+1Lines changed: 1 addition & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -61,4 +61,5 @@ sidebar_label: spring
61
61
|useOptional|Use Optional container for optional parameters||false|
62
62
|hateoas|Use Spring HATEOAS library to allow adding HATEOAS links||false|
63
63
|returnSuccessCode|Generated server returns 2xx code||false|
64
+
|unhandledException|Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).|false|
64
65
|library|library template (sub-template)|<dl><dt>**spring-boot**</dt><dd>Spring-boot Server application using the SpringFox integration.</dd><dt>**spring-mvc**</dt><dd>Spring-MVC Server application using the SpringFox integration.</dd><dt>**spring-cloud**</dt><dd>Spring-Cloud-Feign client with Spring-Boot auto-configured settings.</dd><dl>|spring-boot|
@@ -88,6 +89,7 @@ public class SpringCodegen extends AbstractJavaCodegen
88
89
protectedbooleanvirtualService = false;
89
90
protectedbooleanhateoas = false;
90
91
protectedbooleanreturnSuccessCode = false;
92
+
protectedbooleanunhandledException = false;
91
93
92
94
publicSpringCodegen() {
93
95
super();
@@ -130,6 +132,7 @@ public SpringCodegen() {
130
132
cliOptions.add(CliOption.newBoolean(USE_OPTIONAL,"Use Optional container for optional parameters", useOptional));
131
133
cliOptions.add(CliOption.newBoolean(HATEOAS, "Use Spring HATEOAS library to allow adding HATEOAS links", hateoas));
132
134
cliOptions.add(CliOption.newBoolean(RETURN_SUCCESS_CODE, "Generated server returns 2xx code", returnSuccessCode));
135
+
cliOptions.add(CliOption.newBoolean(UNHANDLED_EXCEPTION_HANDLING, "Declare operation methods to throw a generic exception and allow unhandled exceptions (useful for Spring `@ControllerAdvice` directives).", unhandledException));
133
136
134
137
supportedLibraries.put(SPRING_BOOT, "Spring-boot Server application using the SpringFox integration.");
135
138
supportedLibraries.put(SPRING_MVC_LIBRARY, "Spring-MVC Server application using the SpringFox integration.");
0 commit comments