简体   繁体   中英

Exclude methods of jax-rs service from swagger.json

I´m using swagger on my java EE7 application (Glassfish as application server). Everything works fine except for a method with FormDataParam, which gave me the tradicional error:

org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;

I tried everything, but is just a method, so I do not want so badly this method in my swagger.json

How can I exclude this method from swagger. I tried:

@ApiModelProperty(hidden = true) and @ApiOperation(value="",hidden = true)
@POST
@Path("something")
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public Response newsomething(@FormParam("something") String something,@Context HttpServletRequest request, @Context HttpServletResponse response) throws IOException {
    return "something";
}

What I´m doing wrong?

It's related with Glassfish, it use different version of Jackson. You need to upgrade Glassfish/Jackson. More details:

For me adding @ApiModelProperty(hidden = true) in paths worked Is it wrong or correct?

@ApiModelProperty(hidden = true)
@GET
@Produces({MediaType.APPLICATION_JSON})
@ApiOperation(value = "return getApi ",
        tags = {"getApi"},
        notes = "Returns a Array of getApi",
        hidden = true
        )
@ApiResponses(value = {
        @ApiResponse(response = GetApi.class, message = "", code = 200)
})
@Path("getApi")
public Response getApi(@Context HttpHeaders httpHeaders, @BeanParam QueryParamBean queryParamBean) {
             // codes..
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM