httpYac Code Snippets
An extended collection of code snippets for authoring HTTP request files with the httpYac - Rest Client extension for Visual Studio Code.
The snippets scaffold complete, well-commented request blocks, control-flow constructs, authentication headers, and response assertions, so you can build and validate HTTP requests faster.
Features
The snippets are available in files associated with the http and rest languages. Type a prefix (for example, http, get, ?? status, or chai) and select a snippet from the completion list to insert a ready-to-edit template with tab stops and inline guidance.

Request blocks
| Prefix |
Description |
###, http |
Request region for any HTTP method (GET, POST, PATCH, PUT, DELETE). |
get |
Request region for an HTTP GET method. |
post |
Request region for an HTTP POST method. |
put |
Request region for an HTTP PUT method. |
patch |
Request region for an HTTP PATCH method (json-patch+json, merge-patch+json, or custom JSON). |
delete |
Request region for an HTTP DELETE method. |
Each request block includes optional sections for a description, request name, referenced requests, a $cancel condition, headers, a request body, and common response assertions.
Control flow
| Prefix |
Description |
# @import, file |
Import a local .http/.rest file. |
# @ref |
Reference a request that executes once per session. |
# @forceRef |
Reference a request that executes on every run. |
# @loop, for |
Repeat a request N times. |
# @loop, foreach |
Repeat a request for each item in an array. |
# @loop, while |
Repeat a request while a condition is true. |
retry, attempts |
Retry a failed request for up to N total attempts. |
retry, timeout |
Retry a failed request for up to N seconds. |
last, response |
Return the last response for a request executed in a loop. |
# @sleep, delay |
Set sleep time before a request. |
# @disabled, skip |
Disable a request. |
$cancel, cancel |
Cancel a request when a condition is met. |
Authentication and headers
| Prefix |
Description |
oauth, variables |
Define OAuth 2.0 / OpenID variables (hard-coded, from environment, or without tab stops). |
authorization, oauth |
Set the Authorization header for OAuth 2.0 / OpenID. |
authorization, bearer |
Set the Authorization header to Bearer. |
authorization, basic |
Set the Authorization header to Basic. |
content-type |
Set the Content-Type header for the request data. |
header, default |
Define and reuse default headers. |
# @no-, certificate |
Disable certificate validation for self-signed HTTPS hosts. |
Assertions and tests
| Prefix |
Description |
?? status |
Validate the HTTP response status code. |
?? body |
Validate a response body property. |
?? header |
Validate a response header. |
?? js response |
Validate the status or a body property using JavaScript. |
test, assert |
Validate a response using the test function in a post-request script. |
chai |
Use chai.js with assert, expect, or should validations. |
chai-string |
Use chai-string.js string validations. |
chai-subset |
Use chai-subset.js object/array validations. |
The chai, chai-string, and chai-subset groups also include setup snippets that explain the required Node.js version and npm packages.
Requirements
This extension depends on the httpYac - Rest Client extension, which is installed automatically as an extension dependency.
Extension Settings
This extension does not contribute any settings. It only adds snippets for the http and rest languages.
Known Issues
None at this time. Please report issues on the project repository.
Release Notes
See the CHANGELOG for the full release history.
0.0.2
- Minor formatting and documentation fixes.
0.0.1
License
Licensed under the MIT License.