@@ -3481,6 +3481,64 @@ public void callNativeServiceWithEmptyResponseSync() throws IOException {
3481
3481
);
3482
3482
}
3483
3483
3484
+ @ Test
3485
+ public void annotationLibraryDoesNotCauseImportConflicts () throws IOException {
3486
+ Map <String , Object > properties = new HashMap <>();
3487
+ properties .put ("annotationLibrary" , "none" );
3488
+
3489
+ File output = Files .createTempDirectory ("test" ).toFile ();
3490
+ output .deleteOnExit ();
3491
+
3492
+ final CodegenConfigurator configurator = new CodegenConfigurator ()
3493
+ .setGeneratorName (JAVA_GENERATOR )
3494
+ .setLibrary (JavaClientCodegen .NATIVE )
3495
+ .setAdditionalProperties (properties )
3496
+ .setInputSpec ("src/test/resources/3_0/java/native/issue21991.yaml" )
3497
+ .setOutputDir (output .getAbsolutePath ().replace ("\\ " , "/" ));
3498
+
3499
+ final ClientOptInput clientOptInput = configurator .toClientOptInput ();
3500
+ DefaultGenerator generator = new DefaultGenerator ();
3501
+
3502
+ Map <String , File > files = generator .opts (clientOptInput ).generate ().stream ()
3503
+ .collect (Collectors .toMap (File ::getName , Function .identity ()));
3504
+
3505
+ File apiFile = files .get ("Schema.java" );
3506
+ assertNotNull (apiFile );
3507
+
3508
+ JavaFileAssert .assertThat (apiFile ).fileDoesNotContain (
3509
+ "import io.swagger.v3.oas.annotations.media.Schema;"
3510
+ );
3511
+ }
3512
+
3513
+ @ Test
3514
+ public void annotationLibraryGeneratesCorrectImports () throws IOException {
3515
+ Map <String , Object > properties = new HashMap <>();
3516
+ properties .put ("annotationLibrary" , "swagger2" );
3517
+
3518
+ File output = Files .createTempDirectory ("test" ).toFile ();
3519
+ output .deleteOnExit ();
3520
+
3521
+ final CodegenConfigurator configurator = new CodegenConfigurator ()
3522
+ .setGeneratorName (JAVA_GENERATOR )
3523
+ .setLibrary (JavaClientCodegen .NATIVE )
3524
+ .setAdditionalProperties (properties )
3525
+ .setInputSpec ("src/test/resources/3_0/java/native/issue21991.yaml" )
3526
+ .setOutputDir (output .getAbsolutePath ().replace ("\\ " , "/" ));
3527
+
3528
+ final ClientOptInput clientOptInput = configurator .toClientOptInput ();
3529
+ DefaultGenerator generator = new DefaultGenerator ();
3530
+
3531
+ Map <String , File > files = generator .opts (clientOptInput ).generate ().stream ()
3532
+ .collect (Collectors .toMap (File ::getName , Function .identity ()));
3533
+
3534
+ File apiFile = files .get ("Schema.java" );
3535
+ assertNotNull (apiFile );
3536
+
3537
+ JavaFileAssert .assertThat (apiFile ).fileContains (
3538
+ "import io.swagger.v3.oas.annotations.media.Schema;"
3539
+ );
3540
+ }
3541
+
3484
3542
3485
3543
/**
3486
3544
* This checks that the async client is not affected by this fix.
@@ -3924,4 +3982,4 @@ public void oneOfWithInnerModelTest() {
3924
3982
}
3925
3983
assertTrue (speciesSeen );
3926
3984
}
3927
- }
3985
+ }
0 commit comments