GetShopTV / swagger2

Swagger 2.0 data model.
http://hackage.haskell.org/package/swagger2
BSD 3-Clause "New" or "Revised" License
74 stars 59 forks source link

Should this validate JSON via toEncoding? #240

Open dten opened 2 years ago

dten commented 2 years ago

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