-
Notifications
You must be signed in to change notification settings - Fork 2
/
apiary.apib
111 lines (85 loc) · 3.45 KB
/
apiary.apib
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
FORMAT: 1A
HOST: http://www.google.com
# robert
Robert, User Managment as a Service.
# User
## User [/users]
### List all User [GET]
+ Response 200 (application/json)
[{
"_id": 1234, "email": "foo@bar"
}, {
"_id": 2314, "email": "[email protected]"
}]
### Create a User [POST]
+ Parameters
+ email (required, string, `[email protected]`) ... The user email.
+ password (required, string, `secret`) ... The user password in plain text.
+ other_key (optional, string, `any value`) ... Any other key with any other values, you can put has many as you want here.
+ Request (application/json)
{
"email": "[email protected]",
"password": "secret",
"username": "Bob"
"other_key": "any value"
}
+ Response 201 (application/json)
{
"_id": "48648689460",
"email": "[email protected]",
"username": "Bob",
"other_key" : "any value"
}
### Update a User [PATCH]
All the value but query need to be preceded by a "$" please refer to the request example.
Note that you can also refer to the MongoDB documentation.
+ Parameters
+ query (required, map, `{<field>: <value1>}`) ... The query to find the element to modify.
+ set (optional, map, `{<field1>: <value1>, <field2>: <value2>}`) ... What key set to what field.
+ unset (optional, map, `{<field>: 1, <field2>: ""}`) ... Unset the values of the key <field>, doesn't touch the value of <field2>.
+ push (optional, map, `{<array> : <value1>}`) ... Push the value on the the array.
+ pushAll (optional, map,`{<array>: [<value1>, <value2>]`) ... Push all the values into the array.
+ addToSet (optional, map, `{<set>: <value>}`) ... Add the element to the array if there is not one already.
+ pull (optional, map, `{<arrayField> : <value>, <arrayField> : <query>}`) ... Remove the element who match the query.
+ pop (optional, map, `{ <arrayField>: <-1 | 1> }`) ... Remove the first or the last element of the array.
+ Request (application/json)
{
"query" : {"other_key": "any value"},
"$set" : {"foo": 3, "bar": 5},
"$unset" : {"other": 1, "foo": 0}, // unset the value of the key other, leave untouched the value of foo.
"$push" : {"array1": 5, "array2": "bar"},
"$pushAll" : {"array2": ["foo", 3]},
"$addToSet" : {"array1": "foo", "set2": {"$each" : ["woof", "bar", "meows"]},
"$pull" : {"array2": "meows"},
"$pop" : {"array2": 1, "array2": -1}
}
+ Response 200 (application/json)
{
"_id": "48648689460",
"email": "[email protected]",
"username": "Bob",
"other_key" : "any value",
"foo": 3,
"bar": 5,
"array1": ["foo"],
"array2": ["bar", "foo", 3],
}
## Login [/users/login]
### Make the login of the User [POST]
Need to provide or the password or the username.
+ Parameters
+ password (required, string, `secret`) ... The password of the user.
+ username (optional, string, `Bob`) ... The username of the user.
+ email (optional, string, `[email protected]`) ... The email of the user.
+ Request (application/json)
{
"email": "[email protected]",
"password": "secret"
}
+ Response 200 (application/json)
{
"_id": "48648689460",
"email": "[email protected]",
"username": "Bob",
"other_key" : "any value"
}