Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

swagger includeApplicationPath="true" results in no methods #1060

Closed
sortel64 opened this issue Oct 9, 2020 · 10 comments
Closed

swagger includeApplicationPath="true" results in no methods #1060

sortel64 opened this issue Oct 9, 2020 · 10 comments
Labels
Milestone

Comments

@sortel64
Copy link

sortel64 commented Oct 9, 2020

Related to #1004
Sorry it has taken me so long to give this a go but I'm sure you understand. Man, we are so close on this!

Adding includeApplicationPath="true" on the 'docs' module works well! However, when I added it to the swagger module, it results in no methods under the endpoint. I don't see any issues during the maven build.

I included my enunciate.xml and two screen snapshots, one with 'false' and the other with 'true'. I hope that helps. I can also provide you with a short Java example if that helps as well.

Thanks again for working this. It is so helpful!

includeApplicationPath-false
includeApplicationPath-true

enunciate.xml.txt

@sortel64
Copy link
Author

sortel64 commented Oct 9, 2020

This is v2.13.2

@sortel64
Copy link
Author

sortel64 commented Oct 9, 2020

In the swagger.json file, it looks like all of the paths are correct in that they are prefixed with the application path, but are empty.

@stoicflame stoicflame added the bug label Oct 9, 2020
@stoicflame stoicflame added this to the 2.14.0 milestone Oct 9, 2020
@sortel64
Copy link
Author

I did some debugging this weekend and I believe that I have found the issue. I have included a git diff (below) of a proposed fix that I believe matches your coding pattern. I tested it with both 'includeApplicationPath' set to true and false. I hope this helps.

diff --git a/swagger/src/main/java/com/webcohesion/enunciate/modules/swagger/SwaggerModule.java b/swagger/src/main/java/com/webcohesion/enunciate/modules/swagger/SwaggerModule.java
index 1626bfede..00494d7d1 100644
--- a/swagger/src/main/java/com/webcohesion/enunciate/modules/swagger/SwaggerModule.java
+++ b/swagger/src/main/java/com/webcohesion/enunciate/modules/swagger/SwaggerModule.java
@@ -200,7 +200,11 @@ public class SwaggerModule extends BasicGeneratingModule implements ApiFeaturePr
             }
 
             for (Resource resource : resourceGroup.getResources()) {
-              if (path.equals(resource.getPath())) {
+              String resourcePath = resource.getPath();
+              if (includeApplicationPath && !StringUtils.isEmpty(resourcePath)) {
+                resourcePath = "/" + resourceGroup.getRelativeContextPath() + resourcePath;
+              }
+              if (path.equals(resourcePath)) {
                 swaggerResource.getMethods().addAll(resource.getMethods());
               }
             }

BTW: The documentation for both the docs and swagger modules incorrectly call the configuration parameter 'includeApplicationRoot' instead of 'includeApplicationPath'.

@stoicflame
Copy link
Owner

Thanks for the look.

That patch seems to be based off an old version. Can you confirm you're looking at the latest?

@sortel64
Copy link
Author

sortel64 commented Oct 22, 2020 via email

@stoicflame
Copy link
Owner

Applied at 9b62151.

@sortel64
Copy link
Author

sortel64 commented Mar 5, 2021

Hi Ryan, Do you have a projected release date for 2.14 yet?

@stoicflame
Copy link
Owner

I'll try to get something cut within the next two weeks or so.

@stoicflame
Copy link
Owner

2.13.3 is now available.

@sortel64
Copy link
Author

sortel64 commented Mar 10, 2021 via email

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants