orval-labs / orval

orval is able to generate client with appropriate type-signatures (TypeScript) from any valid OpenAPI v3 or Swagger v2 specification, either in yaml or json formats. 🍺
https://orval.dev
MIT License
3.18k stars 336 forks source link

Mutator: Export of named variable with function not working #1678

Closed blasdfaa closed 3 weeks ago

blasdfaa commented 3 weeks ago

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 
thomas-harmeyer commented 3 weeks ago

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"

melloware commented 3 weeks ago

Thanks @thomas-harmeyer