Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Should this validate JSON via toEncoding? #240

Open
dten opened this issue Jul 20, 2022 · 0 comments
Open

Should this validate JSON via toEncoding? #240

dten opened this issue Jul 20, 2022 · 0 comments

Comments

@dten
Copy link

dten commented Jul 20, 2022

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant