从 swagger.json 中排除 jax-rs 服务的方法
Exclude methods of jax-rs service from swagger.json
我在 java EE7 应用程序(Glassfish 作为应用程序服务器)上使用 swagger。除了带有 FormDataParam 的方法外,一切正常,这给了我传统的错误:
org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
我什么都试过了,但只是一种方法,所以我非常不想要这种方法在我的 swagger.json
如何从 swagger 中排除此方法。我试过了:
@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";
}
我做错了什么?
与Glassfish有关,它使用不同版本的Jackson。您需要升级 Glassfish/Jackson。更多详情:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer
解法https://github.com/swagger-api/swagger-core/issues/1001
- Upgrading Jackson in GlassFish 4.1
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
解决方案-https://groups.google.com/forum/#!topic/swagger-swaggersocket/uQEn-anX_Og
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyDesc
解法https://groups.google.com/forum/#!topic/swagger-swaggersocket/x-Pz_3orTCE
对我来说,在路径中添加 @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..
}
我在 java EE7 应用程序(Glassfish 作为应用程序服务器)上使用 swagger。除了带有 FormDataParam 的方法外,一切正常,这给了我传统的错误:
org.glassfish.jersey.server.ContainerException: java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
我什么都试过了,但只是一种方法,所以我非常不想要这种方法在我的 swagger.json
如何从 swagger 中排除此方法。我试过了:
@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";
}
我做错了什么?
与Glassfish有关,它使用不同版本的Jackson。您需要升级 Glassfish/Jackson。更多详情:
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer
解法https://github.com/swagger-api/swagger-core/issues/1001- Upgrading Jackson in GlassFish 4.1
java.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyIndex(Lcom/fasterxml/jackson/databind/introspect/Annotated;)Ljava/lang/Integer;
解决方案-https://groups.google.com/forum/#!topic/swagger-swaggersocket/uQEn-anX_Ogjava.lang.NoSuchMethodError: com.fasterxml.jackson.databind.AnnotationIntrospector.findPropertyDesc
解法https://groups.google.com/forum/#!topic/swagger-swaggersocket/x-Pz_3orTCE
对我来说,在路径中添加 @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..
}