bustoutsolutions / siesta

The civilized way to write REST API clients for iOS / macOS
https://bustoutsolutions.github.io/siesta/
MIT License
2.19k stars 159 forks source link

Mapping Response as Models #49

Closed gthrb22 closed 8 years ago

gthrb22 commented 8 years ago

How to configure transformer for the service with models service().configureTransformer("/data/2.5/forecast/city?id=524901&APPID=fbb20b6f256459684791c9be06a8ce20") { ($0.content as JSON).arrayValue.map(ObjectModel.init) } I tried something like this but it gives cannot parse server response expected JSON but actual dictionary

pcantrell commented 8 years ago

If you want a SwiftJSON JSON object instead of a dictionary, you need to configure that. See the example project:

https://github.com/bustoutsolutions/siesta/blob/master/Examples/GithubBrowser/Source/API/GithubAPI.swift#L23 https://github.com/bustoutsolutions/siesta/blob/master/Examples/GithubBrowser/Source/API/GithubAPI.swift#L86-L88