-
-
Notifications
You must be signed in to change notification settings - Fork 769
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
No json pretty printing #313
Conversation
json. This only unnecessarily enlarges the payload to be returned and this increase can be significant. Pretty printing should be handled by the client instead
As a side note: I can of course return a flask Response object with my own non-pretty printed json - but then response validation in connexion does not work, and this is one of the feature I like (amongst others) very much. |
@sebastianmika I personally agree, the response JSON should be machine-readable, humans can use their favorite client (e.g. HTTPie) to get pretty output. |
@sebastianmika basically this PR reverts #193, see the discussion there (BTW I still agree with you about not having pretty printed by default). |
True enough. Regarding what is best practice or not, I found little relevant stuff. However, at one place it was correctly stated that enabling compression is much more important than whether one pretty prints the json or not. Using compress = Compress()
compress.init_app(app.app) that is quickly done and indeed had a much greater impact than not pretty printing. The same source also argued as gdb from #193 - API results should be nice to look at for developers without any hassle. So, I would rather close my own PR and go with compression, unless you make a strong point against that. As an alternative, as also discussed in #193, pretty or not could be an option to |
@sebastianmika OK, if you are fine with closing your PR 😄 |
Hi, is there any newer issue opened about this problem after this one? As a new (and pretty happy!) Connexion user found it pretty astonishing that I saw pretty printed JSON responses and that this doesn't seem to be configurable. The compress workaround has drawbacks (when clients do not support it for example) and I don't want to depend on that. In my case, stress-testing the REST API appeared to be network-bound and the data I get is about 4 times the data a compact JSON REST API sends back. |
Changes proposed in this pull request:
Personally I think it is not best practice to return pretty printed json. This only unnecessarily enlarges the payload to be returned and this increase can be significant. Pretty printing should be
handled by the client instead.