@@ -33,6 +33,7 @@ public class SpringCodegen extends AbstractJavaCodegen
33
33
public static final String SPRING_CLOUD_LIBRARY = "spring-cloud" ;
34
34
public static final String IMPLICIT_HEADERS = "implicitHeaders" ;
35
35
public static final String SWAGGER_DOCKET_CONFIG = "swaggerDocketConfig" ;
36
+ public static final String TARGET_OPENFEIGN = "generateForOpenFeign" ;
36
37
37
38
protected String title = "swagger-petstore" ;
38
39
protected String configPackage = "io.swagger.configuration" ;
@@ -49,6 +50,7 @@ public class SpringCodegen extends AbstractJavaCodegen
49
50
protected boolean implicitHeaders = false ;
50
51
protected boolean swaggerDocketConfig = false ;
51
52
protected boolean useOptional = false ;
53
+ protected boolean openFeign = false ;
52
54
53
55
public SpringCodegen () {
54
56
super ();
@@ -81,6 +83,7 @@ public SpringCodegen() {
81
83
cliOptions .add (CliOption .newBoolean (SWAGGER_DOCKET_CONFIG , "Generate Spring Swagger Docket configuration class." ));
82
84
cliOptions .add (CliOption .newBoolean (USE_OPTIONAL ,
83
85
"Use Optional container for optional parameters" ));
86
+ cliOptions .add (CliOption .newBoolean (TARGET_OPENFEIGN ,"Generate for usage with OpenFeign (instead of feign)" ));
84
87
85
88
supportedLibraries .put (DEFAULT_LIBRARY , "Spring-boot Server application using the SpringFox integration." );
86
89
supportedLibraries .put (SPRING_MVC_LIBRARY , "Spring-MVC Server application using the SpringFox integration." );
@@ -178,7 +181,7 @@ public void processOpts() {
178
181
if (additionalProperties .containsKey (USE_TAGS )) {
179
182
this .setUseTags (Boolean .valueOf (additionalProperties .get (USE_TAGS ).toString ()));
180
183
}
181
-
184
+
182
185
if (additionalProperties .containsKey (USE_BEANVALIDATION )) {
183
186
this .setUseBeanValidation (convertPropertyToBoolean (USE_BEANVALIDATION ));
184
187
}
@@ -187,6 +190,10 @@ public void processOpts() {
187
190
this .setUseOptional (convertPropertyToBoolean (USE_OPTIONAL ));
188
191
}
189
192
193
+ if (additionalProperties .containsKey (TARGET_OPENFEIGN )) {
194
+ this .setOpenFeign (convertPropertyToBoolean (TARGET_OPENFEIGN ));
195
+ }
196
+
190
197
if (useBeanValidation ) {
191
198
writePropertyBack (USE_BEANVALIDATION , useBeanValidation );
192
199
}
@@ -201,7 +208,7 @@ public void processOpts() {
201
208
202
209
typeMapping .put ("file" , "Resource" );
203
210
importMapping .put ("Resource" , "org.springframework.core.io.Resource" );
204
-
211
+
205
212
if (useOptional ) {
206
213
writePropertyBack (USE_OPTIONAL , useOptional );
207
214
}
@@ -280,7 +287,7 @@ public void processOpts() {
280
287
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "JacksonConfiguration.java" ));
281
288
}
282
289
}
283
-
290
+
284
291
if ((!this .delegatePattern && this .java8 ) || this .delegateMethod ) {
285
292
additionalProperties .put ("jdk8-no-delegate" , true );
286
293
}
@@ -301,6 +308,10 @@ public void processOpts() {
301
308
additionalProperties .put (RESPONSE_WRAPPER , "Callable" );
302
309
}
303
310
311
+ if (this .openFeign ){
312
+ additionalProperties .put ("isOpenFeign" , "true" );
313
+ }
314
+
304
315
// Some well-known Spring or Spring-Cloud response wrappers
305
316
switch (this .responseWrapper ) {
306
317
case "Future" :
@@ -673,7 +684,7 @@ public Map<String, Object> postProcessModelsEnum(Map<String, Object> objs) {
673
684
674
685
return objs ;
675
686
}
676
-
687
+
677
688
public void setUseBeanValidation (boolean useBeanValidation ) {
678
689
this .useBeanValidation = useBeanValidation ;
679
690
}
@@ -682,4 +693,8 @@ public void setUseBeanValidation(boolean useBeanValidation) {
682
693
public void setUseOptional (boolean useOptional ) {
683
694
this .useOptional = useOptional ;
684
695
}
696
+
697
+ public void setOpenFeign (boolean openFeign ) {
698
+ this .openFeign = openFeign ;
699
+ }
685
700
}
0 commit comments