如何记录基于 Symfony 的 REST API(类似于阐明文档功能)

发布于 2024-08-31 06:19:38 字数 409 浏览 11 评论 0原文

如果我有一个用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

贱人配狗天长地久 2024-09-07 06:19:38

不确定您以前是否见过 Swagger。他们似乎有一个 PHP 兼容版本,尽管我不能真正保证它亲自。它会自动生成一些类似于 enunciate 的 API 文档,尽管它看起来确实需要通过 PHP 注释进行一些繁重的手动文档。话虽这么说,我认为手动工作将与通过 wiki 页面自己制作相同或更少,而且输出要好得多。

正如事实一样,Enunciate 有无限期的计划最终< /em> 支持其他平台,但相关 Jira 票证目前开放等待发起人承担工作。

ENUNCIATE-356 Jira 票证

支持其他语言的第一步是将 Enunciate 模型与 Java 模型解耦。这项工作正在 ENUNCIATE-584 进行跟踪和记录。不幸的是,由于它太重,它从未退出调查阶段。除非找到这项工作的赞助商,否则我预计不会很快承担这么重的负担。

编辑:
发现一个类似问题,其中有人提到一个 专门用于 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:

The first step to supporting other languages is to decouple the Enunciate model from the Java model. This work is being tracked and logged at ENUNCIATE-584. Unfortunately, it never made it out of the investigate phase because of how heavy it is. Unless a sponsor for the work is found, I don't anticipate taking that heavy load on anytime soon.

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.

初见 2024-09-07 06:19:38

据我所知,没有办法自动记录媒体类型。

如果您使用的是 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文