Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make flasgger optional? #26

Open
AdamWill opened this issue Aug 28, 2023 · 7 comments
Open

Make flasgger optional? #26

AdamWill opened this issue Aug 28, 2023 · 7 comments

Comments

@AdamWill
Copy link

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?

@kevin1024
Copy link

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?

@AdamWill
Copy link
Author

AdamWill commented Aug 28, 2023

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
Copy link
Author

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.

@kevin1024
Copy link

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 :)

@AdamWill
Copy link
Author

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

@AdamWill
Copy link
Author

Sorry for the delay, but I finally went ahead and did #32 .

@ml31415
Copy link

ml31415 commented Apr 10, 2024

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants