contentful / contentful.swift

A delightful Swift interface to Contentful's content delivery API.
MIT License
202 stars 82 forks source link

Models that conform to Resource and have a member variable named id, breaks resolveLinksArray method #374

Open neptalire94 opened 2 years ago

neptalire94 commented 2 years ago

Hi, I'm reporting this just in case, am not sure if in the docs there's a mention about this, if it is then sorry you can just close this issue.

Models that do conform to EntryDecodable, FieldsKeyQueryable and Resource, if they have id as a member variable it makes an overload of the FlatResource conformance as the id member variable will be overridden, meaning that for instance if you have an array of this class as a member variable of another class, resolveLinksArray will give you an array of NSNull, this is due to the id overload as previously mentioned since:

image

In the for cycle in churnLinks method this linkKey references the sys.id one while:

image

In data cache these entry.id are referencing the id of the model, which in this case if it's overloaded it will not work properly cause the churnLinks method is expecting that the id matches with the sys.id one and will give you an array of NSNulls instead.