orval icon indicating copy to clipboard operation
orval copied to clipboard

feat: add a way to provide an axios instance

Open jdrouet opened this issue 3 months ago • 8 comments

When using the axios client, I'd like to be able to provide an axios instance. The way to do in the doc is to define a global constant which is then used globally. This is a problem because it allows only a single instance of the client in the application and it's potentially prone to security issues. With this, we can create an instance of axios an pass it as an argument like the following

const instance = axios.create({ headers: { Authentication: 'Bearer foo' } });
const api = createClient();

return api(instance);

Fix https://github.com/orval-labs/orval/issues/653

jdrouet avatar Oct 02 '25 16:10 jdrouet

this looks pretty good to me build is running now

melloware avatar Oct 02 '25 16:10 melloware

sorry do a git pull from main please

melloware avatar Oct 02 '25 16:10 melloware

I rebased 😉

jdrouet avatar Oct 02 '25 16:10 jdrouet

running build again

melloware avatar Oct 02 '25 17:10 melloware

ok it looks like it is failing the samples check you might want to run yarn update-samples then yarn test:samples

melloware avatar Oct 02 '25 18:10 melloware

@melloware should be fixed now 🤔

jdrouet avatar Oct 02 '25 19:10 jdrouet

Parameter 'axios' cannot reference itself.

melloware avatar Oct 02 '25 21:10 melloware

I will come with a proper fix today or tomorrow 😉

jdrouet avatar Oct 03 '25 07:10 jdrouet