Dynamically generate a Typescript requests file for calling FastAPI
This allows us to easily call our FastAPI with the function names that exists in requests vs. hard-coding paths.
- Run your FastAPI, eg http://localhost:8080/docs should be live
- Run the script in
scripts/get-openapi-spec.ts
- Add the dev/build scripts from
package.json
to your project - Run
npm run dev
ornpm run api-build
- this should generate agenerated/api
folder that looks like the below:
5. Add a requests.ts file for accessing your API (ours is called coreAPI)
6. Add a request like that in `sample.ts` to your web project ๐