-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi-documentation.json
162 lines (162 loc) · 5.04 KB
/
api-documentation.json
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
[
[
{
"endpoint_title": "Create User",
"endpoint_url": "http://localhost:3000/users",
"endpoint_description": "Endpoint to create a new user.",
"endpoint_request": "POST",
"request_fields": [
{
"field_name": "username",
"field_description": "The username of the new user."
},
{
"field_name": "email",
"field_description": "The email of the new user."
}
],
"response_fields": [
{
"field_name": "message",
"field_description": "A message indicating the outcome of the operation."
},
{
"field_name": "username",
"field_description": "The username of the created user."
},
{
"field_name": "email",
"field_description": "The email of the created user."
}
],
"response_types": [
{
"response_type": "200",
"response_description": "User created successfully."
},
{
"response_type": "400",
"response_description": "Missing required arguments."
}
],
"request_examples": [
{
"curl_example": "curl -X POST http://localhost:3000/users -d 'username=johndoe&email=johndoe@example.com'",
"python_example": "import requests\n\nurl = 'http://localhost:3000/users'\npayload = {'username': 'johndoe', 'email': 'johndoe@example.com'}\nresponse = requests.post(url, data=payload)\nprint(response.json())",
"nodejs_example": "const axios = require('axios');\n\naxios.post('http://localhost:3000/users', { username: 'johndoe', email: 'johndoe@example.com' })\n .then(response => console.log(response.data))\n .catch(error => console.error(error));"
}
],
"response_example": {
"message": "User created successfully",
"username": "johndoe",
"email": "johndoe@example.com"
}
}
],
[
{
"endpoint_title": "Get Products",
"endpoint_url": "http://localhost:3000/products",
"endpoint_description": "This endpoint retrieves a list of products.",
"endpoint_request": "GET",
"request_fields": [],
"response_fields": [
{
"field_name": "id",
"field_description": "The unique identifier of the product."
},
{
"field_name": "name",
"field_description": "The name of the product."
},
{
"field_name": "price",
"field_description": "The price of the product."
}
],
"response_types": [
{
"response_type": 200,
"response_description": "Success. Returns a list of products."
},
{
"response_type": 401,
"response_description": "Unauthorized. User not authenticated."
},
{
"response_type": 500,
"response_description": "Internal Server Error."
}
],
"request_examples": [
{
"curl_example": "curl http://localhost:3000/products",
"python_example": "requests.get('http://localhost:3000/products')",
"nodejs_example": "axios.get('http://localhost:3000/products')"
}
],
"response_example": "[{ \"id\": 1, \"name\": \"Product A\", \"price\": 10.99 }, { \"id\": 2, \"name\": \"Product B\", \"price\": 19.99 }, { \"id\": 3, \"name\": \"Product C\", \"price\": 7.99 }]"
}
],
[
{
"endpoint_title": "/orders",
"endpoint_url": "http://localhost:3000/orders",
"endpoint_description": "Endpoint to retrieve a list of orders",
"endpoint_request": "GET",
"request_fields": [],
"response_fields": [
{
"field_name": "id",
"field_description": "The unique identifier of the order"
},
{
"field_name": "product",
"field_description": "The name of the product in the order"
},
{
"field_name": "quantity",
"field_description": "The quantity of the product in the order"
}
],
"response_types": [
{
"response_type": "200",
"response_description": "Successful retrieval of orders"
},
{
"response_type": "403",
"response_description": "Forbidden access if user is not authorized"
},
{
"response_type": "500",
"response_description": "Internal Server Error if an error occurs"
}
],
"request_examples": [
{
"curl_example": "curl http://localhost:3000/orders",
"python_example": "requests.get('http://localhost:3000/orders')",
"nodejs_example": "axios.get('http://localhost:3000/orders')"
}
],
"response_example": [
{
"id": 1,
"product": "Product A",
"quantity": 2
},
{
"id": 2,
"product": "Product B",
"quantity": 1
},
{
"id": 3,
"product": "Product C",
"quantity": 3
}
]
}
]
]