swagger-ui icon indicating copy to clipboard operation
swagger-ui copied to clipboard

Collapse Responses section

Open killergege opened this issue 3 years ago • 8 comments

Is your feature request related to a problem?

I'm using swagger a lot. All day I'm working with multiple micro APIs and have several swagger tabs open. And one thing that constantly happen is getting confused by the "Responses" section of the endpoint.

I think there is 3 issues:

  • It looks too much like the "Server response" section, especially when there is a response sample.
  • If the API has a lot of response types, it takes a lot of space, when most people using the Swagger UI only care about the actual response, not ALL the possible responses.
  • Also, if the API has a lot of response types, it is not always easy to find where the actual response ends, and the list of possible responses start ("Responses" title is small, with no clear separator).

This is a UX issue, as several times I'm just confused by what is displayed and I need to look harder and take a few seconds to understand what is displayed (and complain mentally ^^).

Describe the solution you'd like

Possible solutions would be:

  • to make the "Responses" section collapsible, and collapsed by default (most users don't care)
  • make the "Responses" section more visually different from the actual response. Today, the main difference is that one has "Server response" instead of "Responses" as a title, and column headers are "Code / Details" instead of "Code / Description". I'm thinking : different background color, a border, a more visible separator between the "Server response" section and the "Responses" section...

Both would be very useful but a collapsible "Responses" section would help a lot and not disrupt too much the UI.

Additional context

Few examples of the issue : The "default" display (before running) looks too much as if there was already a 200 response. The first thing you see is "Responses" / "200" / "Successful operation", it is quite easy to be confused, and you may need a couple of seconds to process. image

The actual response has mostly 2 differences : the title ("Server response" instead of "Responses"), and the curl/request url But it is not enough to make it visually stand out. image

Moreover, the difference between the actual response and the examples is not visible enough (I shrank the response bodies for the screenshot) : image

killergege avatar Nov 17 '20 19:11 killergege

make the "Responses" section more visually different from the actual response

This is discussed in #6548

hkosova avatar Nov 17 '20 20:11 hkosova

Would be nice if you support showing references to response schema, if reference is specified instead of content. Optional of course. A lot of error statuses like 4XX often have same structure and response schema can be displayed at the bottom in separate section. For now ui always unwraps references and injects them directly into response section.

I perfectly know my problem-details json structure, there is no need to show it every time, consuming 50% of screen space.

Kant8 avatar Oct 03 '21 01:10 Kant8

Agree with @Kant8 on A lot of error statuses like 4XX often have same structure.

I have that exact same issue, would be nice to be able to collapse the Response section

tdroxler avatar Oct 26 '21 13:10 tdroxler

+10, I wish I could collapse all examples, schemas, models and curl section by default, so that I can focus on what truly matters during development: enpoints, parameters and server response. Also "responses" title seems odd: it contains responses one can expect, not actual responses. The most frustrating is when someone puts examples uuids in expected response section, then it is really easy to copy-paste wrong data. When making requests with lot of data, curl div can get pretty big and take all the screen by itself.

nmoreaud avatar Jan 17 '22 17:01 nmoreaud

I'm using a custom style-sheet to make the distinction between actual response and possible responses more visible (some bolding, larger type and colors). But not being able to collapse the responses makes use really difficult, especially with a lot of error responses documented, a single endpoint/action can take up an entire screen. Being able to collapse it or to hide a known set of status codes would be amazing

pinkfloydx33 avatar Mar 24 '22 12:03 pinkfloydx33

Yes, will be extremely helpful.

Responses should be collapsed when try it out is enabled (and vice versa)

hankovich avatar Sep 01 '22 14:09 hankovich

I'd still like to be able to control the behavior of "Try It Out" and "Responses", in terms of whether they're expanded or collapsed by default, independently of each other. But yes, if we're only given one property to manage the behavior of both sections, that would still be preferable to having no control at all.

jehrenzweig-leagueapps avatar Oct 05 '22 14:10 jehrenzweig-leagueapps

It would be nice, I cannot count the times I'm reading the "Response" until I realise that is not the "Server response"

Speedkore avatar Dec 29 '23 16:12 Speedkore