GERONIMO-6694 @Patch wrong import
authorRomain Manni-Bucau <rmannibucau@gmail.com>
Tue, 12 Feb 2019 10:46:58 +0000 (11:46 +0100)
committerRomain Manni-Bucau <rmannibucau@gmail.com>
Tue, 12 Feb 2019 10:46:58 +0000 (11:46 +0100)
geronimo-openapi-impl/pom.xml
geronimo-openapi-impl/src/main/java/org/apache/geronimo/microprofile/openapi/impl/processor/AnnotationProcessor.java
geronimo-openapi-impl/src/test/java/org/apache/geronimo/microprofile/openapi/impl/processor/AnnotationProcessorTest.java
pom.xml

index 3d7cbc1..b6baa52 100644 (file)
       <plugin>
         <groupId>org.apache.maven.plugins</groupId>
         <artifactId>maven-surefire-plugin</artifactId>
-        <version>2.22.0</version>
+        <version>3.0.0-M3</version>
         <configuration>
           <trimStackTrace>false</trimStackTrace>
           <dependenciesToScan>
             <dependency>org.eclipse.microprofile.openapi:microprofile-openapi-tck</dependency>
           </dependenciesToScan>
+          <classpathDependencyExcludes>
+            <classpathDependencyExclude>org.apache.geronimo.specs:geronimo-jaxrs_2.0_spec</classpathDependencyExclude>
+          </classpathDependencyExcludes>
         </configuration>
       </plugin>
       <plugin>
index 34585c8..228e8a5 100644 (file)
@@ -59,7 +59,6 @@ import javax.ws.rs.container.Suspended;
 import javax.ws.rs.core.Context;
 import javax.ws.rs.core.Response;
 
-import org.apache.cxf.jaxrs.ext.PATCH;
 import org.apache.geronimo.microprofile.openapi.config.GeronimoOpenAPIConfig;
 import org.apache.geronimo.microprofile.openapi.impl.model.APIResponseImpl;
 import org.apache.geronimo.microprofile.openapi.impl.model.APIResponsesImpl;
@@ -176,8 +175,6 @@ public class AnnotationProcessor {
                         getPathItem(api, completePath).setHEAD(buildOperation(api, m, annotatedType, "HEAD", completePath));
                     } else if (m.isAnnotationPresent(OPTIONS.class)) {
                         getPathItem(api, completePath).setOPTIONS(buildOperation(api, m, annotatedType, "OPTIONS", completePath));
-                    } else if (m.isAnnotationPresent(PATCH.class)) {
-                        getPathItem(api, completePath).setPATCH(buildOperation(api, m, annotatedType, "PATCH", completePath));
                     } else if (m.isAnnotationPresent(DELETE.class)) {
                         getPathItem(api, completePath).setDELETE(buildOperation(api, m, annotatedType, "DELETE", completePath));
                     } else {
@@ -186,7 +183,9 @@ public class AnnotationProcessor {
                             final String mtd = http.annotationType().getAnnotation(HttpMethod.class).value();
                             if ("TRACE".equals(mtd)) {
                                 getPathItem(api, completePath).setTRACE(buildOperation(api, m, annotatedType, mtd, completePath));
-                            } // else: how to map it???
+                            } else if ("PATCH".equals(mtd)) {
+                                getPathItem(api, completePath).setPATCH(buildOperation(api, m, annotatedType, mtd, completePath));
+                            } // else: how to map it
                         });
                     }
                 });
index ff09a7d..67fd6ad 100644 (file)
@@ -27,6 +27,7 @@ import org.eclipse.microprofile.openapi.models.parameters.Parameter;
 import org.testng.annotations.Test;
 
 import javax.ws.rs.GET;
+import javax.ws.rs.PATCH;
 import javax.ws.rs.Path;
 import javax.ws.rs.PathParam;
 import javax.ws.rs.Produces;
@@ -81,6 +82,26 @@ public class AnnotationProcessorTest {
         assertNotNull(openAPI.getPaths().get("/{a}").getGET().getOperationId()); // we didn't get an index exception
     }
 
+    @Test
+    public void patch() {
+        final AnnotationProcessor annotationProcessor = new AnnotationProcessor((value, def) -> null, new NamingStrategy.Default());
+        final OpenAPI openAPI = new OpenAPIImpl();
+        annotationProcessor.processClass("", openAPI, new ClassElement(Patched.class),
+                Stream.of(Patched.class.getMethods()).map(MethodElement::new));
+        assertNotNull(openAPI.getPaths().get("/{a}").getPATCH().getOperationId()); // we didn't get an index exception
+    }
+
+    @Path("/")
+    public class Patched {
+
+        @PATCH
+        @Path("/{a}")
+        @Produces(MediaType.TEXT_PLAIN)
+        public String hello(final String foo) {
+            return null;
+        }
+    }
+
     @Path("/")
     public class RootPath {
 
diff --git a/pom.xml b/pom.xml
index 304556e..640f263 100644 (file)
--- a/pom.xml
+++ b/pom.xml
       <dependency>
         <groupId>org.apache.tomcat</groupId>
         <artifactId>tomcat-servlet-api</artifactId>
-        <version>9.0.10</version>
+        <version>9.0.16</version>
         <scope>provided</scope>
       </dependency>
 
       <dependency>
         <groupId>org.apache.cxf</groupId>
         <artifactId>cxf-integration-cdi</artifactId>
-        <version>3.2.7</version>
+        <version>3.3.0</version>
         <scope>provided</scope>
         <optional>true</optional>
         <exclusions>
             <groupId>javax.annotation</groupId>
             <artifactId>javax.annotation-api</artifactId>
           </exclusion>
+          <exclusion>
+            <groupId>jakarta.ws.rs</groupId>
+            <artifactId>jakarta.ws.rs-api</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>jakarta.activation</groupId>
+            <artifactId>jakarta.activation-api</artifactId>
+          </exclusion>
+          <exclusion>
+            <groupId>jakarta.xml.bind</groupId>
+            <artifactId>jakarta.xml.bind-api</artifactId>
+          </exclusion>
         </exclusions>
       </dependency>
       <!-- not that consistent with microprofile so don't enforce it -->
       <dependency>
         <groupId>org.apache.meecrowave</groupId>
         <artifactId>meecrowave-arquillian</artifactId>
-        <version>1.2.5</version>
+        <version>1.2.6</version>
         <scope>test</scope>
         <exclusions>
           <exclusion>