Skip to content

Commit e9351c8

Browse files
committed
Update Postman environment and collection: set baseUrl and add detailed descriptions for API contract tests
1 parent ce0c16b commit e9351c8

File tree

2 files changed

+58
-6
lines changed

2 files changed

+58
-6
lines changed

postman/Development Environment.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,13 +4,13 @@
44
"values": [
55
{
66
"key": "baseUrl",
7-
"value": "",
7+
"value": "https://jsonplaceholder.typicode.com",
88
"type": "default",
99
"enabled": true
1010
}
1111
],
1212
"color": null,
1313
"_postman_variable_scope": "environment",
14-
"_postman_exported_at": "2025-11-21T12:10:19.553Z",
15-
"_postman_exported_using": "Postman/11.72.8"
14+
"_postman_exported_at": "2025-11-24T16:30:11.109Z",
15+
"_postman_exported_using": "Postman/11.72.9"
1616
}

postman/JSONPlaceholder API Contract Tests.postman_collection.json

Lines changed: 55 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
"info": {
33
"_postman_id": "35183f5f-9559-48a2-ad97-705822ec8e01",
44
"name": "JSONPlaceholder API Contract Tests",
5+
"description": "StartFragment\n\n# **JSONPlaceholder API Contract Tests**\n\n## **Purpose**\n\nThis collection validates the **contract**, **structure**, and **basic health** of the JSONPlaceholder API. \n \nThe goal is to ensure that each endpoint consistently returns responses that match the expected schema, data types, and status codes. These tests help detect breaking changes, regressions, and deviations from the documented API behavior.\n\n## **Target API**\n\nAll tests target the public JSONPlaceholder API: \n[<b>https://jsonplaceholder.typicode.com</b>](https://jsonplaceholder.typicode.com)\n\nThis API is a free fake REST service used for learning, prototyping, and testing workflows.\n\n## **How to Run This Collection**\n\nBefore running the collection, make sure you have the required environment variable:\n\n### **Environment Variable**\n\n| Variable | Description |\n| --- | --- |\n| `baseUrl` | The base URL of the target API. Set it to `https://jsonplaceholder.typicode.com`. |\n\n### Steps\n\n1. Make sure an environment is selected in Postman.\n \n2. https://jsonplaceholder.typicode.com\n \n3. Open the collection and click **Run Collection** (or use Newman/GitHub Actions if configured).\n \n4. Execute the tests. \n \n All requests will automatically use the `{{baseUrl}}` variable.\n \n\nEndFragment",
56
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json",
67
"_exporter_id": "50210709",
78
"_collection_link": "https://www.postman.com/saoudiam-97-2155897/workspace/jsonplaceholder-api-tests/collection/50210709-35183f5f-9559-48a2-ad97-705822ec8e01?action=share&source=collection_link&creator=50210709"
@@ -22,6 +23,16 @@
2223
"});\r",
2324
"pm.test(\"Response time is less than 200ms\", function () {\r",
2425
" pm.expect(pm.response.responseTime).to.be.below(500);\r",
26+
"});\r",
27+
"\r",
28+
"const schema = pm.collectionVariables.get(\"postSchema\");\r",
29+
"const jsonSchema = JSON.parse(schema);\r",
30+
"const responseBody = pm.response.json();\r",
31+
"\r",
32+
"pm.test(\"Contract: each item matches postSchema\", () => {\r",
33+
" responseBody.forEach(item => {\r",
34+
" pm.expect(tv4.validate(item, jsonSchema), tv4.error).to.be.true;\r",
35+
" });\r",
2536
"});"
2637
],
2738
"type": "text/javascript",
@@ -41,7 +52,8 @@
4152
"path": [
4253
"posts"
4354
]
44-
}
55+
},
56+
"description": "StartFragment\n\n**Purpose:** \n \nRetrieves the full list of posts and validates the API’s ability to return a complete collection.\n\n**What this request tests:**\n\n- HTTP **200** status\n \n- Response time performance\n \n- JSON array structure\n \n- Contract validation for each post object (userId, id, title, body)\n \n- Ensures the endpoint consistently returns the expected list format\n \n\nEndFragment"
4557
},
4658
"response": []
4759
},
@@ -57,7 +69,16 @@
5769
"});\r",
5870
"pm.test(\"Response time is less than 200ms\", function () {\r",
5971
" pm.expect(pm.response.responseTime).to.be.below(500);\r",
60-
"});"
72+
"});\r",
73+
"\r",
74+
"const schema = pm.collectionVariables.get(\"postSchema\");\r",
75+
"const jsonSchema = JSON.parse(schema);\r",
76+
"const responseBody = pm.response.json();\r",
77+
"\r",
78+
"pm.test(\"Contract: response matches postSchema\", () => {\r",
79+
" pm.expect(tv4.validate(responseBody, jsonSchema), tv4.error).to.be.true;\r",
80+
"});\r",
81+
""
6182
],
6283
"type": "text/javascript",
6384
"packages": {},
@@ -77,11 +98,42 @@
7798
"posts",
7899
"1"
79100
]
80-
}
101+
},
102+
"description": "StartFragment\n\n**Purpose:** \n \nRetrieves one post by its ID and validates the integrity of a single resource.\n\n**What this request tests:**\n\n- HTTP **200** status\n \n- Response time performance\n \n- Full JSON contract validation for a single post resource\n \n- Verifies presence and types of required fields (userId, id, title, body)\n \n- Confirms the endpoint correctly handles path parameters\n \n\nEndFragment"
81103
},
82104
"response": []
83105
}
84106
]
85107
}
108+
],
109+
"event": [
110+
{
111+
"listen": "prerequest",
112+
"script": {
113+
"type": "text/javascript",
114+
"packages": {},
115+
"requests": {},
116+
"exec": [
117+
""
118+
]
119+
}
120+
},
121+
{
122+
"listen": "test",
123+
"script": {
124+
"type": "text/javascript",
125+
"packages": {},
126+
"requests": {},
127+
"exec": [
128+
""
129+
]
130+
}
131+
}
132+
],
133+
"variable": [
134+
{
135+
"key": "postSchema",
136+
"value": ""
137+
}
86138
]
87139
}

0 commit comments

Comments
 (0)