docgen icon indicating copy to clipboard operation
docgen copied to clipboard

Generate API in Swagger format

Open JensRantil opened this issue 7 years ago • 15 comments

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.

JensRantil avatar Jul 10 '17 07:07 JensRantil

any update from the author about this? it would be a great feature

keith6014 avatar Aug 11 '18 00:08 keith6014

Authors are open to contributions :)

VojtechVitek avatar Aug 11 '18 18:08 VojtechVitek

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.

keith6014 avatar Aug 13 '18 00:08 keith6014

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?

keith6014 avatar Aug 14 '18 04:08 keith6014

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.

thejmazz avatar Aug 14 '18 16:08 thejmazz

Maybe a framework plugin for swaggo/swag would be the way to go ?

Scapal avatar Feb 22 '19 09:02 Scapal

@Scapal Agree that swaggo looks like a promising approach. @keith6014 are you working on it or is this one still pretty fair game?

JohnLockwood avatar Feb 28 '19 22:02 JohnLockwood

Some updates?

lelvisl avatar May 13 '19 11:05 lelvisl

I haven't tried it out myself, but since chi is pretty much fancy net/http, it appears as if Swaggo works.

alee792 avatar Jun 11 '19 14:06 alee792

we've successfully used swaggo with chi (not via docgen though)

tiny-dancer avatar Jun 12 '19 00:06 tiny-dancer

any news? it's been almost 3 years

fr3fou avatar Apr 08 '20 21:04 fr3fou

Authors are still open to contributions :)

Or.. you can hire us.

VojtechVitek avatar Apr 08 '20 21:04 VojtechVitek

I want to finish the docment generate features, does anyone tell me how to start this work?

leyafo avatar Aug 02 '21 09:08 leyafo

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.

EwenQuim avatar Feb 21 '23 14:02 EwenQuim

You could try https://github.com/go-andiamo/chioas

marrow16 avatar Nov 06 '23 17:11 marrow16