Hi Jon,
I never heard of Swagger until today so I took a look... The idea
is great, the implementation is atrocious.
@Path("/pet.json")
@Api(value = "/pet", description = "Operations about pets")
@Produces({"application/json"})
public class PetResource extends JavaHelp {
@GET
@Path("/{petId}")
@ApiOperation(value = "Find pet by ID", notes = "Add extra notes here", responseClass = "com.wordnik.swagger.sample.model.Pet")
@ApiErrors(value = { @ApiError(code = 400, reason = "Invalid ID supplied"),
@ApiError(code = 404, reason = "Pet not found") })
public Response getPetById (
@ApiParam(value = "ID of pet that needs to be fetched", allowableValues = "range[1,5]", required = true) @PathParam("petId") String petId)
throws NotFoundException
Really?! This renders one's code completely unreadable. It gives me
new appreciation for the way Javadoc was implemented (done right, unlike
this).
Gili
On 18/10/2012 5:56 PM, Jon Archer wrote:
> Scored an answer on SO for anyone interested:
> http://stackoverflow.com/questions/12960479/bootstrapping-jersey-with-a-filter-causes-swagger-to-fail
>
> On Thu, Oct 18, 2012 at 1:06 PM, <jon_at_rollinsville.org
> <mailto:jon_at_rollinsville.org>> wrote:
>
> I'm trying to use swagger with Jersey and notice that when I configure
> Jersey as a servlet everything works fine.
>
> When I change my configuration over such that Jersey is configured
> as a
> filter however I get errors like this:
>
> SEVERE: The following errors and warnings have been detected with
> resource and/or provider classes:
> SEVERE: Missing dependency for method public
> javax.ws.rs.core.Response
> com.wordnik.swagger.jaxrs.ApiListingResourceJSON.getAllApis(javax.servl
> et.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.cor
> e.HttpHeaders,javax.ws.rs.core.UriInfo) at parameter at index 0
> SEVERE: Method, public javax.ws.rs.core.Response
> com.wordnik.swagger.jaxrs.ApiListingResourceJSON.getAllApis(javax.servl
> et.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.cor
> e.HttpHeaders,javax.ws.rs.core.UriInfo), annotated with GET of
> resource, class com.wordnik.swagger.jaxrs.ApiListingResourceJSON, is
> not recognized as valid resource method.
> SEVERE: Missing dependency for method public
> javax.ws.rs.core.Response
> com.wordnik.swagger.jaxrs.ApiListingResourceXML.getAllApis(javax.servle
> t.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.core
> .HttpHeaders,javax.ws.rs.core.UriInfo) at parameter at index 0
> SEVERE: Method, public javax.ws.rs.core.Response
> com.wordnik.swagger.jaxrs.ApiListingResourceXML.getAllApis(javax.servle
> t.ServletConfig,com.sun.jersey.api.core.ResourceConfig,javax.ws.rs.core
> .HttpHeaders,javax.ws.rs.core.UriInfo), annotated with GET of
> resource,
> class com.wordnik.swagger.jaxrs.ApiListingResourceXML, is not
> recognized as valid resource method.
> Oct 18, 2012 11:27:30 AM
> com.sun.jersey.spi.spring.container.servlet.SpringServlet initiate
>
> This only happens when my config includes an <init-param> for the
> filter referencing the swagger like so:
>
> <init-param>
>
> <param-name>com.sun.jersey.config.property.packages</param-name>
>
> <param-value>com.jonarcher.rest;com.wordnik.swagger.jaxrs</param-value>
> </init-param>
>
> That same <init-param> works just fine when Jersey is configured as a
> servlet.
>
> Any pointers on what's wrong? Thanks in advance.
>
>