@@ -151,9 +151,6 @@ public String getHelp() {
151
151
152
152
@ Override
153
153
public void processOpts () {
154
- setUseOas2 (true );
155
- additionalProperties .put (CodegenConstants .USE_OAS2 , true );
156
-
157
154
// Process java8 option before common java ones to change the default dateLibrary to java8.
158
155
if (additionalProperties .containsKey (JAVA8_MODE )) {
159
156
this .setJava8 (Boolean .valueOf (additionalProperties .get (JAVA8_MODE ).toString ()));
@@ -296,7 +293,7 @@ public void processOpts() {
296
293
297
294
if (!this .interfaceOnly ) {
298
295
299
- if (library . equals ( DEFAULT_LIBRARY )) {
296
+ if (isDefaultLibrary ( )) {
300
297
apiTestTemplateFiles .clear ();
301
298
supportingFiles .add (new SupportingFile ("homeController.mustache" ,
302
299
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "HomeController.java" ));
@@ -307,7 +304,8 @@ public void processOpts() {
307
304
supportingFiles .add (new SupportingFile ("application.mustache" ,
308
305
("src.main.resources" ).replace ("." , java .io .File .separator ), "application.properties" ));
309
306
}
310
- if (library .equals (SPRING_MVC_LIBRARY )) {
307
+ if (isSpringMvcLibrary ()) {
308
+ forceOas2 ();
311
309
supportingFiles .add (new SupportingFile ("webApplication.mustache" ,
312
310
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "WebApplication.java" ));
313
311
supportingFiles .add (new SupportingFile ("webMvcConfiguration.mustache" ,
@@ -319,7 +317,8 @@ public void processOpts() {
319
317
supportingFiles .add (new SupportingFile ("application.properties" ,
320
318
("src.main.resources" ).replace ("." , java .io .File .separator ), "swagger.properties" ));
321
319
}
322
- if (library .equals (SPRING_CLOUD_LIBRARY )) {
320
+ if (isSpringCloudLibrary ()) {
321
+ forceOas2 ();
323
322
supportingFiles .add (new SupportingFile ("apiKeyRequestInterceptor.mustache" ,
324
323
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "ApiKeyRequestInterceptor.java" ));
325
324
supportingFiles .add (new SupportingFile ("clientConfiguration.mustache" ,
@@ -355,7 +354,7 @@ public void processOpts() {
355
354
supportingFiles .add (new SupportingFile ("swaggerDocumentationConfig.mustache" ,
356
355
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "SwaggerDocumentationConfig.java" ));
357
356
}
358
- } else if ( this .swaggerDocketConfig && !library . equals ( SPRING_CLOUD_LIBRARY )) {
357
+ } else if ( this .swaggerDocketConfig && !isSpringCloudLibrary ( )) {
359
358
supportingFiles .add (new SupportingFile ("swaggerDocumentationConfig.mustache" ,
360
359
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "SwaggerDocumentationConfig.java" ));
361
360
}
@@ -366,7 +365,7 @@ public void processOpts() {
366
365
if ("threetenbp" .equals (dateLibrary )) {
367
366
supportingFiles .add (new SupportingFile ("customInstantDeserializer.mustache" ,
368
367
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "CustomInstantDeserializer.java" ));
369
- if (library . equals ( DEFAULT_LIBRARY ) || library . equals ( SPRING_CLOUD_LIBRARY )) {
368
+ if (isDefaultLibrary ( ) || isSpringCloudLibrary ( )) {
370
369
supportingFiles .add (new SupportingFile ("jacksonConfiguration.mustache" ,
371
370
(sourceFolder + File .separator + configPackage ).replace ("." , java .io .File .separator ), "JacksonConfiguration.java" ));
372
371
}
@@ -441,7 +440,7 @@ public void execute(Template.Fragment fragment, Writer writer) throws IOExceptio
441
440
442
441
@ Override
443
442
public void addOperationToGroup (String tag , String resourcePath , Operation operation , CodegenOperation co , Map <String , List <CodegenOperation >> operations ) {
444
- if ((library . equals ( DEFAULT_LIBRARY ) || library . equals ( SPRING_MVC_LIBRARY )) && !useTags ) {
443
+ if ((isDefaultLibrary ( ) || isSpringMvcLibrary ( )) && !useTags ) {
445
444
String basePath = resourcePath ;
446
445
if (basePath .startsWith ("/" )) {
447
446
basePath = basePath .substring (1 );
@@ -470,7 +469,7 @@ public void addOperationToGroup(String tag, String resourcePath, Operation opera
470
469
471
470
@ Override
472
471
public String getArgumentsLocation () {
473
- return null ;
472
+ return "/arguments/spring.yaml" ;
474
473
}
475
474
476
475
@ Override
@@ -544,6 +543,10 @@ public Map<String, Object> postProcessOperations(Map<String, Object> objs) {
544
543
if ("0" .equals (resp .code )) {
545
544
resp .code = "200" ;
546
545
}
546
+ if (resp .baseType == null ) {
547
+ // set vendorExtensions.x-java-is-response-void to true as baseType is set to "Void"
548
+ resp .vendorExtensions .put ("x-java-is-response-void" , true );
549
+ }
547
550
doDataTypeAssignment (resp .dataType , new DataTypeAssigner () {
548
551
@ Override
549
552
public void setReturnType (final String returnType ) {
@@ -671,9 +674,29 @@ private void removeHeadersFromContents(List<CodegenContent> contents) {
671
674
}
672
675
}
673
676
677
+ /**
678
+ * Forces Oas2 specification, use it when Oas3 is not supported.
679
+ */
680
+ private void forceOas2 () {
681
+ setUseOas2 (true );
682
+ additionalProperties .put (CodegenConstants .USE_OAS2 , true );
683
+ }
684
+
685
+ private boolean isSpringCloudLibrary () {
686
+ return library .equals (SPRING_CLOUD_LIBRARY );
687
+ }
688
+
689
+ private boolean isSpringMvcLibrary () {
690
+ return library .equals (SPRING_MVC_LIBRARY );
691
+ }
692
+
693
+ private boolean isDefaultLibrary () {
694
+ return library .equals (DEFAULT_LIBRARY );
695
+ }
696
+
674
697
@ Override
675
698
public Map <String , Object > postProcessSupportingFileData (Map <String , Object > objs ) {
676
- if ( library . equals ( SPRING_CLOUD_LIBRARY )) {
699
+ if ( isSpringCloudLibrary ( )) {
677
700
List <CodegenSecurity > authMethods = (List <CodegenSecurity >) objs .get ("authMethods" );
678
701
if (authMethods != null ) {
679
702
for (CodegenSecurity authMethod : authMethods ) {
@@ -695,10 +718,10 @@ public String toApiName(String name) {
695
718
696
719
@ Override
697
720
public String toApiTestFilename (String name ) {
698
- if ( library . equals ( SPRING_MVC_LIBRARY )) {
721
+ if ( isSpringMvcLibrary ( )) {
699
722
return toApiName (name ) + "ControllerIT" ;
700
723
}
701
- if ( library . equals ( SPRING_CLOUD_LIBRARY )) {
724
+ if ( isSpringCloudLibrary ( )) {
702
725
return toApiName (name ) + "Test" ;
703
726
}
704
727
return toApiName (name ) + "ControllerIntegrationTest" ;
0 commit comments