feat: add ofetch http client
This pull request introduces a new feature to the swagger-typescript-api, allowing users to generate a HTTP client utilizing the unjs/ofetch library for making HTTP requests. This is facilitated through the use of the --ofetch command-line flag. The addition of ofetch support is aimed at providing developers with more choices for their HTTP client library, especially in projects where ofetch is already in use or preferred.
There may be areas of improvement or alternative approaches that could improve the implementation or usefulness of the feature. I'm open to any feedback, suggestions or contributions from the community to further refine this feature and would greatly appreciate it. :)
What do I need to do to use it now?
Hi i've updated the branch to the latest version and created an npm package with the changes.
You can install it using: npm i @samydoesit/swagger-typescript-api
await generateApi({
fileName: "schema",
input: path.resolve(import.meta.dirname, "schema.json"),
output: tmpdir,
silent: true,
generateClient: true,
httpClientType: "ofetch",
});
(Please take a look at the test files for usage examples.)
I couldn't get the CLI to work for now.