对于我的第一个API文档(非常简单的API,只有一个方法),我或多或少有这样的结构:
API documentation
1.Disclaimer
2. Using the API
2.1 Input data -> Here I explain how should be the input data, JSON
2.2 Output data > Here I explain which data should be obtained and in JSON
2.3 Example -> I am giving an example of my input and output
在2.3中,我解释了输出(在我的文档中的实际示例中,我只在这里发布了它的外观结构)应该如下所示:
{"message":"Succesful ","data":{"batt1":{"value1":977.48279000017,"value2":977.4208279000022,"value3":1034.9372639500002,"value4":2534.854048049996,"value5":2465.145176450681,"value6":2465.1451764508347},"batt2":{}...}
但是,如何将请求放在这个例子中,这是我想要的。到目前为止,我一直使用/测试我的API命令:curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '@alldata.json' http://localhost:3000/api/v1/namecontroller
我是否应该把我的文档放在2.3中,比如:
在本例中,我以以下形式使用了cURL命令:curl -i -H "Accept: application/json" -H "Content-type: application/json" -X POST -d '@alldata.json' http://localhost:3000/api/v1/namecontroller
对不起,我对这一切都很陌生,RoR,API等等。
你有什么想法吗?
发布于 2015-05-28 13:36:01
我想你可以用下面的格式显示,这样就很容易理解了。
url: http://localhost:3000/api/v1/namecontroller
method: POST
Body : @alldata.json
https://stackoverflow.com/questions/30507573
复制相似问题