DEV Community

Cover image for OpenAPI + Zod + API Gateway + SST = Turbo Productivity
Marko - ServerlessLife.com
Marko - ServerlessLife.com

Posted on • Edited on • Originally published at serverlesslife.com

1

OpenAPI + Zod + API Gateway + SST = Turbo Productivity

How to boost productivity with OpenAPI schema, Zod library, and client-generated code. Included is a sample serverless app built with SST/CDK.

"Don't repeat yourself" (DRY) is one of the main principles of software development. But we keep on breaking it by rewriting the data structure on each layer. In this article, we'll explore the method of enhancing our productivity through the utilization of OpenAPI schema, the Zod library, and the generation of client code, all aimed at reusing our types, schemas, and structures. l will bundle everything into a sample AWS serverless application built with the SST framework (which uses CDK). The solution also takes into account that you do not want to have exactly the same types everywhere. The Zod library nicely solves the problem and allows you to mix and match types.

> We keep breaking the "Don't repeat yourself" (DRY) principle by rewriting the data structure on each layer.

When you are creating an API and an application that consumes it, you need to (re)create types/schema for each layer:

  • data exchange = OpenAPI, GraphQL
  • client that consume it
  • API validation logic
  • business logic

Continue reading on www.serverlesslife.com...

Billboard image

The Next Generation Developer Platform

Coherence is the first Platform-as-a-Service you can control. Unlike "black-box" platforms that are opinionated about the infra you can deploy, Coherence is powered by CNC, the open-source IaC framework, which offers limitless customization.

Learn more

Top comments (0)

Bump.sh

Bump.sh is much more than stunning documentations for all your APIs.

Automatically generate docs that are always up-to-date with CI integrations.
Get alerted on breaking API changes and enjoy the generated diff on each version.

Centralize all your API docs, whether they’re public, private or partner, whether they’re OpenAPI or AsyncAPI, and whether you’re building or consuming it.

Discover Bump.sh

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay