Skip to content

Instantly share code, notes, and snippets.

@up1
Last active May 30, 2026 01:25
Show Gist options
  • Select an option

  • Save up1/2ff003c4515e33e29666b70de12ce817 to your computer and use it in GitHub Desktop.

Select an option

Save up1/2ff003c4515e33e29666b70de12ce817 to your computer and use it in GitHub Desktop.
Demo with http file and ijhttp
$ijhttp demo.http
┌─────────────────────────────────────────────────────────────────────────────┐
│ Running IntelliJ HTTP Client with │
├────────────────────────┬────────────────────────────────────────────────────┤
│ Files │ demo.http │
├────────────────────────┼────────────────────────────────────────────────────┤
│ Public Environment │ │
├────────────────────────┼────────────────────────────────────────────────────┤
│ Private Environment │ │
└────────────────────────┴────────────────────────────────────────────────────┘
Request '#1' GET https://jsonplaceholder.typicode.com/users/1
1 requests completed, 0 have failed tests
GET https://jsonplaceholder.typicode.com/users/1
> {%
client.test("Request executed successfully", function() {
client.assert(response.status === 200, "Response status is not 200");
});
client.test("Response check email value", function() {
const data = response.body;
client.assert(data.email !== undefined, "Email not found in the response");
client.assert(data.email === "Sincere@april.biz", "Email value does not match expected");
});
client.test("Response contains name", function() {
const data = response.body;
client.assert(data.name !== undefined, "Name not found in the response");
});
// JSON schema validation
client.test("Response matches expected schema structures", function() {
const body = response.body;
// 1. Assert the main object types
client.assert(typeof body === "object" && body !== null, "Response should be a JSON Object");
// 2. Validate required top-level primitive types
client.assert(typeof body.id === "number", "Field 'id' must be a number");
client.assert(typeof body.username === "string", "Field 'username' must be a string");
// 3. Validate nested structures if applicable
if (body.address) {
client.assert(typeof body.address.street === "string", "Nested 'address.street' must be a string");
client.assert(typeof body.address.city === "string", "Nested 'address.city' must be a string");
}
});
%}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment