【问题标题】:Exclude methods of jax-rs service from swagger.json从 swagger.json 中排除 jax-rs 服务的方法
【发布时间】:2016-09-01 10:19:11
【问题描述】:

我在我的 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 中使用这种方法

我怎样才能从招摇中排除这种方法。我试过了:

@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";
}

我做错了什么?

【问题讨论】:

    标签: java jackson swagger glassfish-4 nosuchmethoderror


    【解决方案1】:

    它与 Glassfish 有关,它使用不同版本的 Jackson。您需要升级 Glassfish/Jackson。更多详情:

    【讨论】:

    • 在 GlassFish 4.1 中升级 Jackson 是我的解决方案
    【解决方案2】:

    对我来说,在有效路径中添加 @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..
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2014-09-14
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-06
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多