Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/322.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Java 如何避免类标记被方法标记覆盖?_Java_Swagger - Fatal编程技术网

Java 如何避免类标记被方法标记覆盖?

Java 如何避免类标记被方法标记覆盖?,java,swagger,Java,Swagger,使用Swagger 1.5.24并遵循以下步骤,我以这种方式编写了一个Swagger: @Path("/path1") @Api(value = "Class for some requests", tags = {"Requests of type 1", "path1"}) public class Requests1 { @GET @Path("/request1") @ApiOperation(value = "Request 1 standard retrie

使用Swagger 1.5.24并遵循以下步骤,我以这种方式编写了一个Swagger:

@Path("/path1")
@Api(value = "Class for some requests", tags = {"Requests of type 1", "path1"})
public class Requests1 {

    @GET
    @Path("/request1")
    @ApiOperation(value = "Request 1 standard retriever", tags = {"standard", "version 1.0"})
    public Response getRequest1(..) { ... }

    @GET
    @Path("/request1/specific")
    @ApiOperation(value = "Request 1 specific retriever", tags = {"specific", "version 1.1"})
    public Response getRequest1specific(..) { ... }

    @POST
    @Path("/request1")
    @ApiOperation(value = "Request 1 standard inserter", tags = {"standard", "version 1.0"})
    public Response insertRequest1(..) { ... }

    @POST
    @Path("/request1/specific")
    @ApiOperation(value = "Request 1 specific inserter", tags = {"specific", "version 1.0"})
    public Response insertRequest1specific(..) { ... }

}
我想要获得的是在类型1和path1的标记下列出类的所有方法,并在标记下列出标准、1.0版、特定的或1.1版指定了tose标记的方法

例如:

@Path("/path1")
@Api(value = "Class for some requests")
public class Requests1 {

    @GET
    @Path("/request1")
    @ApiOperation(value = "Request 1 standard retriever", tags = {"Requests of type 1", "path1", "standard", "version 1.0"})
    public Response getRequest1(..) { ... }
类型1的请求

  • 请求1标准检索器
  • 请求1个特定的检索器
  • 请求1标准插入器
  • 请求1个特定插入器
版本1.1

  • 请求1个特定的检索器
  • 请求2标准插入器
  • 请求5
。。。等等

问题在于,为方法设置标记会覆盖类的标记,从而导致类型1和path1请求出现空列表

我尝试在@ApiOperation属性中使用@Tag属性,但它显示以下错误:

注释属性ApiOperation.tags的值必须是常量表达式

我可以“避免”为每个方法设置类的标记的问题,但是这样做会降低specifics标记的可读性

例如:

@Path("/path1")
@Api(value = "Class for some requests")
public class Requests1 {

    @GET
    @Path("/request1")
    @ApiOperation(value = "Request 1 standard retriever", tags = {"Requests of type 1", "path1", "standard", "version 1.0"})
    public Response getRequest1(..) { ... }