Automatically generating types for Cloudflare Workers
blog.cloudflare.com
blog.cloudflare.com
You can brag about your automation, when it is well tested.
Unfortunately it might be pretty challenging given how different type systems can be. But maybe if you started with a subset of popular languages that have similar-enough type concepts?
(Correct me if I'm wrong about how Protocol Buffers work)
I think Serde is the closest thing I've seen to what I'm getting at; the way it can freely translate between XML and JSON and Rust structures without any help. But of course it's not a standalone schema language.
You can, of course, write your own derive macros, and apply several derive macros to a single struct.
I wrote some to derive SQLite schemas and migrations and queries and auto-generate frontend TypeScript RPC code. So my source of truth is the Rust struct, and that sort of magically generates everything else.
I don’t know if this is a good idea, but it’s been pretty fun so far. :-)
There are also derive-macro-powered crates to do GraphQL, other flavors of SQL, WASM bindings, etc etc.
In Cloudflare Workers we've taken a different path, having the C++ interfaces be the source of truth, as we feel this leads to less cognitive overhead for developers on the project (and avoided the need to write a new WebIDL code generator matching our internal C++ dialect). It's possible we'll revisit this decision in the future, but for the moment it seems to be working well.
There's openapi (swagger) and json schema which seems more like helping define RPC over http?