@@ -1044,6 +1044,49 @@ public void generateSpecInterfaceWithJBossResponse() throws Exception {
10441044 "<artifactId>resteasy-reactive</artifactId>" );
10451045 }
10461046
1047+ @ Test
1048+ public void generateSpecInterfaceWithSwaggerV3Annotations () throws Exception {
1049+ final File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
1050+ output .deleteOnExit ();
1051+
1052+ final OpenAPI openAPI = new OpenAPIParser ()
1053+ .readLocation ("src/test/resources/3_0/petstore.yaml" , null , new ParseOptions ()).getOpenAPI ();
1054+
1055+ codegen .setOutputDir (output .getAbsolutePath ());
1056+ codegen .additionalProperties ().put (INTERFACE_ONLY , true ); // only interfaces
1057+ codegen .additionalProperties ().put (USE_TAGS , true ); // split by tags
1058+ codegen .additionalProperties ().put (USE_SWAGGER_V3_ANNOTATIONS , true ); // enable Swagger v3 annotations
1059+ // keep default library (spec), do NOT enable MicroProfile
1060+
1061+ final ClientOptInput input = new ClientOptInput ()
1062+ .openAPI (openAPI )
1063+ .config (codegen );
1064+
1065+ final DefaultGenerator generator = new DefaultGenerator ();
1066+ final List <File > files = generator .opts (input ).generate ();
1067+
1068+ // Then the java files are compilable
1069+ validateJavaSourceFiles (files );
1070+
1071+ // And the generated interfaces contain Swagger v3 annotations and imports
1072+ TestUtils .ensureContainsFile (files , output , "src/gen/java/org/openapitools/api/PetApi.java" );
1073+ assertFileContains (output .toPath ().resolve ("src/gen/java/org/openapitools/api/PetApi.java" ),
1074+ "import io.swagger.v3.oas.annotations.*;" ,
1075+ "import io.swagger.v3.oas.annotations.media.*;" ,
1076+ "import io.swagger.v3.oas.annotations.responses.*;" ,
1077+ "import io.swagger.v3.oas.annotations.tags.Tag;" ,
1078+ "@Tag(name = \" Pet\" )" );
1079+ // Ensure MicroProfile annotations are NOT present
1080+ TestUtils .assertFileNotContains (output .toPath ().resolve ("src/gen/java/org/openapitools/api/PetApi.java" ),
1081+ "org.eclipse.microprofile.openapi.annotations.OpenAPIDefinition" );
1082+
1083+ // And pom declares io.swagger.core.v3 swagger-annotations dependency and property
1084+ assertFileContains (output .toPath ().resolve ("pom.xml" ),
1085+ "<groupId>io.swagger.core.v3</groupId>" ,
1086+ "<artifactId>swagger-annotations</artifactId>" ,
1087+ "<io.swagger.v3.annotations.version>" );
1088+ }
1089+
10471090 @ Test
10481091 public void generateSpecInterfaceWithMutinyAndJBossResponse () throws Exception {
10491092 final File output = Files .createTempDirectory ("test" ).toFile ().getCanonicalFile ();
0 commit comments