Repository: swagger-api/swagger-core
Issue: swagger-servlet generating non-unique operationIds

using swagger-servlet-1.5.4.

first of all, @iushankin huuuge thanks for swagger-servlet migration with 1.5.4! works almost flawlessly.

i noticed that swagger-servlet will use `@ApiOperation`s `nickname` attribute for path generation as well as for `operationId`.
however, it may be necessary to have multiple operations with the same path (but different http methods).
in this case, the `nickname` is correctly used multiple times as path for different operations but also as `operationId` which means the `operationId` is no longer unique.

as a result, swagger editor - for example - shows errors:

> Cannot have multiple operations with the same operationId: /myPath

thanks, zyro


Changed files:
modules/swagger-servlet/src/main/java/io/swagger/servlet/extensions/ServletReaderExtension.java
modules/swagger-servlet/src/test/java/io/swagger/servlet/extensions/PathGetterTest.java
modules/swagger-servlet/src/test/java/io/swagger/servlet/ReaderTest.java

diff --git a/modules/swagger-servlet/src/main/java/io/swagger/servlet/extensions/ServletReaderExtension.java b/modules/swagger-servlet/src/main/java/io/swagger/servlet/extensions/ServletReaderExtension.java
index 5345b1a9f..5eaae4195 100644
--- a/modules/swagger-servlet/src/main/java/io/swagger/servlet/extensions/ServletReaderExtension.java
+++ b/modules/swagger-servlet/src/main/java/io/swagger/servlet/extensions/ServletReaderExtension.java
@@ -222,7 +222,7 @@ public class ServletReaderExtension implements ReaderExtension {
         final String operationPath = apiOperation == null ? null : apiOperation.nickname();
         return PathUtils.collectPath(context.getParentPath(),
                 apiAnnotation == null ? null : apiAnnotation.value(),
-                StringUtils.defaultIfBlank(operationPath, method.getName()));
+                method.getName());
     }
 
     @Override
diff --git a/modules/swagger-servlet/src/test/java/io/swagger/servlet/ReaderTest.java b/modules/swagger-servlet/src/test/java/io/swagger/servlet/ReaderTest.java
index a48d65190..a36bacfe1 100644
--- a/modules/swagger-servlet/src/test/java/io/swagger/servlet/ReaderTest.java
+++ b/modules/swagger-servlet/src/test/java/io/swagger/servlet/ReaderTest.java
@@ -43,12 +43,12 @@ public class ReaderTest {
 
         Assert.assertEquals(swagger.getHost(), "host");
         Assert.assertEquals(swagger.getBasePath(), "/api");
-        Assert.assertNotNull(swagger.getPath("/resources/users"));
+        Assert.assertNotNull(swagger.getPath("/resources/testMethod3"));
         Assert.assertNotNull(swagger.getDefinitions().get("SampleData"));
         Assert.assertEquals(swagger.getExternalDocs().getDescription(), "docs");
         Assert.assertEquals(swagger.getExternalDocs().getUrl(), "url_to_docs");
 
-        Path path = swagger.getPath("/resources/users");
+        Path path = swagger.getPath("/resources/testMethod3");
         Assert.assertNotNull(path);
         Operation get = path.getGet();
         Assert.assertNotNull( get );
diff --git a/modules/swagger-servlet/src/test/java/io/swagger/servlet/extensions/PathGetterTest.java b/modules/swagger-servlet/src/test/java/io/swagger/servlet/extensions/PathGetterTest.java
index 4b643b073..3c1092335 100644
--- a/modules/swagger-servlet/src/test/java/io/swagger/servlet/extensions/PathGetterTest.java
+++ b/modules/swagger-servlet/src/test/java/io/swagger/servlet/extensions/PathGetterTest.java
@@ -13,7 +13,7 @@ public class PathGetterTest extends BaseServletReaderExtensionTest {
         return new Object[][]{
                 {"testMethod1", "/tests/resources/testMethod1"},
                 {"testMethod2", "/tests/resources/testMethod2"},
-                {"testMethod3", "/tests/resources/users"},
+                {"testMethod3", "/tests/resources/testMethod3"},
                 {"testMethod4", "/tests/resources/testMethod4"},
         };
     }
@@ -23,7 +23,7 @@ public class PathGetterTest extends BaseServletReaderExtensionTest {
         return new Object[][]{
                 {"testMethod1", "/tests/testMethod1"},
                 {"testMethod2", "/tests/testMethod2"},
-                {"testMethod3", "/tests/users"},
+                {"testMethod3", "/tests/testMethod3"},
                 {"testMethod4", "/tests/testMethod4"},
         };
     }