Vscode-restclient: Provide option to place response in an edittable response document

Created on 19 Feb 2017  路  10Comments  路  Source: Huachao/vscode-restclient

It would be better if the response could be just a normal document with highlighting.
Then we could use the full power of VS Code to search, select or manipulate the result data without having to copy and past into a new document.

enhancement

All 10 comments

@dakaraphi using html to preview response instead of normal text document is by design for following reasons.

  • I can easily highlight http response(no matter json, xml) with the use of highlight.js package
  • I can preview stream response(image) in html easily, but not in text document
  • I can have more freedom and functions to add to the response preview view, like in the future I can add an input in the html page to let user filter the response body

And I know, what you've mentioned like __search__ and __manipulate__ is a pain point of html page in the limitation of vscode.

However, copy and paste is not needed in my tool, since you can simply do this by clicking the Save Response button in the upper right corner
image

@Huachao I'm not asking you to change the current behavior, I'm asking for an option to be provided to choose to dump the data to an editor, ideally with the language set by the response content type.

  1. Within an editor, I have all the full power of VS Code + hundreds of plugins.
  2. I can use the theme coloring and syntax highlighting I have chosen. Yes, the headers may not look correct, but the main content XML or JSON etc will look good.
  3. If I need to see an image, I can use the current behavior
  4. I don't usually want to save the content.

So, it would just be nice to have a new command to send request and dump to editor.

@dakaraphi Got, I will reopen this and consider this carefully. Thanks for your suggestion

So, after spending some more time using this extension, this is my typical workflow

  1. Send Request
  2. Select result and copy
  3. Close result window
  4. Open new editor window and paste in result
  5. Set language to XML or JSON based on response
  6. Format document
  7. Inspect or search content for specific data

So if there was a command that basically automated that workflow, that would be awesome.

  1. Open a new editor (Do this for each response. This allows me to very conveniently to use the VS Code builtin compare to compare results with previous results.)
  2. Automatically set language based on response
  3. Format document

@dakaraphi I understand your pain now 馃槃 .

@dakaraphi I have fixed this issue, and will publish in next release. When you click the newly added 'Save Response Body' icon, the extension will save body __ONLY__ according to content type to corresponding file extension. And you can also override the content type and file extension mapping rule, like by default, I will set the content type of application/atom+xml to file extension atom, and you can overwrite in setting to xml

@Huachao Thanks for taking a look into this so quickly! This sounds a bit better, but not exactly what I was attempting to describe above. Could you please consider the following?

  1. I want to execute this with a new command that just opens the response in a new editor tab. I would like to skip the interim step of having the preview and then click another button.
  2. I actually am fine with including the headers at the top. VS Code seems to handle that just fine. Syntax highlighting works and document formatting still works. This way I can skip the current preview.
  3. I rarely want to save a response. I don't want a bunch of files to cleanup. I would prefer to just save the response as I would any file if I wish to keep it.
  4. You didn't mention if you automatically execute VS Code's format. If that's possible to do, that would also be great.
  5. BTW, nice idea about providing mapping rules for language type. Looks good.

@dakaraphi I will think about you requirement again. And the save body to specific file extension is required by other user, so I will keep it.

@dakaraphi I have implemented this, and after I published the version, you can experience this by set the flag rest-client.previewResponseInUntitledDocument to true. And after that, you can still use previous send request command, and view response in an untitled document.

@dakaraphi I know you already provide a new PR and I also leave some comments to discuss with you. And I want to tell you that the new version 0.13.0 is already published, and you can use the functionalities except your suggestions.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

luislobo picture luislobo  路  6Comments

danroot picture danroot  路  3Comments

YBogomolov picture YBogomolov  路  3Comments

rainbow2019s picture rainbow2019s  路  4Comments

hidaytrahman picture hidaytrahman  路  5Comments