Our great sponsors
-
openapi-generator
OpenAPI Generator allows generation of API client libraries (SDK generation), server stubs, documentation and configuration automatically given an OpenAPI Spec (v2, v3)
-
InfluxDB
Power Real-Time Data Analytics at Scale. Get real-time insights from all types of time series data with InfluxDB. Ingest, query, and analyze billions of data points in real-time with unbounded cardinality.
I prefer to write the OpenAPI spec in YAML by hand as the source of truth and use that to auto-generate the appropriate client and server types for whichever languages those are implemented in. For my current project, I use oazapfts to generate TypeScript client types that my frontend uses to talk to the backend.
For my current project, the backend is deployed to Lambda but written in Rust. The API model types (e.g., SomeRouteRequest and SomeRouteResponse) are auto-generated from the OpenAPI spec using OpenAPI Generator's Rust generator. I had to write a script to manually generate traits with function signatures for each route handler from the OpenAPI spec. Then, my code implements that trait, and the compiler type checks that the code is consistent with the OpenAPI spec.