-
Notifications
You must be signed in to change notification settings - Fork 9k
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
Offer a switch to not pretty-print large responses in the UI or even not print them at all #4018
Comments
We had some discussion about this on Issues #2030 and #3832 I very much like the idea of a button/switch with The additional Preview I do not see much value, I think that preview should be built-in by default, we should only display X amount of bites of the response, and if the response is large we can add a download link. |
@dirkschneemann Swagger-Ui can display images on the response here is an example: |
Sorry for the late reply, @heldersepu . Our API only runs internally within our network so I cannot share it but it should be easy to come up with a simple example API in any language that serves a static SVG image on request. Feel free to contact me if you need help with this. |
@dirkschneemann If you can create on simple example it will be awesome, the latest UI should render the image just fine. |
Hi @heldersepu , unfortunately I cannot get the SVG rendering to work, using swagger-ui 3.7.0 and 3.8.0. I created a minimal web application in Python which just returns the SVG code of your example on the The according endpoint definition in the OpenAPI spec looks like this:
Still, I always get the following error in the response box: You can see from the developer toolbar at the bottom that the response's content type is correctly set to Have you got any idea what could be the reason for this? |
Interesting enough I did noticed that too... |
Great, thanks a lot! Hope this will make it into the next release :) |
If you can take a look at my code... |
Sorry, I am not enough familiar with this to judge or know about a better way. |
I was not familiar a month ago... |
Is this ticket still open? I recently ran into this problem as well. I agree that a button to turn off the "Pretty" option would be nice since Swagger UI seems not to be able to handle large JSON responses. If the ticket is still open, @heldersepu do you have any insight into the work that has been done on this ticket? |
@icarter09 Yes ticket still open, as far as I know no work has been done |
Just closed #3640 in favor of this - it's worth considering a response size ceiling after which we have the user opt-in to rendering the request at all, be it pretty or raw. Even raw string rendering starts to break down eventually (probably not far past the 50MB mark 🤔) |
Is this being resolved any time soon? We are currently facing the same issue. Best regards. |
Just wanted to know if there was a switch created to have a pretty or not pretty JSON responses? In any versions at least. I've also been looking into this but haven't found anything so far. Thank you |
@Ovrful and @amartinez-relpro can you provide a link to your API, would be nice to have more data on how others use it |
We are also facing this issue with large JSON responses (> 10 MB JSON). |
Same issue here. Any workaround? The UI becomes unresponsive with large JSON (catalog export as an instance) |
Not sure if another "Me Too" comment is helpful, but we are also having this issue. Is there a way to add a filter to not do formatting on the result? |
Same here. Freezes on large results. |
Same here. I'm facing the same two issues:
|
Ok, this has bitten me in my behind on several projects now 😤 How about, at least, show a warning? Something along the lines of:
I've made a quick-and-dirty example of how I think it should look: Obviously the message, or the 'design', can be improved and isn't final; I'm just pitching what I think is a decent compromise. |
I originally came here because my big number 2^256 bits. Was translated by the UI into scientific format instead of just showing the raw number. That have led me to various issues that are all closed in favor of this issue here. |
@migoldfinger & @RobThree this issue if implemented will still not fix your issues with big number, completely unrelated issue |
Offer a switch to not pretty-print large responses in the UI or even not print them at all but rather send them as a download or similar.
I am aware of issue 1184 which sounds similar. However, the solution mentioned therein names a
highlightSizeThreshold
parameter which I cannot find anymore in the current version, it probably only existed inswagger-ui 2.x
.dist
folder on NGINXExpected Behavior
Current Behavior
Currently, all responses (at least JSON, GeoJSON and XML) are automatically pretty-printed in the response box with lots of whitespace and linebreaks. Large responses can lead to a huge and inconvenient scrollbar or even make the browser crash.
Possible Solution
Similar as done e.g. in Postman, there could be a button/switch that can be set to
Pretty
orRaw
prior to hitting the execute button.In addition (nice to have):
Preview
button could only display the first x lines of the responsedownload
would open aDownload file
dialog box so that the user can save a large response without displaying it in the UI at allContext
My API returns quite large GeoJSON and SVG responses for some of its endpoints. Typically, when trying out their functionality in
swagger-ui
via theTry it out
button, our users are not interested in reading such responses with the naked eye. What they rather do is copy and paste them into a tool which can display the GeoJSON on a map or render the SVG text into an actual image. We have such tools running locally in our company but similar ones are also freely available online.Just for copying the response, pretty-printing is not necessary and not doing it would probably increase the browser's performance significantly while keeping the webpage easier navigable due to the smaller scrollbar.
The text was updated successfully, but these errors were encountered: