servant icon indicating copy to clipboard operation
servant copied to clipboard

validateEveryToJSON ignores new response handlers

Open mossprescott opened this issue 3 years ago • 1 comments

validateEveryToJSON silently ignores any endpoints in the API type that use anything other than the built-in Verb and ReqBody types. See below for context.

Note: this issue was originally reported against in the servant-swagger repo (https://github.com/haskell-servant/servant-swagger/issues/68), with some comments in favor of fixing it. As far as I can tell, the same code exists in the PR merging the code into this repo: https://github.com/haskell-servant/servant/blob/fed9e99a99d2ca113a0b8d012921782ff93c563f/servant-swagger/src/Servant/Swagger/Internal/TypeLevel/API.hs#L85

Reporting the issue here for (re-)consideration.

We’ve implemented a new handler (for streaming responses) by providing instances of HasServer, HasClient, Accept, and HasSwagger. This works reasonably well, but now we've run into an issue where the type-level machinery used by validateEveryToJSON (i.e. BodyTypes) can’t be extended in a similar way, and in fact it silently ignores endpoints that use the new type. I don’t know if this approach can be made to handle this, but it would be an improvement if it at least gave an error saying that it can’t discover all the types.

The problem is the “default” case on this line: https://github.com/haskell-servant/servant-swagger/blob/735657be74c1fb701c18d6eeac4d3b2ba23b66e1/src/Servant/Swagger/Internal/TypeLevel/API.hs#L81

mossprescott avatar Nov 23 '21 16:11 mossprescott

cc @rukav @ystael

mossprescott avatar Nov 23 '21 16:11 mossprescott