[英]Exclude methods of jax-rs service from swagger.json
I´m using swagger on my java EE7 application (Glassfish as application server). 我在Java EE7应用程序(Glassfish作为应用程序服务器)上使用了swagger。 Everything works fine except for a method with FormDataParam, which gave me the tradicional error: 除了使用FormDataParam的方法,其他一切都正常,这给了我传统的错误:
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 我尝试了所有方法,但这只是一个方法,所以我不想在我的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. 与Glassfish有关,它使用了不同版本的Jackson。 You need to upgrade Glassfish/Jackson. 您需要升级Glassfish / Jackson。 More details: 更多细节:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer
solution https://github.com/swagger-api/swagger-core/issues/1001 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer
solution https://github.com/swagger-api/swagger -核心/问题/ 1001 java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
solution - https://groups.google.com/forum/#!topic/swagger-swaggersocket/uQEn-anX_Og 解决方案-https://groups.google.com/forum/#!topic/swagger - swaggersocket/uQEn - anX_Og java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyDesc
solution https://groups.google.com/forum/#!topic/swagger-swaggersocket/x-Pz_3orTCE java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyDesc
解决方案https://groups.google.com/forum/#!topic/swagger-swaggersocket/x-Pz_3orTCE For me adding @ApiModelProperty(hidden = true) in paths worked Is it wrong or correct? 对我来说,在可用的路径中添加@ApiModelProperty(hidden = true)是错误还是正确的?
@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..
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.