在 Firebase Cloud Functions 项目中生成 Swagger 文档文档、项目、Cloud、Firebase

2023-09-07 14:18:56 作者:离人醉℡

是否可以从 firebase 云函数中的函数注释生成 Swagger Spec 文件?如果是这样,我们该怎么做?

Is it possible to generate Swagger Spec file from function comments in firebase cloud functions? If so, how can we do it?

我看到云功能代码更像无服务器,所以想知道这是否可能.

I see the cloud functions code to be more like serverless, so wondering if this is possible.

推荐答案

我还没有找到自动的方法,但是有很多库可供选择.

I haven't found an automatic way, but there are plenty of libraries to choose from.

我在我的 Firebase 函数实现中使用 express 和 nodejs,对我来说,Swagger 文档生成可以通过以下库实现:https://github.com/scottie1984/swagger-ui-expresshttps://github.com/Surnet/swagger-jsdoc

I'm using express and nodejs in my Firebase Function implementations, and for me, Swagger doc generation can be implemented via the following libraries: https://github.com/scottie1984/swagger-ui-express https://github.com/Surnet/swagger-jsdoc

您可以在以下位置找到其他库:https://swagger.io/tools/open-source/open-source-整合/

You can find other libraries at: https://swagger.io/tools/open-source/open-source-integrations/

这将创建一个新的 HTTP 端点,它将提供一个 swagger 文档的 HTML 页面.

This will create a new HTTP endpoint, which will serve an HTML page of a swagger doc.