httpbin icon indicating copy to clipboard operation
httpbin copied to clipboard

Make flasgger optional?

Open AdamWill opened this issue 2 years ago • 7 comments

Hi! I'm a packager for Fedora. We've run into a bit of a roadblock trying to update Fedora's httpbin package: https://bugzilla.redhat.com/show_bug.cgi?id=2233128#c9

since the last version we packaged, httpbin grew a hard dependency on flasgger. flasgger is not packaged for Fedora and is a bit tricky to package because it contains several bundled, pre-minified javascript libraries, which is against Fedora's packaging guidelines. (They are also, I'll note, ancient - upstream hasn't updated the bundled libraries for ui2 or ui3 since it added them, six and five years ago respectively.)

We can probably work around this if necessary (perhaps by only packaging ui3, the one httpbin uses, which is simpler as it only bundles jquery 2.x), but another option is to look at having httpbin not use flasgger. It doesn't seem, strictly speaking, to be necessary - all it does (AIUI) is provide API docs in the web UI, which is neat but not critical. Especially not since the main reason we package httpbin in Fedora is as a dependency of requests' test suite - no human is looking at API docs in a web UI there.

Would it be acceptable to send a patch to make the flasgger dependency optional, and just skip all the flasgger setup stuff in httpbin/core.py if it's not present?

AdamWill avatar Aug 28 '23 22:08 AdamWill

I'm down, especially since flasgger adds its own tree of sub-dependencies, and for httpbin's library usecase, it really doesn't matter.

However, it DOES render the current homepage for httpbin.

Maybe there's a way to fall back to the old static homepage if flasgger isn't available?

kevin1024 avatar Aug 28 '23 22:08 kevin1024

I mean, I guess the way I'd address that would be just to make sure whatever process generates the project's homepage honors the optional dependency? I was thinking the setuptools extras_require style, where you can require something like httpbin[apidocs] and flasgger will be pulled in, but if you require just httpbin it won't.

e.g. in a lot of my projects I specify the dependency coverage[toml] because I want to configure coverage via pyproject.toml - in coverage itself this is implemented here. If you just require coverage, you can't configure it with pyproject.toml.

I don't know how you do this if you're not using setuptools, but I'd be surprised if other systems don't make it possible.

AdamWill avatar Aug 28 '23 23:08 AdamWill

oh, I think I'm misunderstanding - you mean it renders the page you see for any instance of httpbin if you just go to the root of the web server? In that case, yeah, I guess we'd need an alternative.

AdamWill avatar Aug 28 '23 23:08 AdamWill

you mean it renders the page you see for any instance of httpbin if you just go to the root of the web server? I

As I understand it, yes, the neat API explorer thingy you get when visiting the homepage of httpbin.org is powered by flasgger.

At one point there was a static html homepage, if someone dug that up from git history and made sure it was up-to-date with all the currently available endpoints and had the app fall back to that static page if flasgger is not installed, then I would merge that PR :)

kevin1024 avatar Aug 31 '23 00:08 kevin1024

awesome, thanks. I will try and get to that then.

AdamWill avatar Aug 31 '23 01:08 AdamWill

Sorry for the delay, but I finally went ahead and did https://github.com/psf/httpbin/pull/32 .

AdamWill avatar Oct 18 '23 00:10 AdamWill

@sigmavirus24 @nateprewitt Could one of you please have a look at either PR #32 or #44 ? Pretty please? :)

ml31415 avatar Apr 10 '24 09:04 ml31415