I noticed recently that whilst servant's MimRender JSON calls encode which calls toEncoding however the swagger tests call toJSON.
https://github.com/haskell-servant/servant/blob/master/servant/src/Servant/API/ContentTypes.hs#L334
https://github.com/GetShopTV/swagger2/blob/master/src/Data/Swagger/Internal/Schema/Validation.hs#L77
The default implementation for toEncoding calls toJSON but there's no requirement for that to be the case. I ended up making my implementations diverge (to make it an error to call toJSON) which meant that the api itself worked but the tests did not pass.
Wondering if the tests here should actually call toEncoding
I noticed recently that whilst servant's
MimRender JSONcallsencodewhich callstoEncodinghowever the swagger tests calltoJSON.https://github.com/haskell-servant/servant/blob/master/servant/src/Servant/API/ContentTypes.hs#L334
https://github.com/GetShopTV/swagger2/blob/master/src/Data/Swagger/Internal/Schema/Validation.hs#L77
The default implementation for
toEncodingcallstoJSONbut there's no requirement for that to be the case. I ended up making my implementations diverge (to make it an error to call toJSON) which meant that the api itself worked but the tests did not pass.Wondering if the tests here should actually call toEncoding