有没有办法发现ReST API的所有端点? [英] Is there a way to discover all endpoints of a ReST API?

查看:197
本文介绍了有没有办法发现ReST API的所有端点?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想知道是否可能以编程方式发现特定API的所有端点。

I'm wondering if its possible to programmatically discover all the endpoints of a particular API.

所以例如,如果我使用浏览器或卷曲获取此URL:
https://api.twitter.com/1.1/

So for example if I GET this URL with a browser or curl: https://api.twitter.com/1.1/

我可能会收到像这样的JSON响应: / p>

I might get something like this as a JSON response:

{"TwitterAPI":{
    "version" : 1.1,
    "GET" : {
        "search/" : ["users", "trending"],
        "users/" : ["id", "handle"]
    }
}

当然,Twitter可以选择发布或不发布此格式。所以作为一个侧面的问题,是否有任何用于Java或Javascript的库将自动映射和发布您在控制器中创建的API路由?

Of course Twitter could choose to publish or not publish this format. So as a side question, are there any libraries for Java or Javascript that will automatically map and publish the API routes you created in your controllers?

推荐答案


没有办法以编程方式发现REST服务,因为
没有一个标准的注册表服务。

There is no way of programmatically discovering REST services as they do not have a standard registry service.

除了做一些疯狂的强力搜索,没有办法找到正确的URL(更不用说正确的参数)。所以唯一的选择是记录你的API。为此,我看到的最好的选择是:

Apart from doing something insane brute-force search there is no way of finding the right URLs ( not to mention the right parameters). So the only option is documenting your API. For that the best choice I have seen so far is:

  • Swagger
  • And people also like API Blueprint.

这篇关于有没有办法发现ReST API的所有端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆