Skip to content

Should this validate JSON via toEncoding? #240

@dten

Description

@dten

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions