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
2.82k stars 313 forks source link

Mocks: Is there a way to have a single export for mocks in tags-split mode? #512

Open la55u opened 2 years ago

la55u commented 2 years ago

Generating everything in one file with the single mode results in a 20k line file which is obviously not ideal, makes my IDE freeze and file operations take extremely long time to finish. So I naturally choose the tags-split mode in orval, but when I tried to set up mocks according to the examples, I faced the following issue. I couldn't find a way to have a single function that exports all the mock functions. I figured it should be something like export const handlers = getMyApiMSW() in handlers.js but currently I can only do that in 'split' mode as it generates a separate .msw file for mocks.

Question is, can we have an index.mocks.ts file or similar generated that exports only the mock functions but all of them? (Using react-query client if it makes a difference.)

Thank you, awesome tool btw!

Edit: related to https://github.com/anymaniax/orval/issues/347

anymaniax commented 2 years ago

Hello @la55u at the moment it's not possible. It's on my todo list to be added as a feature. Also thanks for the support!

melloware commented 10 months ago

cc @Will-Mann-16