- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexample.html
More file actions
512 lines (506 loc) · 16.8 KB
/
example.html
File metadata and controls
512 lines (506 loc) · 16.8 KB
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
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
<html>
<head>
<meta charset="utf-8">
<meta content="width=device-width, initial-scale=1, shrink-to-fit=no" name="viewport">
<title>Phone directory CRUD API</title>
<link href="https://stackpath.bootstrapcdn.com/bootstrap/4.1.3/css/bootstrap.min.css" rel="stylesheet" type="text/css">
<link href="https://raw.githubusercontent.com/google/code-prettify/master/styles/desert.css" type="text/css">
<style>
/* Prettify CSS styles. */
pre {
white-space: pre-line;
white-space: pre-wrap; /* Since CSS 2.1 */
white-space: -moz-pre-wrap; /* Mozilla, since 1999 */
white-space: -pre-wrap; /* Opera 4-6 */
white-space: -o-pre-wrap; /* Opera 7 */
word-wrap: break-word; /* Internet Explorer 5.5+ */
}
/* desert scheme ported from vim to google prettify */
pre.prettyprint {
font-family: monospace;
font-size: 13px;
background-color: #1e1e1e;
border: 0 !important;
margin-bottom: 0px;
}
pre .nocode { background-color: none; color: #000 }
pre .str { color: #ffa0a0 } /* string - pink */
pre .kwd { color: #f0e68c; font-weight: bold }
pre .com { color: #87ceeb } /* comment - skyblue */
pre .typ { color: #98fb98 } /* type - lightgreen */
pre .lit { color: #cd5c5c } /* literal - darkred */
pre .pun { color: #fff } /* punctuation */
pre .pln { color: #fff } /* plaintext */
pre .tag { color: #f0e68c; font-weight: bold } /* html/xml tag - lightyellow */
pre .atn { color: #bdb76b; font-weight: bold } /* attribute name - khaki */
pre .atv { color: #ffa0a0 } /* attribute value - pink */
pre .dec { color: #98fb98 } /* decimal - lightgreen */
/* Specify class=linenums on a pre to get line numbering */
ol.linenums { margin-top: 0; margin-bottom: 0; color: #AEAEAE } /* IE indents via margin-left */
li.L0,li.L1,li.L2,li.L3,li.L5,li.L6,li.L7,li.L8 { list-style-type: none }
/* Alternate shading for lines */
li.L1,li.L3,li.L5,li.L7,li.L9 { }
@media print {
pre.prettyprint { background-color: none }
pre .str, code .str { color: #060 }
pre .kwd, code .kwd { color: #006; font-weight: bold }
pre .com, code .com { color: #600; font-style: italic }
pre .typ, code .typ { color: #404; font-weight: bold }
pre .lit, code .lit { color: #044 }
pre .pun, code .pun { color: #440 }
pre .pln, code .pln { color: #000 }
pre .tag, code .tag { color: #006; font-weight: bold }
pre .atn, code .atn { color: #404 }
pre .atv, code .atv { color: #060 }
}
/* Other CSS styles. */
.example {
font-family: monospace;
}
body {
background: #252526;
color: white;
}
.card {
-webkit-box-shadow: 0px 2px 4px 0px rgba(0,0,0,1);
-moz-box-shadow: 0px 2px 4px 0px rgba(0,0,0,1);
box-shadow: 0px 2px 4px 0px rgba(0,0,0,1);
}
</style>
</head>
<body>
<div class="container">
<h1 class="display-4 mt-3">Phone directory CRUD API</h1>
<div class="card border-0 mb-3 bg-dark">
<div class="card-body">
<p class="card-text lead">This is an example CRUD for a phone directory JSON API REST, it includes some of the most basic database operations like creating, reading, updating and deleting (CRUD).</p>
<p><b>Endpoint:</b><code> http://crud.host</code></p>
<h1>Status codes</h1>
<table class="table table-dark table-striped table-bordered">
<thead>
<tr>
<th>Status code</th>
<th>Reason</th>
<th>Meaning</th>
</tr>
</thead>
<tbody>
<tr>
<td>200</td>
<td>OK</td>
<td>Your request was successful.</td>
</tr>
<tr>
<td>400</td>
<td>Bad Request</td>
<td>Your request is invalid.</td>
</tr>
<tr>
<td>401</td>
<td>Unauthorized</td>
<td>The access token is wrong or missing.</td>
</tr>
<tr>
<td>404</td>
<td>Not Found</td>
<td>The phone number could not be found.</td>
</tr>
<tr>
<td>405</td>
<td>Method Not Allowed</td>
<td>You tried to access to a route with an invalid method.</td>
</tr>
<tr>
<td>500</td>
<td>Internal Server Error</td>
<td>We had a problem with our server. Try again later.</td>
</tr>
</tbody>
</table>
<h1>Index</h1>
<ol>
<li><code><b>POST</b><span> <span>/api/phone </span></span></code><a class="text-white" href="#0">Create a phone number</a></li>
<li><code><b>GET</b><span> <span>/api/phone </span></span></code><a class="text-white" href="#1">Get all phone numbers</a></li>
<li><code><b>GET</b><span> <span>/api/phone/{id} </span></span></code><a class="text-white" href="#2">Get specific phone number</a></li>
<li><code><b>PUT</b><span> <span>/api/phone/{id} </span></span></code><a class="text-white" href="#3">Update phone number</a></li>
<li><code><b>DELETE</b><span> <span>/api/phone/{id} </span></span></code><a class="text-white" href="#4">Delete phone number</a></li>
</ol>
</div>
</div>
<div class="card border-0 mb-3 bg-dark" id="0">
<div class="card-header">
<h1 class="display-5">1. Create a phone number</h1>
</div>
<div class="card-body">
<p class="card-text lead">Insert a phone number into database.</p>
<h3>URL</h3>
<p>
<code>
<b>POST</b>
<span>http://crud.host/api/phone</span>
</code>
</p>
<h3>Parameters</h3>
<div class="table-responsive-sm">
<table class="table table-dark table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>name</td>
<td>string</td>
<td>Yes</td>
<td>Name of the phone number owner.</td>
</tr>
<tr>
<td>phone</td>
<td>string</td>
<td>Yes</td>
<td>Phone number of the owner.</td>
</tr>
</tbody>
</table>
</div>
<h3>Examples</h3>
<span class="card-text lead">Request</span>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<b>POST</b>
<b>/api/phone</b>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Authorization: Bearer [access token]</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>Accept: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">{
"name":"Andrés Trump",
"phone":"+52 461 111 1111",
}</pre>
</code>
</td>
</tr>
</table>
<span class="card-text lead">Response</span>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<span>200 OK</span>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">{
"success": true
}</pre>
</code>
</td>
</tr>
</table>
</div>
</div>
<div class="card border-0 mb-3 bg-dark" id="1">
<div class="card-header">
<h1 class="display-5">2. Get all phone numbers</h1>
</div>
<div class="card-body">
<p class="card-text lead">Retrieve all the phone numbers in the database.</p>
<h3>URL</h3>
<p>
<code>
<b>GET</b>
<span>http://crud.host/api/phone</span>
</code>
</p>
<h3>Examples</h3>
<span class="card-text lead">Response</span>
<p>Example of response</p>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<span>200 OK</span>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">[
{
"id": 1,
"name": "Andrés Trump",
"phone": "+52 461 111 1111"
},
{
"id": 2,
"name": "Margarita Clinton",
"phone": "+52 461 111 2233"
},
{
"id": 3,
"name": "Donald John López Obrador"
"phone": "+1 628 222 3344"
}
]</pre>
</code>
</td>
</tr>
</table>
</div>
</div>
<div class="card border-0 mb-3 bg-dark" id="2">
<div class="card-header">
<h1 class="display-5">3. Get specific phone number</h1>
</div>
<div class="card-body">
<p class="card-text lead">Retrieve a single phone number from the database.</p>
<h3>URL</h3>
<p>
<code>
<b>GET</b>
<span>http://crud.host/api/phone/{id}</span>
</code>
</p>
<h3>Parameters</h3>
<div class="table-responsive-sm">
<table class="table table-dark table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>int</td>
<td></td>
<td>ID of the existing phone number</td>
</tr>
</tbody>
</table>
</div>
<h3>Examples</h3>
<span class="card-text lead">Response</span>
<p>Example response</p>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<span>200 OK</span>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">{
"id": 1,
"name": "Andrés Trump",
"phone": "+52 461 111 1111"
}</pre>
</code>
</td>
</tr>
</table>
</div>
</div>
<div class="card border-0 mb-3 bg-dark" id="3">
<div class="card-header">
<h1 class="display-5">4. Update phone number</h1>
</div>
<div class="card-body">
<p class="card-text lead">Edit existing phone number in database.</p>
<h3>URL</h3>
<p>
<code>
<b>PUT</b>
<span>http://crud.host/api/phone/{id}</span>
</code>
</p>
<h3>Parameters</h3>
<div class="table-responsive-sm">
<table class="table table-dark table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>int</td>
<td></td>
<td>ID of the existing phone number.</td>
</tr>
<tr>
<td>name</td>
<td>string</td>
<td></td>
<td>Name of the phone number owner.</td>
</tr>
<tr>
<td>phone</td>
<td>string</td>
<td></td>
<td>Phone number of the owner.</td>
</tr>
</tbody>
</table>
</div>
<h3>Examples</h3>
<span class="card-text lead">Request</span>
<p>Example request</p>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<b>PUT</b>
<b>/api/phone/{id}</b>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Authorization: Bearer [access token]</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>Accept: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">{
"name": "Enrique Peña Bush",
"phone": "+1 628 000 3355",
}</pre>
</code>
</td>
</tr>
</table>
<span class="card-text lead">Response</span>
<p>Example response</p>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<span>200 OK</span>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">{
"success": true
}</pre>
</code>
</td>
</tr>
</table>
</div>
</div>
<div class="card border-0 mb-3 bg-dark" id="4">
<div class="card-header">
<h1 class="display-5">5. Delete phone number</h1>
</div>
<div class="card-body">
<p class="card-text lead">Remove existing phone number from database permanently.</p>
<h3>URL</h3>
<p>
<code>
<b>DELETE</b>
<span>http://crud.host/api/phone/{id}</span>
</code>
</p>
<h3>Parameters</h3>
<div class="table-responsive-sm">
<table class="table table-dark table-striped table-bordered">
<thead>
<tr>
<th>Name</th>
<th>Type</th>
<th>Optional</th>
<th>Description</th>
</tr>
</thead>
<tbody>
<tr>
<td>id</td>
<td>int</td>
<td></td>
<td>ID of existing phone number</td>
</tr>
</tbody>
</table>
</div>
<h3>Examples</h3>
<span class="card-text lead">Response</span>
<p>Example response</p>
<table class="table table-sm table-borderless table-dark example">
<tr>
<td>
<span>200 OK</span>
<span>HTTP/1.1</span>
</td>
</tr>
<tr>
<td>Content-Type: application/json</td>
</tr>
<tr>
<td>
<code>
<pre class="prettyprint">{
"success": true
}</pre>
</code>
</td>
</tr>
</table>
</div>
</div>
</div>
<footer>
<div class="container py-5">
<p class="mb-0 text-uppercase font-weight-bold small text-justify">
<a class="text-muted float-right" href="https://github.com/ivan-avalos/api-documenter" rel="noopener">Documentation generated with api-documenter</a>
</p>
</div>
</footer>
<script src="https://cdn.rawgit.com/google/code-prettify/master/loader/run_prettify.js"></script>
</body>
</html>