@@ -161,9 +161,6 @@ public String getHelp() {
161
161
162
162
@ Override
163
163
public void processOpts () {
164
- setUseOas2 (true );
165
- additionalProperties .put (CodegenConstants .USE_OAS2 , true );
166
-
167
164
// Process java8 option before common java ones to change the default dateLibrary to java8.
168
165
if (additionalProperties .containsKey (JAVA8_MODE )) {
169
166
this .setJava8 (Boolean .valueOf (additionalProperties .get (JAVA8_MODE ).toString ()));
@@ -302,7 +299,7 @@ public void processOpts() {
302
299
303
300
if (!this .interfaceOnly ) {
304
301
305
- if (library . equals ( DEFAULT_LIBRARY )) {
302
+ if (isDefaultLibrary ( )) {
306
303
apiTestTemplateFiles .clear ();
307
304
supportingFiles .add (new SupportingFile ("homeController.mustache" ,
308
305
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "HomeController.java" ));
@@ -313,7 +310,8 @@ public void processOpts() {
313
310
supportingFiles .add (new SupportingFile ("application.mustache" ,
314
311
("src.main.resources" ).replace ("." , java .io .File .separator ), "application.properties" ));
315
312
}
316
- if (library .equals (SPRING_MVC_LIBRARY )) {
313
+ if (isSpringMvcLibrary ()) {
314
+ forceOas2 ();
317
315
supportingFiles .add (new SupportingFile ("webApplication.mustache" ,
318
316
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "WebApplication.java" ));
319
317
supportingFiles .add (new SupportingFile ("webMvcConfiguration.mustache" ,
@@ -325,7 +323,8 @@ public void processOpts() {
325
323
supportingFiles .add (new SupportingFile ("application.properties" ,
326
324
("src.main.resources" ).replace ("." , java .io .File .separator ), "swagger.properties" ));
327
325
}
328
- if (library .equals (SPRING_CLOUD_LIBRARY )) {
326
+ if (isSpringCloudLibrary ()) {
327
+ forceOas2 ();
329
328
supportingFiles .add (new SupportingFile ("apiKeyRequestInterceptor.mustache" ,
330
329
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "ApiKeyRequestInterceptor.java" ));
331
330
supportingFiles .add (new SupportingFile ("clientConfiguration.mustache" ,
@@ -361,7 +360,7 @@ public void processOpts() {
361
360
supportingFiles .add (new SupportingFile ("swaggerDocumentationConfig.mustache" ,
362
361
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "SwaggerDocumentationConfig.java" ));
363
362
}
364
- } else if ( this .swaggerDocketConfig && !library . equals ( SPRING_CLOUD_LIBRARY )) {
363
+ } else if ( this .swaggerDocketConfig && !isSpringCloudLibrary ( )) {
365
364
supportingFiles .add (new SupportingFile ("swaggerDocumentationConfig.mustache" ,
366
365
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "SwaggerDocumentationConfig.java" ));
367
366
}
@@ -372,7 +371,7 @@ public void processOpts() {
372
371
if ("threetenbp" .equals (dateLibrary )) {
373
372
supportingFiles .add (new SupportingFile ("customInstantDeserializer.mustache" ,
374
373
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "CustomInstantDeserializer.java" ));
375
- if (library . equals ( DEFAULT_LIBRARY ) || library . equals ( SPRING_CLOUD_LIBRARY )) {
374
+ if (isDefaultLibrary ( ) || isSpringCloudLibrary ( )) {
376
375
supportingFiles .add (new SupportingFile ("jacksonConfiguration.mustache" ,
377
376
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "JacksonConfiguration.java" ));
378
377
}
@@ -447,7 +446,7 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
447
446
448
447
@ Override
449
448
public void addOperationToGroup (String tag , String resourcePath , Operation operation , CodegenOperation co , Map <String , List <CodegenOperation >> operations ) {
450
- if ((library . equals ( DEFAULT_LIBRARY ) || library . equals ( SPRING_MVC_LIBRARY )) && !useTags ) {
449
+ if ((isDefaultLibrary ( ) || isSpringMvcLibrary ( )) && !useTags ) {
451
450
String basePath = resourcePath ;
452
451
if (basePath .startsWith ("/" )) {
453
452
basePath = basePath .substring (1 );
@@ -476,7 +475,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
476
475
477
476
@ Override
478
477
public String getArgumentsLocation () {
479
- return null ;
478
+ return "/arguments/spring.yaml" ;
480
479
}
481
480
482
481
@ Override
@@ -550,6 +549,10 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
550
549
if ("0" .equals (resp .code )) {
551
550
resp .code = "200" ;
552
551
}
552
+ if (resp .baseType == null ) {
553
+ // set vendorExtensions.x-java-is-response-void to true as baseType is set to "Void"
554
+ resp .vendorExtensions .put ("x-java-is-response-void" , true );
555
+ }
553
556
doDataTypeAssignment (resp .dataType , new DataTypeAssigner () {
554
557
@ Override
555
558
public void setReturnType (final String returnType ) {
@@ -687,9 +690,29 @@ private void removeHeadersFromContents(List<CodegenContent> contents) {
687
690
}
688
691
}
689
692
693
+ /**
694
+ * Forces Oas2 specification, use it when Oas3 is not supported.
695
+ */
696
+ private void forceOas2 () {
697
+ setUseOas2 (true );
698
+ additionalProperties .put (CodegenConstants .USE_OAS2 , true );
699
+ }
700
+
701
+ private boolean isSpringCloudLibrary () {
702
+ return library .equals (SPRING_CLOUD_LIBRARY );
703
+ }
704
+
705
+ private boolean isSpringMvcLibrary () {
706
+ return library .equals (SPRING_MVC_LIBRARY );
707
+ }
708
+
709
+ private boolean isDefaultLibrary () {
710
+ return library .equals (DEFAULT_LIBRARY );
711
+ }
712
+
690
713
@ Override
691
714
public Map <String , Object > postProcessSupportingFileData (Map <String , Object > objs ) {
692
- if ( library . equals ( SPRING_CLOUD_LIBRARY )) {
715
+ if ( isSpringCloudLibrary ( )) {
693
716
List <CodegenSecurity > authMethods = (List <CodegenSecurity >) objs .get ("authMethods" );
694
717
if (authMethods != null ) {
695
718
for (CodegenSecurity authMethod : authMethods ) {
@@ -711,10 +734,10 @@ public String toApiName(String name) {
711
734
712
735
@ Override
713
736
public String toApiTestFilename (String name ) {
714
- if ( library . equals ( SPRING_MVC_LIBRARY )) {
737
+ if ( isSpringMvcLibrary ( )) {
715
738
return toApiName (name ) + "ControllerIT" ;
716
739
}
717
- if ( library . equals ( SPRING_CLOUD_LIBRARY )) {
740
+ if ( isSpringCloudLibrary ( )) {
718
741
return toApiName (name ) + "Test" ;
719
742
}
720
743
return toApiName (name ) + "ControllerIntegrationTest" ;
0 commit comments