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

Button for copy to clipboard

Open mvindahl opened this issue 11 years ago • 10 comments

We often find ourselves doing a web service call in swagger-ui and wanting to subsequently copy the result to the clipboard. Currently the only option is to go to the text box and mark the text using the mouse of keyboard (cmd-A is not a viable shortcut since it'll select the entire page).

I've seen other applications add a "copy to clipboard" button next to content which people typically want to copy to elsewhere. I think that such a button next to (or above) the response body output would be nice.

I don't think it's rocket science either. So if you like the idea, I can try to implement it and do a PR.

mvindahl avatar Nov 21 '15 09:11 mvindahl

Hi, that is a good suggestion, and it was once in swagger-ui. The reason it was removed was because of large definitions taking a long time to create all the "copy" buttons (it was using flash if I recall). If it can be done on-demand (like when expanding a resource), it'd be great to have.

fehguy avatar Nov 23 '15 07:11 fehguy

Great. I'd be very surprised if it caused any overhead to add these buttons in the current JS/HTML5 based implementation. I'm less surprised to learn that ol' Flash performed poorly :)

I'll see if I can find the time to add it and also to check how it impacts performance.

mvindahl avatar Nov 24 '15 13:11 mvindahl

Thank you, there are probably better techniques than what we did before. Would be happy if you had time to contribute.

fehguy avatar Nov 28 '15 02:11 fehguy

Closing as an old ticket. If anyone wants to submit a PR to cover this issue, we'd be happy to review.

webron avatar Jun 09 '17 21:06 webron

I would be interested in this too. As explained in the description, when you need to call a series of endpoints passing the response of one as the input of another, the live demo experience becomes quite clunky (although you could prepare everything upfront, but still!).

I see a couple of options to tackle this:

  • adding a small copy button next to the textbox of the response;
  • enabling something like "triple click" in the text box to select all (like it happens here on GitHub when you triple click on a snippet), e.g.
triple click meeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee

Based on the this comment, I believe this issue was closed because of the lack of contributor. I would be happy to help, assuming there is a preference in the options listed above.

@webron, would you be inclined to reopen this issue?

fabriziocucci avatar Jan 17 '18 10:01 fabriziocucci

+1 for this enhancement

nennec avatar Jan 17 '18 13:01 nennec

+1

arran549 avatar Jun 29 '18 14:06 arran549

+1

johnnyqian avatar Aug 15 '18 03:08 johnnyqian

+1

perseghini avatar Jul 11 '19 17:07 perseghini

+1

ship2moon avatar Aug 12 '19 14:08 ship2moon