swagger-api / swagger-api/swagger-ui
Offer a switch to not pretty-print large responses in the UI or even not print them at all
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 29k
- Forks
- 9.3k
- Avg merge
- 2d 23h
- Merged PRs (30d)
- 25
Description
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 in swagger-ui 2.x.
| Q | A |
|---|---|
| Bug or feature request? | Feature Request |
| Which Swagger/OpenAPI version? | 3.0.0 |
| Which Swagger-UI version? | 3.6.1 |
| How did you install Swagger-UI? | self-hosting the dist folder on NGINX |
| Which browser & version? | any |
| Which operating system? | any |
Expected 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 or Raw prior to hitting the execute button.

In addition (nice to have):
- a
Previewbutton could only display the first x lines of the response - another checkbox or button for
downloadwould open aDownload filedialog box so that the user can save a large response without displaying it in the UI at all
Context
My API returns quite large GeoJSON and SVG responses for some of its endpoints. Typically, when trying out their functionality in swagger-ui via the Try 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.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the Swagger UI configuration documentation and the Try it out response box described in the issue, then trace how large JSON, GeoJSON, and XML responses are rendered. Define which response modes are in scope before changing behavior; done means the selected handling avoids unnecessary pretty-printing and supports the agreed large-response outcome without crashing the browser.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100