如何记录基于 Symfony 的 REST API(类似于阐明文档功能)
如果我有一个用 Symfony [symfony-project.org] 框架(即 PHP)编写的基于 REST 的服务,是否有任何合适的工具/框架可以解析我的代码并生成 API 文档?
基于 Java 的框架 enunciate 具有与我需要的类似的文档功能,您可以在此处查看示例: http://enunciate.codehaus.org/wannabecool/step1/index.html。
我知道基于 REST 的服务的前提应该是不言而喻的,但是我想要的是能够为我生成此文档的东西,而无需手动编写我的所有端点、支持的格式、示例输出等。
谢谢
If I have a REST based service written in the Symfony [symfony-project.org] framework (i.e. PHP), is there any decent tools/frameworks out there that will parse my code and generate API documentation?
The Java based framework enunciate has documentation capabilities similar to what I need, you can view an example of this here: http://enunciate.codehaus.org/wannabecool/step1/index.html.
I understand the premise of REST based services are supposed to be self evident, however I was after something that would generate this documentation for me without the need to manually write up all my endpoints, supported formats, sample output etc.
Thanks
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
不确定您以前是否见过 Swagger。他们似乎有一个 PHP 兼容版本,尽管我不能真正保证它亲自。它会自动生成一些类似于 enunciate 的 API 文档,尽管它看起来确实需要通过 PHP 注释进行一些繁重的手动文档。话虽这么说,我认为手动工作将与通过 wiki 页面自己制作相同或更少,而且输出要好得多。
正如事实一样,Enunciate 有无限期的计划最终< /em> 支持其他平台,但相关 Jira 票证目前开放等待发起人承担工作。
从 ENUNCIATE-356 Jira 票证:
编辑:
发现一个类似问题,其中有人提到一个 专门用于 Swagger+ 的 GitHub 项目Symfony2。 这个其他问题是相同的,但没有额外的信息。
Not sure if you've seen Swagger before. They seem to have a PHP compatible version, though I can't really vouch for it personally. It does some automatic API documentation generation comparable to enunciate, though it does look like it requires some heavy manual documentation via PHP comments. That being said, I think the manual effort will be the same or less than making your own via wiki pages, and the output is much, much nicer.
Just as a factoid, it looks like Enunciate has indefinite plans to eventually support other platforms, but the relevant Jira ticket is currently Open waiting for a sponsor to take on the work.
From the ENUNCIATE-356 Jira ticket:
Edit:
Found a similar question where someone mentions a GitHub project dedicated to Swagger+Symfony2. This other question is the same, but no additional information.
据我所知,没有办法自动记录媒体类型。
如果您使用的是 XHTML 等媒体类型,则 Google 站点地图 等网络爬虫可能会产生一些有用的输出显示资源之间的关系。
To my knowledge there is no way to automate the documentation of media types.
If you are using a media type like XHTML then a web crawler like Google sitemap may produce some useful output to show the relations between your resources.