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

tapiro could generate client code too #227

Open
giuscri opened this issue Apr 8, 2020 · 0 comments
Open

tapiro could generate client code too #227

giuscri opened this issue Apr 8, 2020 · 0 comments

Comments

@giuscri
Copy link
Contributor

giuscri commented Apr 8, 2020

Given a tapir endpoint we could easily generate functions that consumers could import and call.

val booksListingEndpoint: Endpoint[(BooksFromYear, Limit, AuthToken), String, List[Book], Nothing] = endpoint
    .get
    .in(("books" / path[String]("genre") / path[Int]("year")).mapTo(BooksFromYear))
    .in(query[Int]("limit").description("Maximum number of books to retrieve"))
    .in(header[String]("X-Auth-Token"))
    .errorOut(stringBody)
    .out(jsonBody[List[Book]])

def bookListing(booksFromYear, limit, authToken)(implicit host: String, port: Int) =
    bookListingEndpoint.toSttpRequest(s"http://{host}:{port}")

Clients could call bookListing(...) triggering a call against the endpoint.

As I understand this, this is an important piece of RPC that's currently missing from tapiro. gRPC for example generates libraries out of the protobuf's.

To my understanding this is very easy to implement and adds a crazy amount of value.

@giuscri giuscri changed the title tapiro could generate "client libraries" too tapiro could generate client code too Apr 8, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants