-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapi-design.puml
76 lines (76 loc) · 1.99 KB
/
api-design.puml
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
@startmindmap
caption API-Design Considerations
title API Design Considerations
<style>
mindmapDiagram {
.green {
BackgroundColor lightgreen
}
.rose {
BackgroundColor #FFBBCC
}
.lightblue {
BackgroundColor lightblue
}
}
</style>
* API Design
** 1. Resource Oriented Design <<green>>
*** Resource <<lightblue>>
****_ a piece of data
*** Collection <<lightblue>>
****_ a group of resources
*** URL <<lightblue>>
****_ location of resource/Collection
** 2. Use kebab-case for URLs <<green>>
*** bad: <<rose>>
****_ /systemOrders or /system_orders
*** good: <<lightblue>>
****_ /system-orders
** 3. Use camelCase for Parameters <<green>>
*** bad: <<rose>>
****_ /system-orders/{order_id} or /system-orders/{OrderId}
*** good: <<lightblue>>
****_ /system-orders/{orderId}
** 4. Plural name to point to a collection <<green>>
*** bad: <<rose>>
****_ GET /user or GET /User
*** good: <<lightblue>>
****_ GET /users
** 5. URL starts with a Collection and ends with an Identifier <<green>>
*** bad: <<rose>>
****_ GET /shops/:shopId/category/:categoryId/price
*** good: <<lightblue>>
****_ GET /shops/:shopId/ or GET /category/:categoryId
** 6. Keep verbs out of your Resource URL <<green>>
*** bad: <<rose>>
****_ POST /updateuser/{userId} or GET /getusers
*** good: <<lightblue>>
****_ PUT /user/{userId}
** 7. Use verbs for non Resource URL (returns nothing but an operation) <<green>>
*** good: <<lightblue>>
****_ POST /alerts/245743/resend
** 8. Use camelCase for JSON property <<green>>
*** bad: <<rose>>
****_:<code>
{
user_name: "Djiwandou"
user_id: "1"
}
</code>;
*** good: <<lightblue>>
****_:<code>
{
userName: "Djiwandou"
userId: "1"
}
</code>;
** 9. Golden Rules
*** Flat is better than nested <<lightblue>>
*** Simple is better than complex <<lightblue>>
*** Strings are better than number <<lightblue>>
*** Consistency is better than customization <<lightblue>>
legend right
Created using PlantUML
endlegend
@endmindmap