@@ -136,18 +136,18 @@ the client and represents a new resource to be created on the server.
136
136
137
137
In addition, a resource object ** MAY** contain any of these top-level members:
138
138
139
- * ` "links" ` : information about a resource's relationships (described
140
- below).
139
+ * ` "links" ` : a "links object", providing information about a resource's
140
+ relationships (described below).
141
141
* ` "meta" ` : non-standard meta-information about a resource that can not be
142
142
represented as an attribute or relationship.
143
143
144
144
Any other top-level member in a resource object represents an "attribute".
145
145
An attribute may contain any valid JSON value.
146
146
147
- > Note: Although has-one foreign keys are often stored as columns in a
148
- database alongside other fields, foreign keys ** MUST NOT ** be included in a
149
- resource's attributes. All relations ** MUST** be represented under a
150
- resource's links object, as described below.
147
+ Although has-one foreign keys (e.g. ` author_id ` ) are often stored internally
148
+ alongside other information to be represented in a resource object, these keys
149
+ * SHOULD NOT * appear as attributes. If relations are provided, they ** MUST**
150
+ be represented under the " links object" , as described below.
151
151
152
152
Here's how an article (i.e. a resource of type "articles") might appear in a document:
153
153
@@ -156,7 +156,15 @@ Here's how an article (i.e. a resource of type "articles") might appear in a doc
156
156
{
157
157
" type" : " articles" ,
158
158
" id" : " 1" ,
159
- " title" : " Rails is Omakase"
159
+ " title" : " Rails is Omakase" ,
160
+ " links" : {
161
+ " author" : {
162
+ " self" : " /articles/1/links/author" ,
163
+ " related" : " /articles/1/author" ,
164
+ " type" : " people" ,
165
+ " id" : " 9"
166
+ }
167
+ }
160
168
}
161
169
// ...
162
170
```
@@ -186,7 +194,7 @@ consistently throughout an implementation.
186
194
Each resource object ** MUST** contain an ` id ` member, whose value ** MUST**
187
195
be a string.
188
196
189
- #### Links
197
+ #### Links < a href = " #document-structure-links " id = " document-structure-links " class = " headerlink " ></ a >
190
198
191
199
The value of the ` "links" ` key is a JSON object (a "links object") that
192
200
represents related resources, keyed by the name of each association.
0 commit comments