@@ -90,6 +90,7 @@ public class SpringCodegen extends AbstractJavaCodegen
9090 public static final String RETURN_SUCCESS_CODE = "returnSuccessCode" ;
9191 public static final String UNHANDLED_EXCEPTION_HANDLING = "unhandledException" ;
9292 public static final String USE_RESPONSE_ENTITY = "useResponseEntity" ;
93+ public static final String GENERATE_GENERIC_RESPONSE_ENTITY = "generateGenericResponseEntity" ;
9394 public static final String USE_ENUM_CASE_INSENSITIVE = "useEnumCaseInsensitive" ;
9495 public static final String USE_SPRING_BOOT3 = "useSpringBoot3" ;
9596 public static final String REQUEST_MAPPING_OPTION = "requestMappingMode" ;
@@ -147,6 +148,7 @@ public enum RequestMappingMode {
147148 @ Setter protected boolean useSpringController = false ;
148149 protected boolean useSwaggerUI = true ;
149150 @ Setter protected boolean useResponseEntity = true ;
151+ @ Setter protected boolean generateGenericResponseEntity = false ;
150152 @ Setter protected boolean useEnumCaseInsensitive = false ;
151153 @ Getter @ Setter
152154 protected boolean useSpringBoot3 = false ;
@@ -256,6 +258,10 @@ public SpringCodegen() {
256258 "Use the `ResponseEntity` type to wrap return values of generated API methods. "
257259 + "If disabled, method are annotated using a `@ResponseStatus` annotation, which has the status of the first response declared in the Api definition" ,
258260 useResponseEntity ));
261+ cliOptions .add (CliOption .newBoolean (GENERATE_GENERIC_RESPONSE_ENTITY ,
262+ "Use a generic type for the `ResponseEntity` wrapping return values of generated API methods. "
263+ + "If enabled, method are generated with return type ResponseEntity<?>" ,
264+ generateGenericResponseEntity ));
259265 cliOptions .add (CliOption .newBoolean (USE_ENUM_CASE_INSENSITIVE ,
260266 "Use `equalsIgnoreCase` when String for enum comparison" ,
261267 useEnumCaseInsensitive ));
@@ -433,6 +439,11 @@ public void processOpts() {
433439
434440 convertPropertyToBooleanAndWriteBack (UNHANDLED_EXCEPTION_HANDLING , this ::setUnhandledException );
435441 convertPropertyToBooleanAndWriteBack (USE_RESPONSE_ENTITY , this ::setUseResponseEntity );
442+ convertPropertyToBooleanAndWriteBack (GENERATE_GENERIC_RESPONSE_ENTITY , this ::setGenerateGenericResponseEntity );
443+ if (!useResponseEntity ) {
444+ this .setGenerateGenericResponseEntity (false );
445+ this .additionalProperties .put (GENERATE_GENERIC_RESPONSE_ENTITY , false );
446+ }
436447 convertPropertyToBooleanAndWriteBack (OPTIONAL_ACCEPT_NULLABLE , this ::setOptionalAcceptNullable );
437448 convertPropertyToBooleanAndWriteBack (USE_SPRING_BUILT_IN_VALIDATION , this ::setUseSpringBuiltInValidation );
438449
0 commit comments