Making API generation consistent
Standardizing OpenAPI SDK and DTO generation across services with templates and scripts.
My role · I standardized the generation approach using custom Mustache templates and scripts across many services.
Context · Professional work, with company details generalized.
Context
Several services exposed APIs consumed by other parts of the product. Generated clients and DTOs needed a consistent shape across those boundaries.
The Problem
Differences in OpenAPI generation made it harder to keep generated SDKs and DTOs aligned across multiple services.
My role
I standardized the generation approach using custom Mustache templates and scripts across many services.
Technical Approach
- Defined shared templates for generated SDK and DTO output.
- Used scripts to apply generation consistently across services.
- Kept the generator tied to the OpenAPI contract rather than hand-maintaining divergent clients.
Generalized process
- OpenAPI contract
- Shared templates
- Generation scripts
- SDK and DTO output
- Consuming services
Decisions and Tradeoffs
Centralize the generation rules
A shared template made output conventions repeatable across the participating services.
Generate from the contract
The OpenAPI definition remained the source for the generated client and DTO shapes.
Alternative to revisit
A different generator could be evaluated later, provided it preserves the conventions the services depend on.
Outcome
OpenAPI SDK and DTO generation was standardized across many services. No time-saved or defect-reduction metric is claimed.
Reflection
Clear documentation and a small compatibility check would help future template changes stay predictable.
Technologies
Links
No public repository or live demo is available for this professional work.