Skip to content

Adds Swift `Identifiable` conformance to `ResourceObject`

Pre-release
Pre-release
Compare
Choose a tag to compare
@mattpolzin mattpolzin released this 29 May 21:57
8aa20f3

In order to reduce the burden of conflict on users of the library, JSONAPI.Identifiable has been renamed to JSONAPIIdentifiable and (for all platforms that support it) conformance to Swift.Identifiable has been added to ResourceObject.

⚠️ Breaking Changes ⚠️
Sorry to introduce a breaking change during the release candidates. Conformance to Swift.Identifiable is really beneficial, especially if you ever pull a model into SwiftUI.

  • Renamed Identifiable -> JSONAPIIdentifiable
  • Renamed JSONAPIIdentifiable's Identifier associated type to ID to match that of the Swift Identifiable type.
  • Removed ResourceObject.Id (i.e. consolidated so that the same type alias as is used by JSONAPIIdentifiable and Swift.Identifiable is just named ResourceObject.ID). Otherwise there is a confusing co-existence of both ResourceObject.ID and ResourceObject.Id.
  • [EDIT] As of the soon-to-be-released 4.0.0-rc.3.2, I will have re-introduced ResourceObject.Id which means that ResourceObject.ID and ResourceObject.Id will be equally valid. Not crazy about it, but no easy and satisfactory way to deal with it before the release of 4.0.0.

Suggested approach to updating code:

  1. Anywhere you are using JSONAPI.Identifiable, find JSONAPI.Identifiable or Identifiable (careful not to pick up on Swift Identifiable in your codebase) and replace with JSONAPIIdentifiable.
  2. Anywhere you are using Identifier() or Id() in the context of a ResourceObject to construct its ID, replace with ID(). [EDIT] As of 4.0.0-rc.3.2 ResourceObject.ID and ResourceObject.Id will both be equally valid.