You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+7-7Lines changed: 7 additions & 7 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -80,7 +80,7 @@ Note that Playground support for importing non-system Frameworks is still a bit
80
80
81
81
In this documentation, in order to draw attention to the difference between the `JSONAPI` framework (this Swift library) and the **JSON API Spec** (the specification this library helps you follow), the specification will consistently be referred to below as simply the **SPEC**.
82
82
83
-
### `EntityDescription`
83
+
### `JSONAPI.EntityDescription`
84
84
85
85
An `EntityDescription` is the `JSONAPI` framework's representation of what the **SPEC** calls a *Resource Object*. You might create the following `EntityDescription` to represent a person in a network of friends:
86
86
@@ -136,7 +136,7 @@ This readme doesn't go into detail on the **SPEC**, but the following *Resource
136
136
}
137
137
```
138
138
139
-
### `Entity`
139
+
### `JSONAPI.Entity`
140
140
141
141
Once you have an `EntityDescription`, you _create_, _encode_, and _decode_`Entities` that "fit the description". If you have a `CreatableRawIdType` (see the section on `RawIdType`s below) then you can create new `Entities` that will automatically be given unique Ids, but even without a `CreatableRawIdType` you can encode, decode and work with entities.
Note that I am assuming an unidentified person is a "new" person. I suspect that is generally an acceptable conflation because the only time the **SPEC** allows a *Resource Object* to be encoded without an `Id` is when a client is requesting the given *Resource Object* be created by the server and the client wants the server to create the `Id` for that object.
184
184
185
-
### `Relationships`
185
+
### `JSONAPI.Relationships`
186
186
187
187
There are two types of `Relationships`: `ToOneRelationship` and `ToManyRelationship`. An `EntityDescription`'s `Relationships` type can contain any number of `Relationship` properties of either of these types. Do not store anything other than `Relationship` properties in the `Relationships` struct of an `EntityDescription`.
let friendIds: [Person.Identifier] = person ~> \.friends
202
202
```
203
203
204
-
### `Attributes`
204
+
### `JSONAPI.Attributes`
205
205
206
206
The `Attributes` of an `EntityDescription` can contain any JSON encodable/decodable types as long as they are wrapped in an `Attribute`, `ValidatedAttribute`, or `TransformedAttribute``struct`.
207
207
@@ -271,13 +271,13 @@ public var fullName: Attribute<String> {
271
271
}
272
272
```
273
273
274
-
### `JSONAPIDocument`
274
+
### `JSONAPI.Document`
275
275
276
-
The entirety of a JSON API request or response is encoded or decoded from- or to a `JSONAPIDocument`. As an example, a JSON API response containing one `Person` and no included entities could be decoded as follows:
276
+
The entirety of a JSON API request or response is encoded or decoded from- or to a `Document`. As an example, a JSON API response containing one `Person` and no included entities could be decoded as follows:
277
277
```
278
278
let decoder = JSONDecoder()
279
279
280
-
let responseStructure = JSONAPIDocument<SingleResourceBody<Person>, NoMetadata, NoLinks, NoIncludes, UnknownJSONAPIError>.self
280
+
let responseStructure = JSONAPI.Document<SingleResourceBody<Person>, NoMetadata, NoLinks, NoIncludes, UnknownJSONAPIError>.self
281
281
282
282
let document = try decoder.decode(responseStructure, from: data)
0 commit comments