swagger-typescript-api icon indicating copy to clipboard operation
swagger-typescript-api copied to clipboard

feat: add ofetch http client

Open samydoesit opened this issue 1 year ago • 2 comments

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. :)

samydoesit avatar Mar 27 '24 22:03 samydoesit

What do I need to do to use it now?

productdevbook avatar Nov 07 '24 08:11 productdevbook

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.

samydoesit avatar Nov 10 '24 02:11 samydoesit