165 lines
4.9 KiB
JSON
165 lines
4.9 KiB
JSON
{
|
|
"info": {
|
|
"_postman_id": "8f1c2b6e-1111-4a3b-9c55-0d6f2a7b9e01",
|
|
"name": "Shop API",
|
|
"schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json"
|
|
},
|
|
"auth": {
|
|
"type": "bearer",
|
|
"bearer": [{ "key": "token", "value": "{{token}}", "type": "string" }]
|
|
},
|
|
"event": [
|
|
{ "listen": "prerequest", "script": { "type": "text/javascript", "exec": [""] } }
|
|
],
|
|
"variable": [
|
|
{ "key": "baseUrl", "value": "https://shop.example.com/api" },
|
|
{ "key": "pageSize", "value": 20 }
|
|
],
|
|
"item": [
|
|
{
|
|
"name": "Health",
|
|
"request": {
|
|
"auth": { "type": "noauth" },
|
|
"method": "GET",
|
|
"header": [],
|
|
"url": { "raw": "{{baseUrl}}/health", "host": ["{{baseUrl}}"], "path": ["health"] }
|
|
}
|
|
},
|
|
{
|
|
"name": "Products",
|
|
"item": [
|
|
{
|
|
"name": "List products",
|
|
"request": {
|
|
"method": "GET",
|
|
"header": [
|
|
{ "key": "Accept", "value": "application/json" },
|
|
{ "key": "X-Debug", "value": "1", "disabled": true }
|
|
],
|
|
"url": {
|
|
"raw": "{{baseUrl}}/products?limit={{pageSize}}&sort=name",
|
|
"host": ["{{baseUrl}}"],
|
|
"path": ["products"],
|
|
"query": [
|
|
{ "key": "limit", "value": "{{pageSize}}" },
|
|
{ "key": "sort", "value": "name" }
|
|
]
|
|
}
|
|
},
|
|
"event": [
|
|
{
|
|
"listen": "test",
|
|
"script": { "exec": ["pm.test(\"ok\", () => pm.response.to.have.status(200));"], "type": "text/javascript" }
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Create product",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "raw",
|
|
"raw": "{\r\n \"name\": \"Widget\",\r\n \"price\": 9.5\r\n}",
|
|
"options": { "raw": { "language": "json" } }
|
|
},
|
|
"url": "{{baseUrl}}/products"
|
|
}
|
|
},
|
|
{
|
|
"name": "Upload image",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "formdata",
|
|
"formdata": [
|
|
{ "key": "caption", "value": "Front view", "type": "text" },
|
|
{ "key": "image", "type": "file", "src": "/home/me/widget.png" },
|
|
{ "key": "draft", "value": "true", "type": "text", "disabled": true }
|
|
]
|
|
},
|
|
"url": "{{baseUrl}}/products/1/image"
|
|
}
|
|
},
|
|
{
|
|
"name": "Admin",
|
|
"auth": {
|
|
"type": "basic",
|
|
"basic": [
|
|
{ "key": "password", "value": "{{adminPass}}", "type": "string" },
|
|
{ "key": "username", "value": "admin", "type": "string" }
|
|
]
|
|
},
|
|
"item": [
|
|
{
|
|
"name": "Delete product",
|
|
"request": { "method": "DELETE", "header": [], "url": "{{baseUrl}}/products/1" }
|
|
},
|
|
{
|
|
"name": "Search (GraphQL)",
|
|
"request": {
|
|
"method": "POST",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "graphql",
|
|
"graphql": { "query": "query { products { id name } }", "variables": "{\"first\": 5}" }
|
|
},
|
|
"url": "{{baseUrl}}/graphql"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
},
|
|
{
|
|
"name": "Auth",
|
|
"item": [
|
|
{
|
|
"name": "Token",
|
|
"request": {
|
|
"auth": { "type": "noauth" },
|
|
"method": "POST",
|
|
"header": [],
|
|
"body": {
|
|
"mode": "urlencoded",
|
|
"urlencoded": [
|
|
{ "key": "grant_type", "value": "client_credentials" },
|
|
{ "key": "client_id", "value": "{{clientId}}" },
|
|
{ "key": "scope", "value": "shop", "disabled": true }
|
|
]
|
|
},
|
|
"url": "https://auth.example.com/oauth/token"
|
|
},
|
|
"event": [
|
|
{ "listen": "test", "script": { "exec": ["pm.environment.set('token', pm.response.json().access_token);"] } }
|
|
]
|
|
},
|
|
{
|
|
"name": "API key ping",
|
|
"request": {
|
|
"auth": {
|
|
"type": "apikey",
|
|
"apikey": [
|
|
{ "key": "key", "value": "X-Api-Key" },
|
|
{ "key": "value", "value": "{{apiKey}}" },
|
|
{ "key": "in", "value": "header" }
|
|
]
|
|
},
|
|
"method": "GET",
|
|
"url": "{{baseUrl}}/ping"
|
|
}
|
|
},
|
|
{
|
|
"name": "Digest thing",
|
|
"request": {
|
|
"auth": { "type": "digest", "digest": [] },
|
|
"method": "GET",
|
|
"url": "{{baseUrl}}/digest"
|
|
}
|
|
}
|
|
]
|
|
}
|
|
]
|
|
}
|