zoubingwu / msw-auto-mock

A cli tool to generate random mock data from OpenAPI definition for msw.
246 stars 54 forks source link

Configurable array length, number values, and response conditions #25

Closed senning closed 3 days ago

senning commented 1 year ago

Hi there! Thanks for building this library, I'm finding it really helpful for quick prototyping. I ran into a few pain points that I had to resolve by directly changing the mock file, so I tried to fix them with this PR. There are two groups of changes, one of which is much bigger, so I kept them in separate commits in case you wanted to cherry-pick the smaller one.

support min and max values for numbers and array length

alt handler transformer for conditional responses

To provide an example of these changes in action, I set up this repo. You can run it with these params:

./test.yml -o ./mock.js -r ./responseConditions.json --node --base-url https://test.com/

and test it with the tests in that repo.

zoubingwu commented 1 year ago

Thanks for your contribution! Could you please use pnpm as package manager? or just remove package-lock.json from commits

senning commented 1 year ago

Sure, I've removed package-lock.json and I'll use pnpm in the future. I've also rebased against the current master.

leogallot commented 6 months ago

Hello, is this PR planned to be merged? Thank you.