hey-api / openapi-ts

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

Support Custom client #1213

Open tomertweed opened 2 weeks ago

tomertweed commented 2 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 2 weeks ago

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

amirlevygit commented 2 weeks ago

Will be very appreciated

max-scopp commented 1 week ago

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

LeUKi commented 1 week ago

just like this

import axios from "axios";
axios.interceptors.request.use(); // custom your client
const client = createClient({ baseURL, timeout, axios });
tomertweed commented 1 week 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