Hey gang! Running Moya 11.0.2
So I've run into an interesting situation with a value in a json payload called banner_image, which is usually a String with a path to an image, but it can also sometimes be null
eg (roughly) :
{
"foo": 1234,
"bar": false,
"banner_image": "http://baz.com/image.png"
}
and sometimes:
{
"foo": 1234,
"bar": false,
"banner_image": null
}
I'm not actually using the banner_image and not currently mapping the value in the relevant model within the app. When the banner_image has a value, the request is successful and I decode the response data and carry on.
However, when banner_image returns null, switching on the result fails with the .imageMapping error. EDIT: I found I was still running Moya 9, and after upgrading to Moya 11 it now it returns a parameterMapping error with the message (more or less) "can't do; corrupt data" ;)
I tried mapping the image value to my model with an optional String to see if that would make it happy, but that didn't work.
Curiously, another endpoint in the app also has a value that is sometimes a String, and sometimes null, but this value is called "status":
{
// other keys etc
"status": "woohoo"
}
{
// other keys etc
"status": null
}
I'm also ignoring this status value when decoding a successful response, however the requests don't fail in this case when status is null.
So I'm wondering if there is some smart detection in the inner workings of either Moya or Alamo that recognizes the word image in a json key and attempts to do something (___ ?) and then fails when the value is null?
Not sure how far or close to accurate my assessment is, but if this makes sense to someone, is there a flag or setting or some way to bypass this behavior?
Thanks so much, love love love Moya!
It was something completely unrelated to my (in retrospect) droolings of a madman above. I'm a close minded fool and was blinded by what I conceptualized "imageMapping" to mean. Sorry for the waste of time my Moya friends!
@mossby Glad you could get this one resolved 馃憤 No worries, I make the most outrageous mistakes all the time 馃槅
Most helpful comment
@mossby Glad you could get this one resolved 馃憤 No worries, I make the most outrageous mistakes all the time 馃槅