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

问题描述

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

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

所以例如,如果我使用浏览器或卷曲获取此URL:

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?

推荐答案

除了做一些疯狂的强力搜索,没有办法找到正确的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的所有端点?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

05-27 03:59
查看更多