Skip to content

Commit

Permalink
Added validation setting
Browse files Browse the repository at this point in the history
[release]
  • Loading branch information
madskristensen committed Jan 3, 2022
1 parent 4f10553 commit 662770b
Show file tree
Hide file tree
Showing 8 changed files with 25 additions and 8 deletions.
8 changes: 3 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@ or get the [CI build](https://www.vsixgallery.com/extension/RestClientVS.a7b4a36

REST Client allows you to send HTTP request and view the response in Visual Studio directly. Based on the popular VS Code extension [Rest Client](https://marketplace.visualstudio.com/items?itemName=humao.rest-client) by [Huachao Mao](https://github.com/Huachao)

![Screenshot](art/screenshot.png)

## The .http file
Any files with the extension `.http` is the entry point to creating HTTP requests.

Expand Down Expand Up @@ -40,11 +42,7 @@ This is what it looks like in the Blue Theme.

![Document](art/document.png)

Notice the green play buttons showing up after each URL. Clicking those will fire off the request and display the raw response in the Output Widow.

![Output](art/output.png)

Peek at the value of the variables by moving the mouse over any line containing a variable reference.
Notice the green play buttons showing up after each URL. Clicking those will fire off the request and display the raw response on the right side of the document.

![Tooltip](art/tooltip.png)

Expand Down
Binary file modified art/options.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file removed art/output.png
Binary file not shown.
Binary file added art/screenshot.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
5 changes: 5 additions & 0 deletions src/RestClientVS/Language/TokenTagger.cs
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,11 @@ private void AddTagToList(Dictionary<ParseItem, ITagSpan<TokenTag>> list, ParseI

private IEnumerable<ErrorListItem> CreateErrorListItem(ParseItem item)
{
if (!General.Instance.EnableValidation)
{
yield break;
}

ITextSnapshotLine line = _buffer.CurrentSnapshot.GetLineFromPosition(item.Start);

foreach (Error error in item.Errors)
Expand Down
7 changes: 7 additions & 0 deletions src/RestClientVS/Options/General.cs
Original file line number Diff line number Diff line change
Expand Up @@ -17,9 +17,16 @@ public class General : BaseOptionModel<General>
[DefaultValue(20)]
public int Timeout { get; set; } = 20;

[Category("General")]
[DisplayName("Enable validation")]
[Description("Determines if error messages should be shown for unknown variables and incorrect URIs.")]
[DefaultValue(true)]
public bool EnableValidation { get; set; } = true;

[Category("Response")]
[DisplayName("Response Window Width")]
[Description("The number of seconds to allow the request to run before failing.")]
[Browsable(false)]
[DefaultValue(500)]
public int ResponseWindowWidth { get; set; } = 500;
}
Expand Down
9 changes: 8 additions & 1 deletion src/RestClientVS/RestDocument.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,10 @@ public RestDocument(ITextBuffer buffer)
{
_buffer = buffer;
_buffer.Changed += BufferChanged;

FileName = buffer.GetFileName();

General.Saved += OnSettingsSaved;

ThreadHelper.JoinableTaskFactory.RunAsync(async () =>
{
await Task.Yield();
Expand All @@ -42,11 +43,17 @@ private async Task ParseAsync()
Parse();
}

private void OnSettingsSaved(General obj)
{
ParseAsync().FireAndForget();
}

public void Dispose()
{
if (!_isDisposed)
{
_buffer.Changed -= BufferChanged;
General.Saved -= OnSettingsSaved;
}

_isDisposed = true;
Expand Down
4 changes: 2 additions & 2 deletions vs-publish.json
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,8 @@
"targetPath": "art/document.png"
},
{
"pathOnDisk": "art/output.png",
"targetPath": "art/output.png"
"pathOnDisk": "art/screenshot.png",
"targetPath": "art/screenshot.png"
},
{
"pathOnDisk": "art/tooltip.png",
Expand Down

0 comments on commit 662770b

Please sign in to comment.