Releases: mattpolzin/JSONAPI
Breaking change - Rename `type` to `jsonType`
JSONTyped
had a static var type: String
that unnecessarily collided with Swift.type(of:)
. I renamed it to static var jsonType: String
so to avoid the collision and save the minor headache. This is a breaking change.
Add `including()` methods to `Document`
Document
gains including()
method that allows you to easily add includes to the document (or more accurately create a new Document with the given includes added to it). There are actually two variants of this method:
- Take a
Document
withIncludeType
ofNoIncludes
and map it to aDocument
with the given includes in whatever new type you would like. - Take a
Document
withIncludeType
other thanNoIncludes
and add more of the same type of includes to it.
Breaking change to split Attribute out into its own Type.
Realistically, this should not break very much code, but it technically has the potential to require some changes.
Attribute
used to be a typealias
to TransformedAttribute
with an IdentityTransformer
. Now, Attribute
is its own Type. Although it is a bit sad to see a new Type created where a typealias used to suffice, the benefit of Attribute
being its own Type is that the use of it is much more concise. Instead of Attribute
offering initialization and containing Type information only relevant to TransformedAttribute
, it will not have a cleaner interface.
Add ability to append/merge Includes, ManyResourceBody, and Document.Body.Data
You can now append two Includes
values or ManyResourceBody
values.
You can also merge two Document.Body.Data
values.
Add `Include8` and `Include9` types
Support including up to 9 different types of entities in JSONAPI documents.
Add documentation around custom keys and encoding/decoding for Attributes
0.11.2 Add convenience method for default decoding of attributes. add tests …
Remove Codable constraint on proxies
This non-breaking change allows you to create EntityProxies
that have Attributes
or Relationships
that are not Codable
. The idea behind a proxy in this context is to be able to create a more convenient representation in code of something that does not need to be directly encoded or decoded.
Add convenient copy methods to Entity
- [Breaking] Rename
Document.Body.primaryData
toDocument.Body.primaryResource
. - Add
Entity.identified(by:)
(create identified copy of unidentified Entity with the given Id). - Add
Entity.Identified(byType:)
(create identified copy of unidentified Entity with the given Id Type). - Add
Entity.withNewIdentifier()
(create a copy of an identified Entity with a new Id).
Remove cruft, add to TestLib
I Removed the many many convenience initializers on Entity and Document. They appeared to be causing the compiler strife and there was a confusing number of them available at any one time. The recommendation is to provide convenience initializers on a per-need basis instead if they offer a lot of utility to you; you can even copy the existing convenience accessors right out of the library (they are just commented out).
I also added the ability to initialize nullable attributes with literals when their wrapped type could also be initialized from that literal.
Important bug fixes and nice features
- Added
Pointer
typealias
forToOneRelationship
with no meta or links. - Added some missing
Entity
initializers. - Added
Poly7
/Include7
. - Added relationship operator
~>
support for optional relationships. - Added subscript access to attributes that are not
AttributeType
(so that computed properties do not need to beAttributeType
. - Made it possible to add
Relationships
to values that are notEntityType
. - Fixed encoding bug when
Relationship
is nullable (not optional, but nullable).