orval-labs/orval

Mutator: Export of named variable with function not working

Closed this issue · 2 comments

What are the steps to reproduce this issue?

  1. go to https://stackblitz.com/edit/vitejs-vite-7fajbv?file=src%2Fapi%2Fhttp-client.ts
  2. run in terminal npm run orval

What happens?

takes error in terminal - Your mutator file doesn't have the httpClient exported function

What were you expecting to happen?

The custom http client must be successfully applied

Any logs, error output, etc?

❯ npm run orval

> vite-typescript-starter@0.0.0 orval
> orval

🍻 Start orval v7.2.0 - A swagger client generator for typescript
Your mutator file doesn't have the httpClient exported function

What versions are you using?

  System:
    OS: Linux 5.0 undefined
    CPU: (8) x64 Intel(R) Core(TM) i9-9880H CPU @ 2.30GHz
    Memory: 0 Bytes / 0 Bytes
    Shell: 1.0 - /bin/jsh
  npmPackages:
    orval: ^7.2.0 => 7.2.0 

you need to change:
export const httpClient = ofetch.create({});
to
export const httpClient = () => ofetch.create({});

as per the error message "Your mutator file doesn't have the httpClient exported function"