Skip to content

Commit 9a3d634

Browse files
committed
create updated examples with includes
1 parent 39655d5 commit 9a3d634

22 files changed

+501
-3
lines changed

docs/http_snippets/README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,14 @@
55

66

77
```shell
8+
# checked on node@14 and npm@6.14.18
89
# to use in cli
9-
npm install --global httpsnippet
10+
npm install --global httpsnippet@2
1011
```
1112

1213
```shell
1314
# to use as a module
14-
npm install --save httpsnippet
15+
npm install --save httpsnippet@2
1516
```
1617

1718
## Spec
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"method": "POST",
3+
"url": "http://localhost:8000/computers?include=user",
4+
"httpVersion": "HTTP/1.1",
5+
"queryString": [
6+
],
7+
"headers": [
8+
{
9+
"name": "content-type",
10+
"value": "application/vnd.api+json"
11+
}
12+
],
13+
"postData": {
14+
"mimeType": "application/json",
15+
"text": "{\n \"data\": {\n \"type\": \"computer\",\n \"attributes\": {\n \"name\": \"Amstrad\"\n },\n \"relationships\": {\n \"user\": {\n \"data\": {\n \"id\": \"3\",\n \"type\": \"user\"\n }\n }\n }\n }\n}"
16+
}
17+
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
{
2+
"method": "POST",
3+
"url": "http://localhost:8000/users",
4+
"httpVersion": "HTTP/1.1",
5+
"queryString": [
6+
],
7+
"headers": [
8+
{
9+
"name": "content-type",
10+
"value": "application/vnd.api+json"
11+
}
12+
],
13+
"postData": {
14+
"mimeType": "application/json",
15+
"text": "{\n \"data\": {\n \"type\": \"user\",\n \"attributes\": {\n \"first_name\": \"Bob\",\n \"last_name\": \"Green\",\n \"age\": 37,\n \"status\": \"active\",\n \"email\": \"bob@example.com\"\n }\n }\n}"
16+
}
17+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"method": "GET",
3+
"url": "http://localhost:8000/users/3",
4+
"httpVersion": "HTTP/1.1",
5+
"queryString": [
6+
],
7+
"headers": [
8+
{
9+
"name": "content-type",
10+
"value": "application/vnd.api+json"
11+
}
12+
]
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"method": "GET",
3+
"url": "http://localhost:8000/users/3?include=computers",
4+
"httpVersion": "HTTP/1.1",
5+
"queryString": [
6+
],
7+
"headers": [
8+
{
9+
"name": "content-type",
10+
"value": "application/vnd.api+json"
11+
}
12+
]
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"method": "GET",
3+
"url": "http://localhost:8000/users",
4+
"httpVersion": "HTTP/1.1",
5+
"queryString": [
6+
],
7+
"headers": [
8+
{
9+
"name": "content-type",
10+
"value": "application/vnd.api+json"
11+
}
12+
]
13+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
{
2+
"method": "GET",
3+
"url": "http://localhost:8000/users?include=computers",
4+
"httpVersion": "HTTP/1.1",
5+
"queryString": [
6+
],
7+
"headers": [
8+
{
9+
"name": "content-type",
10+
"value": "application/vnd.api+json"
11+
}
12+
]
13+
}
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
POST /computers?include=user HTTP/1.1
2+
Content-Type: application/vnd.api+json
3+
4+
{
5+
"data": {
6+
"type": "computer",
7+
"attributes": {
8+
"name": "Amstrad"
9+
},
10+
"relationships": {
11+
"user": {
12+
"data": {
13+
"id": "3",
14+
"type": "user"
15+
}
16+
}
17+
}
18+
}
19+
}
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
1+
HTTP/1.1 201 Created
2+
Content-Type: application/json
3+
4+
{
5+
"data": {
6+
"attributes": {
7+
"name": "Amstrad"
8+
},
9+
"id": "2",
10+
"relationships": {
11+
"user": {
12+
"data": {
13+
"id": "3",
14+
"type": "user"
15+
}
16+
}
17+
},
18+
"type": "computer"
19+
},
20+
"included": [
21+
{
22+
"attributes": {
23+
"age": 37,
24+
"created_at": "2023-08-31T15:26:43.331089",
25+
"email": "bob@example.com",
26+
"first_name": "Bob",
27+
"last_name": "Green",
28+
"modified_at": "2023-08-31T15:26:43.331092",
29+
"status": "active"
30+
},
31+
"id": "3",
32+
"type": "user"
33+
}
34+
],
35+
"jsonapi": {
36+
"version": "1.0"
37+
},
38+
"meta": null
39+
}
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
POST /users HTTP/1.1
2+
Content-Type: application/vnd.api+json
3+
4+
{
5+
"data": {
6+
"type": "user",
7+
"attributes": {
8+
"first_name": "Bob",
9+
"last_name": "Green",
10+
"age": 37,
11+
"status": "active",
12+
"email": "bob@example.com"
13+
}
14+
}
15+
}

0 commit comments

Comments
 (0)