hey-api / openapi-ts

🚀 The OpenAPI to TypeScript codegen. Generate clients, SDKs, validators, and more. Support: @mrlubos
https://heyapi.dev
Other
1.39k stars 107 forks source link

Support Custom client #1213

Open tomertweed opened 3 weeks ago

tomertweed commented 3 weeks ago

Description

Hey, I want to replace the existing request clients (http, axios...) with my own client (A wrapper of axios with extra utils and different interface) I could only find usage of the pre-built clients. Im not sure if its supported or not but I would like to be able to customize / override the client with my own. And thanks for your great project

yarinvak commented 3 weeks ago

Hey this will be great if you can add it, this is a very useful feature!

amirlevygit commented 3 weeks ago

Will be very appreciated

max-scopp commented 2 weeks ago

@tomertweed you can fully replace the fetch() implementation of the fetch-client, have you looked at that?

LeUKi commented 2 weeks ago

just like this

import axios from "axios";
axios.interceptors.request.use(); // custom your client
const client = createClient({ baseURL, timeout, axios });
tomertweed commented 2 weeks ago

just like this

import axios from "axios";
axios.interceptors.request.use(); // custom your client
const client = createClient({ baseURL, timeout, axios });

My goad is to use my client instead of interceptor of axios

JeanVt commented 2 days ago

I am also interested in this feature. Adding interceptors or changing the fetch implementation is not enough in my case, In addition to changing the fetch implementation, I want to be able to pass custom options to service methods, and return a different type.

max-scopp commented 2 days ago

@JeanVt Could you share a specific code example on what your final goals are? We're running HeyAPI's Angular Query Plugin and despite a poorly typed api we haven't faced any major issues. In fact, none related to HeyAPI in particular. We do need need to retype certain endpoints in a regular basis, from completly non-existend to just missing a few properties.