-
Notifications
You must be signed in to change notification settings - Fork 1
/
api.raml
120 lines (118 loc) · 4.32 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
#%RAML 1.0
title: demo-jsonapi
description: a sample RESTful API that conforms to jsonapi.org 1.0
version: v1
baseUri: https://columbia-demo-jsonapi.cloudhub.io/{version}/api
documentation:
- title: About {json:api} 1.0
content:
This is an example of a [jsonapi 1.0](http://jsonapi.org/format) RESTful API
which uses mediatype (application/vnd.api+json) in requests and responses.
- title: The jsonApiLibrary (api.*) types
content:
The types defined in library `jsonApiLibrary.raml` are derived directly from the jsonsapi 1.0
[specification](https://github.com/json-api/json-api/blob/gh-pages/schema)
(which is defined using the [json-schema.org](http://json-schema.org/documentation.html) specification).
They were translated from JSON to YAML and then manually edited in several cases where a json:api
capability is not directly available in RAML (for instance, _patternProperties_).
When referencing those types
in your API, you must prefix them with the library name you've given in the `uses` statement. In this example, that
is `api`. For reasons I don't quite understand, you must use this with the same uses key name
(api) in this main api.raml and any other libraries that reference types defined in jsonApiLibrary.raml such
as the WidgetType and LocationType definitions.
- title: The Locations and Widgets types
content:
The Locations and Widget types are the types managed by this sample API. They are all subclasses of the
api.resource type and also subclass api.attributes from the jsonApiLibrary.raml library.
uses:
api: libraries/jsonApiLibrary.raml
loc: libraries/LocationType.raml
wid: libraries/WidgetType.raml
col: libraries/jsonApiCollections.raml
cu: libraries/columbiaLibrary.raml
obj: libraries/ObjectType.raml
# the API's resources:
/widgets:
displayName: widgets
description: stuff we have in inventory
type:
col.collection:
dataType: wid.widgets
exampleCollection: !include examples/WidgetCollectionExample.raml
exampleItem: !include examples/WidgetItemExample.raml
get:
is: [ cu.oauth_read_any, col.all-the-things ]
post:
is: [ cu.oauth_create_any ]
/{id}:
type:
col.item:
dataType: wid.widgets
exampleItem: !include examples/WidgetItemExample.raml
get:
is: [ cu.oauth_read_any, col.sparse ]
patch:
is: [ cu.oauth_update_any ]
delete:
is: [ cu.oauth_delete_any ]
/relationships:
description: widget relationships
# no methods here...
/locations:
description: (many) locations of widgets in inventory
type: col.relationshipCollection
get:
is: [ cu.oauth_read_any, col.all-the-things ]
post:
is: [ cu.oauth_create_any ]
patch:
is: [ cu.oauth_update_any ]
delete:
is: [ cu.oauth_delete_any ]
/manufacturer:
description: (one) manufacturer of the widget
type: col.relationshipItem
get:
is: [ cu.oauth_read_any, col.all-the-things ]
patch:
is: [ cu.oauth_update_any ]
/locations:
displayName: locations
description: inventory locations
type:
col.collection:
dataType: loc.locations
exampleCollection: !include examples/LocationCollectionExample.raml
exampleItem: !include examples/LocationItemExample.raml
get:
is: [ cu.oauth_read_any, col.all-the-things ]
post:
is: [ cu.oauth_create_any ]
/{id}:
type:
col.item:
dataType: loc.locations
exampleItem: !include examples/LocationItemExample.raml
get:
is: [ cu.oauth_read_any, col.sparse ]
patch:
is: [ cu.oauth_update_any ]
delete:
is: [ cu.oauth_delete_any ]
/objects:
displayName: objects
description: The object store persists all the types used above. Use this utility resource
to GET or DELETE the entire contents of the object store.
type:
col.collection:
dataType: obj.objects
exampleCollection: !include examples/ObjectCollectionExample.raml
exampleItem: !include examples/ObjectItemExample.raml
get:
is: [ cu.oauth_read_any ]
delete:
description: DELETES the entire object store
is: [ cu.oauth_delete_any ]
responses:
204:
description: Sucessfully deleted. No content returned.