teamcarma / swagger-jaxrs-doclet

This fork is no longer actively maintained, please switch to https://github.com/conorroche/swagger-doclet
Apache License 2.0
81 stars 38 forks source link

Operations on application root path #131

Closed glucas closed 8 years ago

glucas commented 8 years ago

I'm using the swagger-doclet (along with the swagger-codegen-maven-plugin) to generate documentation from a JAX-RS API.

Resources that have operations at the application root path (with @Path("/") or @Path("")) cause a NullPointerException during codegen. I'm not entirely sure if this is an issue with the doclet or codegen, but the doclet is generating a json spec that has api operations with no corresponding path such as the GET below:

{ "apiVersion" : "1", "swaggerVersion" : "1.2", "basePath" : "http://localhost:8180/ws/test", "resourcePath" : "/root", "apis" : [ { "operations" : [ { "method" : "GET", "nickname" : "getSomething", "type" : "SomeBean", "summary" : "Gets the thing", "produces" : [ "application/json", "application/xml" ] } ] }, { "path" : "/publish", "operations" : [ { "method" : "POST", "nickname" : "publishSomething", "type" : "void", ...

glucas commented 8 years ago

OK - adding a path before running the codegen step prevents the NPE, so I do think this is an issue with the doclet. This variation of the above example works fine:

{ "apiVersion" : "1", "swaggerVersion" : "1.2", "basePath" : "http://localhost:8180/ws/test", "resourcePath" : "/root", "apis" : [ { "path" : "/", "operations" : [ { "method" : "GET", "nickname" : "getSomething", "type" : "SomeBean", "summary" : "Gets the thing", "produces" : [ "application/json", "application/xml" ] } ] }, { "path" : "/publish", "operations" : [ { "method" : "POST", "nickname" : "publishSomething", "type" : "void", ...

glucas commented 8 years ago

I've got things working locally with a small change to ApiMethodParser#parse: just replacing a "" path with "/" works for me. I can submit a pull request.

conorroche commented 8 years ago

@glucas thanks for your help ive merged this in now