wvteijlingen / Spine

A Swift library for working with JSON:API APIs. It supports mapping to custom model classes, fetching, advanced querying, linking and persisting.
MIT License
264 stars 109 forks source link

Cannot fetch relationships having key which contains an underscore. #158

Closed PanagiotisVakalis closed 7 years ago

PanagiotisVakalis commented 7 years ago

Hello, I am sending a GET request using ?include=request_type. On my class I have created a variable called requestType: Resource? and in the fieldsFromDictionary I have set "requestType": ToOneRelationship(RequestType.self) The RequestType class has a resourceType of "request-types".

In the include I am using the "requestType"

The JSON which I am receiving contains the request-type with dash and not underscore. As a result I get no value for the requestType variable.

Finally I have used the UnderscoredKeyFormatter.

The main issue is that the include in the url contains an underscore while the key contains a dash.

How can I overcome this type of issue with the underscore and the dash?