-
Notifications
You must be signed in to change notification settings - Fork 2
/
api.raml
160 lines (137 loc) · 4.98 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
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
#%RAML 1.0
title: Customer Management
version: v1
protocols: [HTTPS]
baseUri: https://api.samplehost.com/api/{version}
mediaType: application/json
description: !
"API specification for managing customers"
securedBy: oauth_2_0
###################
## Security Schemes
###################
securitySchemes:
basic: !include securitySchemes/basic.raml
oauth_2_0: !include securitySchemes/oauth_2_0.raml
###################
## Types
###################
types:
customer:
description: Model for 'Customer' resource
schema: !include schemas/customer.schema
errorResponse:
description: Standard model for all error responses (irrespective of the code)
schema: !include schemas/errorResponse.schema
successResponse:
description: Standard response model for all success responses
schema: !include schemas/successResponse.schema
paginatedResponse:
description: |
Standard model for paginated response.\n
The paginated response contain necessary attributes which will indicate to the consumer how many times they will need to invoke to API to obtain the complete resultset.
schema: !include schemas/paginatedResponse.schema
###################
## Traits
###################
traits:
pageable: !include traits/pageable.raml
sortable: !include traits/sortable.raml
throwsForbiddenError: !include traits/throwsForbiddenError.raml
throwsResourceNotFoundError: !include traits/throwsResourceNotFoundError.raml
throwsInternalServerError: !include traits/throwsInternalServerError.raml
makeConditionalRequests: !include traits/makeConditionalRequests.raml
allowPatch:
description: |
Allow partial modification of <<resourcePathName | !singularize>>
body: <<examplePatchResourceBody>>
responses:
204:
description: Return the updated <<resourcePathName | !singularize>> resource
body:
application/json:
example: <<patchResourceResponseExample>>
type: <<patchResourceResponseType>>
###################
## Resource Types
###################
resourceTypes:
collectionType: !include resourceTypes/collection.raml
resourceType: !include resourceTypes/resource.raml
###################
## API Definitions
###################
/customers:
displayName: Customer collection
description: Set of APIs to manage Customer resource.
type: {
collectionType:
{
examplePaginatedResponseExample : !include examples/getCustomerPaginatedResponse-example.json,
examplePaginatedResponseType: paginatedResponse,
createResourceRequestExample : !include examples/customer-example.json,
createResourceRequestType: customer,
createResourceResponseExample: !include examples/createCustomerResponse-example.json,
createResourceResponseType: successResponse,
createResourceBadRequestExample: !include examples/400-createCustomerBadRequest-example.json
}
}
get:
is: [pageable,sortable]
description: |
Retrieve all customers. When query parameters are ommited, the API calls returns all customers. Using the optional query
parameters, the result set could be narrowed further to the matching customers.
queryParameters:
firstName:
required: false
description: First name of customer
type: string
example: John
lastName:
required: false
description: Last name of customer
type: string
example: Smith
address.streetLine1:
required: false
description: Fuzzy search on street line 1
type: string
example: George Street
address.streetLine2:
required: false
description: Fuzzy search on street line 2
type: string
example: Mountain%20Street
address.city:
required: false
description: Fuzzy search address
type: string
example: Sydney, Bellevue%20Hill, Potts%20Point
address.postCode:
required: false
description: Exact search by postcode
type: string
example: 2000, 214
/{customerId}:
displayName: Customer resource
securedBy: oauth_2_0
description: Operations on individual Customer resource
type: {
resourceType:
{
updateResourceRequestExample : !include examples/customer-example.json,
updateResourceRequestType: customer,
updateResourceResponseExample: !include examples/customer-example.json,
updateResourceResponseType: customer,
getSingleResourceExample: !include examples/customer-example.json,
getSingleResourceType: customer
}
}
get:
is: [ makeConditionalRequests]
patch:
is: [allowPatch: {
examplePatchResourceBody : !include examples/patchCustomer-example.json,
patchResourceResponseExample : !include examples/customer-example.json,
patchResourceResponseType : customer
}]