Skip to content

Auto generated clients

Course: OpenAPI Spec - chapter 7

Given you have a yaml/json file that describes the shape of your routes, lets try generating a ts client that we can use in a Node.js / React app to talk to the backend

Ref https://www.npmjs.com/package/openapi-typescript-codegen

  1. Store the OpenAPI Spec in a file (spec.json)
$1b
  1. Generate the client
npx openapi-typescript-codegen --input ./spec.json --output ./generated
  1. Explore the client
cd generated
cat index.ts
  1. Use it in a different project