[ANN] Preview of Stripe client and mock server - DkStdRestApis

I am pleased to announce that Stripe is the first REST API available in the DkStdRestApis project:

That README has a 10-minute quick start; you can do it with or without a Stripe account.

The Stripe client and mock server have Apache 2.0 licensing and were generated using a new OpenAPI code generator. The code generator is not part of this preview announcement (wait until DkCoder 0.4 announcement) but since there have been a couple generators released in the past month perhaps it is best to say what is different:

  1. Both client and server source code are generated. The client examples include direct web requests by cohttp-lwt-curl (src/DkStdRestApis_NotStripe/Curl2.ml) and also indirectly by printing the curl -d name=value https://api.stripe.com/... command (src/DkStdRestApis_NotStripe/CurlCmd.ml). The mock server example (src/DkStdRestApis_NotStripe/ServerTiny.ml) uses @c-cube 's excellent tiny_httpd daemon.
  2. Very small dependency cone that works on Windows/macOS/Linux (including the REST server). And the minimum OCaml version will be 4.14 for the foreseeable future.
  3. My focus is not on the code generator but having working, maintainable REST clients for the major cloud/SaaS services that can be included in DkCoder’s liberally licensed standard library. The server feature was a pleasant but very unplanned accident. If I do take time to develop fancier server features (ex. replaying mocks from a corpus, etc.) those additions will not be open source.
  4. It is intended to have high coverage of OpenAPI features. Today that includes form URL encoding, sum types, server-side polymorphism and style/explode support. The only major feature that is intentionally unsupported is the not composition operator (have no idea how to express negation in OCaml’s type system!).

Now for the problems:

  1. Stripe only compiles in bytecode mode. Why? The generated modules are huge (8+ MB in total) because Stripe’s specification is 6MB. Native compilation can’t handle that today.
  2. I’m not releasing to opam until I’m sure that native compilation won’t denial-of-service developer and opam machines. I’m also waiting for some Windows patches to dependencies to be released.

Thanks to @vlaviron for helping solve some of the compilation scaling problems. And thanks to Nomadic Labs (and OCamlPro?) for developing Json_encoding and @anuragsoni for developing Routes; they are both bidirectional + lightweight + foundational.

Report bugs / add stars in the DkCoder project.

3 Likes