tapir
tapir copied to clipboard
Exhaustivity check?
What's the recommended way to turn missing server and/or client routes into compilation errors?
How would you define a missing server/client route?
A missing server route would be a route that the client calls but the server does not implement.
I'm not sure if the reverse, routes that exist on the server but not on the client, is a useful thing to check, but I'm just including it for symmetry.
For comparison, this kind of guarantee is something that type-based API description libraries provide, e.g. Servant in Haskell or typedapi / Typed Schema in Scala (see the line Note that now you must implement aloha method in your handler or compile error will be raised in the MkRoute application in Typed Schema docs).
Ah, I think I understand what you mean, but that won't be possible here. The individual endpoints don't have unique types, but rather the general Endpoint[I, E, O, R]. And when working with multiple endpoints, we use List[Endpoint[_, _, _, _]] or similar, instead of a fully type-safe tuple.
@adamw I'm currently exploring some ways of doing this using macros / generic programming. I think it could be a great opt-in feature on top of Tapir. Maybe as a separate module? I'll share my results if I get something good.
@Lermex sure, though I'd have to see some specific code examples, even if it's just a sketch of the API, to say anything more :). I'll keep this open then.