Skip to main content

Setup

Generate types

✅ You need to have node.js installed (which you already probably have).

So just run:

npx rest2ts --source https://petstore.swagger.io/v2/swagger.json --target ./api
Integrate this script into your package.json

Go to your package.json and add this script to your scripts section:

"generate-types": "npx rest2ts --source https://petstore.swagger.io/v2/swagger.json --target ./api

Run from project root

npm generate-types

and types from https://petstore.swagger.io/v2/swagger.json will be generated into ./api folder. Forever.

Setup client

import { setupClient } from "Api/Api";

function App() {
setupClient({
apiUrl: "https://petstore.swagger.io/v2",
});

<>Your app</>;
}