Spark: Swagger support?

Created on 23 Mar 2015  Â·  14Comments  Â·  Source: perwendel/spark

Anybody looking into baking-in swagger support?

Feature request

All 14 comments

Would be nice to have. How would you imagine this would work roughly?

I tried to do something like this before, but unfortunately annotations
don't seem to work correctly with lambda functions, so it'd be impossible.

For my project, I basically just created a mustache template html page for
the API documentation, and represented all the routes, examples, and
descriptions in a static .JSON file.
On Mar 23, 2015 9:25 AM, "Eelco Hillenius" [email protected] wrote:

Would be nice to have. How would you imagine this would work roughly?

—
Reply to this email directly or view it on GitHub
https://github.com/perwendel/spark/issues/258#issuecomment-84995856.

Yeah, annotations won't work, which imho is fine because even if they would, it would much negate everything that's nice about using Spark (which is, that it is a simple api not build around having specific methods with annotations and such). The end of the day, swagger is a spec, so as long as you generate what it expects, it doesn't matter how you get there.

I think that at the minimum what Spark can do to facilitate swagger integration is make the model that it builds up internally more accessible. That'd be great to have regardless actually. Basically, we - framework clients - would have a way to introspect routes for the basics, like path and parameter info, and Spark could consider baking in more things - optionally - like content types etc and make that available for introspection when set. That would be a good start.

Beyond that (and building on top of that probably) Spark could consider building a tighter integration. Wouldn't be everyone's cup of tea to make Spark more opinionated (and have a larger conceptual surface area) I guess, though swagger being pretty much the defacto standard, this probably isn't so bad. Not sure what that would actually look like, but I would probably be thinking about adding a bunch of optional builders to build up meta data about the API.

I really like (from a quick view) how https://github.com/metosin/compojure-api provides swagger support on top of compojure. Not so useful for this case, but maybe a source of inspiration somehow :-)

Spark is so easy to use, would be great if we could generate Swagger templates from Sparkframework. Then documentation would be very easily supported. Develop your code and just generate your documentation in a standard way.

Any progress ?

+1

chchchch

2016-04-21 9:02 GMT+02:00 Yuanteng (Jeff) Pei [email protected]:

+1

—
You are receiving this because you are subscribed to this thread.
Reply to this email directly or view it on GitHub
https://github.com/perwendel/spark/issues/258#issuecomment-212773536

It's possible to create swagger json if you can survive writing your routes without lambda expressions. You can check my sample project https://github.com/srlk/spark-swagger

@srlk nice! Can we repost your tutorial on https://sparktutorials.github.io/ ?

Sure @tipsy

Looks like the project has moved. All links are broken.
Here is the new link:
https://github.com/cesinrm/spark-swagger

@pgKuantic , the tutorial link on readme is lost

"And each route has to be separate classes to make annotations happily parsesable.. Sorry (req, res) -> magic!"
https://serol.ro/posts/2016/swagger_sparkjava/

Really dislike the idea to abandon lambda expression (req, res) -> magic!

Hi,
I´ve been working on a non-official Spark extension to suppor Swagger.
Check it out https://github.com/manusant/SparkSwagger

The ideia is to keep the Spark beauty and simplicity, maintaing the existing api with additional information.

This library also generate a live documentation page directly from running Spark server

Spark + Swagger Spec + Swagger UI = SparkSwagger

Was this page helpful?
0 / 5 - 0 ratings