Skip to content

Commit 78f8413

Browse files
committed
Fixed #1189: @path("") and @path("/") produce an empty path
1 parent 0a9664f commit 78f8413

File tree

3 files changed

+24
-1
lines changed

3 files changed

+24
-1
lines changed

modules/swagger-jaxrs/src/main/java/io/swagger/jaxrs/Reader.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -274,7 +274,7 @@ protected Swagger read(Class<?> cls, String parentPath, String parentMethod, boo
274274
pathBuilder.append("/").append(p);
275275
}
276276
}
277-
operationPath = pathBuilder.toString();
277+
operationPath = pathBuilder.length() > 0 ? pathBuilder.toString() : PATH_DELIMITER;
278278

279279
if (isIgnored(operationPath)) {
280280
continue;

modules/swagger-jaxrs/src/test/scala/ReaderTest.scala

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -188,4 +188,12 @@ class ReaderTest extends FlatSpec with Matchers {
188188
swagger.getPaths().get("/testDeprecated").getGet().isDeprecated() should equal(true)
189189
swagger.getPaths().get("/testAllowed").getGet.isDeprecated() should be(null)
190190
}
191+
192+
it should "scan empty path annotation" in {
193+
val reader = new Reader(new Swagger())
194+
val swagger = reader.read(classOf[ResourceWithEmptyPath])
195+
196+
swagger.getPaths().get("/").getGet() should not be(null)
197+
198+
}
191199
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
package resources;
2+
3+
import io.swagger.annotations.Api;
4+
5+
import javax.ws.rs.GET;
6+
import javax.ws.rs.Path;
7+
8+
@Path("")
9+
@Api
10+
public class ResourceWithEmptyPath {
11+
12+
@GET
13+
public void getTest() {
14+
}
15+
}

0 commit comments

Comments
 (0)