openapi-fetch-gen is a tool that generates a fully typed TypeScript API client from OpenAPI TypeScript interface definitions created by openapi-typescript.
It parses the TypeScript schema file generated by openapi-typescript, extracts API endpoints, HTTP methods, and parameter structures, and generates typed wrapper functions for each endpoint.
The tool exports a fully-typed client with a base client instance and individual typed functions for each API endpoint, providing type helpers for parameters and responses.
To install, you can use npm install --save-dev @moznion/openapi-fetch-gen and run it using npx openapi-fetch-gen --input ./schema.d.ts --output ./client.ts.
The aim of openapi-fetch-gen is to simplify the creation of API clients by automating the process from the .d.ts schema generated by openapi-ts/openapi-typescript.
It eliminates the need for developers to manually implement client code for every API endpoint, offering a more efficient and streamlined approach.
Developers can use openapi-fetch-gen with the schema.d.ts file generated by openapi-typescript to automatically generate a fully-typed API client code for their Swagger API.
The generated client code includes functions for different HTTP methods like GET, PUT, POST, PATCH, DELETE, etc., making it easier to interact with the API endpoints.
openapi-fetch-gen simplifies the process of creating type-safe fetch client libraries and enhances the developer experience by reducing manual implementation tasks.
Overall, openapi-fetch-gen significantly streamlines the process of generating a fully-typed TypeScript API client, enhancing the efficiency and accuracy of API client development.