Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

[feature proposal] Automated Mock Generator #152

Open
serranoio opened this issue Feb 20, 2025 · 0 comments
Open

[feature proposal] Automated Mock Generator #152

serranoio opened this issue Feb 20, 2025 · 0 comments

Comments

@serranoio
Copy link
Contributor

serranoio commented Feb 20, 2025

Initial Proposal

  1. Let's say you want to call v1/cowboy 10 times with your own custom parameters, with the rest being filled by the OpenAPI spec. The mock generator will call the endpoint 10 times with your custom params.
  2. Let's say you want the endpoint v1/cowboy to return a mocked response 10 times with your own custom parameters. The mock simulator will call the endpoint 10 times and return this response.
  3. Automation trigger - Sometimes the browser needs to make a call. Wiretap will integrate with an automation script (like cypress), call the script so the browser makes the call, intercept the request / response & mock it.
  4. Save custom mocks from UI - allows you to save your custom mocks so that you can use them in your config.
  5. Mock chaining. You can chain response.params -> request.params. Example: v1/cowboy returns an object Boots where boots =interface Boots {boots_id,... }

and there is an endpoint that allows you to customize your cowboy boots v1/customize-boots that accepts boots_id, mock chaining will allow you to use the response param from v1/cowboy as the request param for v1/customize-boots.

Architecture

I don't know how the architecture will look like.
I don't know what the configuration will look like yet.

UI

This will require a fat UI.

  1. Create a Call Sequence - Select an endpoint to call from a list of endpoints
  2. Each endpoint will allow you to choose
    2a. if you are mocking request or response, allowing you to quickly choose the http codes, example, examples (if there are any), giving you the option to input any custom params as well.
    2b. if you want an automation script to call the endpoint or if wiretap has to make the call itself
    2c. If any data needs to be "Mock Chain"ed, then pressing the data property will add it to the mock chain list
    2d. How many times you want to call the endpoint
  3. Once finished with an endpoint, you can add another endpoint to the automation. As for now, every call will be made synchronously in the call list.

Mock Chaining

Any data property that gets added to the mock chain list becomes available as a variable to be used in any request param.

Open Questions

  • There's a lot to discover about this ⚔.
  • Definitely plan to add the Call Sequences to the config so that we can automate mock generation.

Comments

This one comes first before the OpenAPI Spec Generator. Would like to discuss about the UI and how you envision it. I would love to code this. I am in fact dying to code this. I could not sleep last thursday because I thought of how powerful this idea could be. 🔥

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant