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
- Store the OpenAPI Spec in a file (spec.json)
$1b- Generate the client
npx openapi-typescript-codegen --input ./spec.json --output ./generated- Explore the client
cd generatedcat index.ts- Use it in a different project