首页 文章

我们可以在java代码中使用swagger注释值吗?

提问于
浏览
0

我是java的新手 . 尝试开发一个应用程序来安排cron作业中的http api调用 . 只有方法名称才是输入 . 所有api都配置了swagger注释 . 我可以使用这些注释来确定api是发布还是获取或删除等 . 例如

public class ABC {

    @ApiOperation(
          httpMethod = "GET",
          value = "value",
          notes = "notes",
          response = ABC.class)
    ABC getValue()
    {
    }
  }

只有getValue是我的应用程序的输入 . 我可以获取@ApiOperation值来确定http方法类型 .

1 回答

  • 0

    您可以,但它位于 RequestMapping 注释中(您指定应将哪个URL链接到方法的注释):

    例如,当有人在GET中导航到 myBaseURl/persons 时,将调用此方法 . 它将返回JSON .

    @ApiOperation(  value = "List of persons",
                    notes = "List all my base's persons. ",
                    response = Person.class,
                    responseContainer = "List",
                    tags = { "Persons", })
    @RequestMapping(value = "/persons",
                    produces = { "application/json" },
                    method = RequestMethod.GET)
    public PagedResources<PersonResource> persons(...) {}
    

相关问题