docgen
docgen copied to clipboard
Generate API in Swagger format
Swagger/OpenAPI is a very popular format for documenting, and generating clients, for APIs. Has there been any discussions about supporting Swagger generation? I couldn't find any issue for it.
This came out of https://github.com/go-chi/chi/issues/226.
any update from the author about this? it would be a great feature
Authors are open to contributions :)
i understand. i don't know swagger well nor do I know go well :-(
ATM, I am using goa it works but a total PITA to setup.
ok. i see the work for RAML. seem you are taking care of a lot of stuff already. Can you give me some tips for adding swagger support? where is a good place to start?
I'd say read (glancing as appropiate) RAML and OpenAPI specs (can't say which order is best), and check out mulesoft's oas-raml-converter, which is specifically useful for its lost semantics sections.
Maybe a framework plugin for swaggo/swag would be the way to go ?
@Scapal Agree that swaggo looks like a promising approach. @keith6014 are you working on it or is this one still pretty fair game?
Some updates?
I haven't tried it out myself, but since chi is pretty much fancy net/http, it appears as if Swaggo works.
we've successfully used swaggo with chi (not via docgen though)
any news? it's been almost 3 years
Authors are still open to contributions :)
Or.. you can hire us.
I want to finish the docment generate features, does anyone tell me how to start this work?
I'm currently using swaggo too, but I dislike the fact that it's comment-based: the documentation can deviate from the real routes and controllers. Generating a swagger from Go code really is a pain, and shouldn't be, as an industry standard...
I've built swaglint to try to minimize these differences, but I think it's not enough.
The problem with automatic generation is about knowing in advance the types sent, if we want to be 100% swagger compliant. Chi, as a net/http router, cannot know in advance what will be sent to the http.Writer. The best chi can do is listing the routes, methods and path params. I think the problem is too complicated and need a framework (like NestJS), and so doesn't apply to a router like Chi (correct me in I'm wrong).
I'm in favor of closing the issue as "wontfix" because it's not in the scope of Chi.
You could try https://github.com/go-andiamo/chioas