Skip to content

Commit a4167a9

Browse files
committed
update snippets for person, add get persons
1 parent 5fbf271 commit a4167a9

10 files changed

+60
-6
lines changed

docs/http_snippets/minimal_api__create_person.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,6 @@
1212
],
1313
"postData": {
1414
"mimeType": "application/json",
15-
"text": "{\n\t\"data\": {\n\t\t\"type\": \"person\",\n\t\t\"name\": \"John\"\n\t}\n}"
15+
"text": "{\n\t\"data\": {\n\t\t\"type\": \"person\",\n\t\t\"attributes\": {\n\t\t\t\t\"name\": \"John\"\n\t\t}\n\t}\n}"
1616
}
1717
}
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:5000/persons",
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: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
*.py
Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
POST /persons HTTP/1.1
22
Content-Type: application/vnd.api+json
33
Host: localhost:5000
4-
Content-Length: 54
4+
Content-Length: 78
55

66
{
77
"data": {
88
"type": "person",
9-
"name": "John"
9+
"attributes": {
10+
"name": "John"
11+
}
1012
}
1113
}

docs/http_snippets/snippets/minimal_api__create_person_result

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ Content-Type: application/vnd.api+json
44
{
55
"data": {
66
"attributes": {
7-
"name": null
7+
"name": "John"
88
},
99
"id": "1",
1010
"links": {
Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
GET /persons HTTP/1.1
2+
Content-Type: application/vnd.api+json
3+
Host: localhost:5000
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
HTTP/1.1 200 OK
2+
Content-Type: application/vnd.api+json
3+
4+
{
5+
"data": [
6+
{
7+
"attributes": {
8+
"name": "John"
9+
},
10+
"id": "1",
11+
"links": {
12+
"self": "/persons/1"
13+
},
14+
"type": "person"
15+
}
16+
],
17+
"jsonapi": {
18+
"version": "1.0"
19+
},
20+
"links": {
21+
"first": "http://localhost:5000/persons",
22+
"last": "http://localhost:5000/persons?page%5Bnumber%5D=2",
23+
"next": "http://localhost:5000/persons?page%5Bnumber%5D=2",
24+
"self": "http://localhost:5000/persons"
25+
},
26+
"meta": {
27+
"count": 1
28+
}
29+
}

docs/http_snippets/update_snippets_with_responses.py

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,13 @@ def run_request_for_module(module_name: str):
2626
log.info("Process module %s", module)
2727
response: requests.Response = module.response
2828
log.info("Response %s", response)
29+
2930
http_response_text = []
30-
response_reason = (response.reason or "").title()
31+
32+
response_reason = (response.reason or "")
33+
if response.status_code != HTTPStatus.OK:
34+
response_reason = response_reason.title()
35+
3136
http_response_text.append(
3237
# "HTTP/1.1 201 Created"
3338
"{} {} {}".format(
@@ -36,6 +41,7 @@ def run_request_for_module(module_name: str):
3641
response_reason,
3742
)
3843
)
44+
3945
http_response_text.append(
4046
"{}: {}".format(
4147
"Content-Type",

docs/index.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,7 @@ Flask-COMBO-JSONAPI with Flask.
5151
:maxdepth: 3
5252

5353
installation
54+
minimal_api_example
5455
quickstart
5556
logical_data_abstraction
5657
resource_manager

docs/minimal_api_example.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
21
A minimal API
32
=============
43

0 commit comments

Comments
 (0)