22

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.

Ayyappa
  • 1,876
  • 1
  • 21
  • 41
  • Everyone is upvoting but don't have an answer :( – Ayyappa Apr 11 '18 at 15:12
  • Hey I've tried to do this recently. Its challenging but possible. Although I've done a lot of work to make it possible but still there are problems in terms of UI in production. – Shaggie May 15 '20 at 14:17
  • I finally ended up the other way around and its seems more helpful in the longterm. I created the spec and used it for generating the code which helps in creating lot of boiler plate code when ever there is a need for new functionality. Also the code is more consistent and I only need to write services(business logic part alone). Rest (controllers, routing, repositories, etc...) everything is handled automatically by code generator! – Ayyappa May 16 '20 at 06:13

2 Answers2

4

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

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

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

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

Tim Kofoed
  • 61
  • 6
2

There is not an automatic way to do this at this time. I think you could build your own but seems like it would be a lot of work.

Jonathan
  • 1,725
  • 3
  • 19
  • 45