Skip to content

Commit de4f2e3

Browse files
committed
Update JSON API naming to be consistent
1 parent 966f3c5 commit de4f2e3

File tree

1 file changed

+17
-18
lines changed

1 file changed

+17
-18
lines changed

README.md

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -117,7 +117,7 @@ Whether the component should be enabled or disabled. Defaults to `true`, flip it
117117

118118
### handleErrors
119119
When true, the component will unregister all other error handling and
120-
register a custom error handler which always returns errors in jsonapi compliant
120+
register a custom error handler which always returns errors in JSON API compliant
121121
format. Validation errors include the correct properties in order to work
122122
out of the box with EmberJS.
123123

@@ -137,10 +137,10 @@ out of the box with EmberJS.
137137
Allows blacklisting of models and methods.
138138
Define an array of blacklist objects. Blacklist objects can contain "model" key
139139
"methods" key or both. If just "model" is defined then all methods for the
140-
specified model will not be serialized of deserialized using jsonapi. If just the "methods" key is defined then
141-
all methods specified on all models will be serialized or deserialized using jsonapi. If a combination of
140+
specified model will not be serialized of deserialized using JSON API. If just the "methods" key is defined then
141+
all methods specified on all models will not be serialized or deserialized using JSON API. If a combination of
142142
"model" and "methods" keys are used then the specific combination of model and methods
143-
specified will not be serialized or deserialized using jsonapi.
143+
specified will not be serialized or deserialized using JSON API.
144144

145145
#### example
146146
```js
@@ -160,8 +160,7 @@ specified will not be serialized or deserialized using jsonapi.
160160
- Default: `null`
161161

162162
#### Note
163-
The default component behavior is to modify the output of the following CRUD model methods
164-
methods on all models:
163+
The default behavior is to modify (serialize to JSON API) the output of the following CRUD methods on all models:
165164
- `find`
166165
- `create`
167166
- `updateAttributes`
@@ -172,20 +171,20 @@ In addition the following wild card method names are matched and the output is m
172171
- `__get__.*`
173172
- `__findRelationships__.*`
174173

175-
The default behavior for modifying input only applies to the following methods on all models:
174+
The default behavior is to modify (deserialize from JSON API) the input to the following CRUD methods on all models:
176175
- `create`
177176
- `updateAttributes`
178177

179178
### include
180179
Allows whitelisting of methods.
181180
Define an array of whitelist objects. Whitelist objects can contain a "methods" key
182181
or both a "models" key and a "methods" key. If just the "methods" key is defined then
183-
the methods specified will be serialized or deserialized using jsonapi on all models that have
182+
the methods specified will be serialized or deserialized using JSON API on all models that have
184183
the specified methods. If a combination of
185184
"model" and "methods" keys are used then the specific combination of model and methods
186-
specified will be serialized or deserialized using jsonapi.
185+
specified will be serialized or deserialized using JSON API.
187186

188-
Note: objects returned from a remote method that will be jsonapi serialized MUST include
187+
Note: objects returned from a remote method that will be JSON API serialized MUST include
189188
an id property. id property can be null.
190189

191190
#### example
@@ -206,7 +205,7 @@ an id property. id property can be null.
206205

207206
### hideIrrelevantMethods
208207
By default, `loopback-component-jsonapi` disables a number of methods from each endpoint
209-
that are not jsonapi relevant. These methods are:
208+
that are not JSON API relevant. These methods are:
210209
- `upsert`
211210
- `exists`
212211
- `findOne`
@@ -215,7 +214,7 @@ that are not jsonapi relevant. These methods are:
215214
- `updateAll`
216215

217216
You can use this option to prevent `loopback-component-jsonapi` from doing so. These methods are not modified by the component. Their output
218-
will not be in a jsonapi compliant format.
217+
will not be in a JSON API compliant format.
219218

220219
#### example
221220
```js
@@ -230,7 +229,7 @@ will not be in a jsonapi compliant format.
230229
- Default: `true`
231230

232231
### attributes
233-
By default, model properties will be converted to attributes in jsonapi terms.
232+
By default, model properties will be converted to attributes in JSON API terms.
234233
All model properties except the primary key and any foreign keys will be copied into
235234
the attributes object before output. If you wish to limit which properties will
236235
be output as attributes you can specify a whitelist of attributes for each type.
@@ -251,7 +250,7 @@ be output as attributes you can specify a whitelist of attributes for each type.
251250
- Default: `null`
252251

253252
#### note
254-
The attributes arrays are keyed by type not by model name. Type is the term used by json api to describe the resource type in question and while not required by json api it is usually plural. In `loopback-component-jsonapi` it is whatever the models `plural` is set to in `model.json`. So in our example above we defined: `"posts": ["title", "content"]` as the resource type for the `post` model is `posts`
253+
The attributes arrays are keyed by type not by model name. Type is the term used by JSON API to describe the resource type in question and while not required by JSON API it is usually plural. In `loopback-component-jsonapi` it is whatever the models `plural` is set to in `model.json`. So in our example above we defined: `"posts": ["title", "content"]` as the resource type for the `post` model is `posts`
255254

256255
## Custom Serialization
257256
For occasions where you need greater control over the serialization process, you can implement a custom serialization function for each model as needed. This function will be used instead of the regular serialization process.
@@ -312,7 +311,7 @@ module.exports = function (MyModel) {
312311

313312
###### `options.type`
314313
Resource type. Originally calculated from a models plural. Is used in the default
315-
serialization process to set the type property for each model in a jsonapi response.
314+
serialization process to set the type property for each model in a JSON API response.
316315
- eg. `posts`
317316

318317
###### `options.method`
@@ -342,11 +341,11 @@ The api prefix used before resource information. Can be used in conjunction with
342341
- eg. `/api`
343342

344343
###### `options.topLevelLinks`
345-
JSON API links object used at the top level of the JSON API response structure.
344+
Links object used at the top level of the JSON API response structure.
346345
- eg. `{links: {self: 'http://localhost:3000/api/posts'}}`
347346

348347
###### `options.dataLinks`
349-
links object used to generate links for individual resource items. The structure is
348+
Links object used to generate links for individual resource items. The structure is
350349
and object with JSON API link keys such as `self` or `related` that are defined as
351350
a function that will be called for each resource.
352351

@@ -372,7 +371,7 @@ definition. An object with relationship name keys, each having properties:
372371
- `keyFrom` name of key on from model
373372
- `type` type of relationship (belongsTo, hasOne, hasMany)
374373

375-
This information is used to build relationship urls and even setup side loaded
374+
This information is used to build relationship urls and even setup side-loaded
376375
data correctly during the serialization process.
377376

378377
eg.

0 commit comments

Comments
 (0)