-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapi.raml
83 lines (76 loc) · 2.62 KB
/
api.raml
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
#%RAML 1.0
---
title: Drivers
baseUri: https://desolate-basin-87139.herokuapp.com/api
description: |
This is a go-kit powered micro-service, called Drivers.
It serves REST-like API. This API provides only one resource, which is Driver.
Example Driver {"id":1, "name":"JohnDoe", "license_number":"11-222-33"}.
/import:
post:
description: |
Import a batch of drivers.
For driver from a batch, would be applied upsert if there is an existing record with the same id in the database.
Accepts json body with an array of drivers. Array size should be from 1 to 1000 elements
Driver fields:
* "id" is an uint64, must be greater thet 0
* "name" is a string, length must be from 3 to 1000 UTF-8 symbols
* "license_number" is a string, must match `^[0-9]{2}-[0-9]{3}-[0-9]{2}$`
body:
application/json:
example: |
[{
"id": 1,
"name": "John Doe",
"license_number": "11-222-33"
}]
responses:
200: ok
body:
application/json:
example: {}
400:
description: validation error
body:
application/json:
example: {"error":"status=400, error=invalid collection length; collection drivers should be from 1 to 1000 elements, but not 0"}
409:
description: insertion error
body:
application/json:
example: {"error":"status=409, error=Key (license_number)=(11-222-33) already exists."}
500:
description: something yet unhandled or something really wrong
body:
application/json:
example: {"error": "status=500 error=pq: Could not complete operation in a failed transaction"}
/driver/{id}:
get:
description: |
Get a driver by id.
"id" is a uint64, should be greater then 0.
responses:
200:
body:
application/json:
example: |
{
"id":1,
"name": "JohnDoe",
"license_number": "11-222-33"
}
400:
description: validation error
body:
application/json:
example: {"error":"status=400, error=invalid id; should be greater then 0"}
404:
description: search error
body:
application/json:
example: {"error":"status=404, error=driver with id=3 is not found"}
500:
description: something yet unhandled or something really wrong
body:
application/json:
example: {"error": "status=500 error=pq: Could not complete operation in a failed transaction"}