在PHP中自动记录REST API [英] Auto documenting REST API in PHP

查看:126
本文介绍了在PHP中自动记录REST API的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

phpDocumentor似乎是记录PHP代码的标准,尽管我想知道为什么多年来没有对其进行更新.

但是,它似乎不适合记录REST API的入口点; IE,是系统的最终用户感兴趣的,可从外部访问的入口点,而不是记录所有内部类等等,而这仅是api开发人员所感兴趣的.

我正在寻找可以说的东西,嘿,此方法可通过REST在此URL外部访问,这是它需要的GET或POST参数,它支持GET/POST/etc HTTP方法,它返回JSON或XML等等.

此信息将能够产生API文档.代码内部也可以使用它来自动过滤输入,验证输出,创建基本单元测试等.

解决方案

我知道3种与swagger集成的PHP:

所有内容均应有助于自动创建swagger-spec,从而使您可以从swagger-ui进行访问.然后,您可以生成api客户端等.

phpDocumentor seems to be the standard for documenting PHP code, though I have to wonder why it hasn't been updated in years..?

However, it does not seem suitable for documenting the entry points for a REST API; IE, externally accessible entry points that an end user of your system would be interested in, as opposed to documenting all the internal classes and such - something only of interest to the developers of the api.

I am looking for something where I could say, hey this method here is externally accessible through REST at this URL, here's the GET or POST arguments it takes, it supports GET/POST/etc HTTP methods, it returns JSON or XML or whatever.

This information would be able to produce an API document. It could also be used by the code internally to automatically filter inputs, validate output, create basic unit tests, etc.

解决方案

I know of 3 PHP integrations with swagger:

All should help auto-create a swagger-spec, which gives you access from swagger-ui. Then you can generate api clients, etc.

这篇关于在PHP中自动记录REST API的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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