You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Is your feature request related to a problem? Please describe.
I have been working on creating mock APIS (full CRUD support) in my own implementations with MSW for a few years and have been wondering how much can I automate this and I would like to share a couple thoughts and hear if any of this makes sense for mocks-server.
Describe the solution you'd like
I have been following Miragejs and MSW/Data for a while and have recently stumbled upon quicktype and Zod-Mock. Quicktype is amazing. Whereas Miragejs and MSW/Data core value IMHO is in data modeling such that you can produce an interactive mocked API I believe this should be automated. Ideally we should be able to just look at network activity and infer the data model. This is exactly what quicktype enables. Further its does codegen, so we can generate zod code and leverage zod-mock to dynamically respond with faker-js mocked data that passes the type validation of the inferred type.
Additional context
Beyond just automatically mocking the data with a type-valid shape I can foresee this enabling monitoring network traffic on the fly in (certainly in dev but perhaps in other contexts) to gen types on the fly and watch for type changes as more routes are seen. Quicktype can make a single type that incorporates multiple examples.
There is probably a path towards automating the transformation/mutation bits as well but thats a deeper discussion and I just want to introduce this idea in its simplest form first.
The text was updated successfully, but these errors were encountered:
Maybe this could be implemented in a plugin somehow. A separated process could previously look at the network activity and generate the routes for the Mocks Server, or even the plugin could create a "proxy", so all of the traffic to the original API goes through it in a previous iteration, which would make easier to it to collect the needed information to generate the routes. So, the sequence would be as simpler as:
"start the Mocks Server with the routesGenerator plugin enabled in proxy mode"
"use the original API through the Mocks Server proxy"
"request the Mocks Server plugin to generate routes from collected data"
"stop the server"
"start it again. Now you have the mock API available"
Is your feature request related to a problem? Please describe.
I have been working on creating mock APIS (full CRUD support) in my own implementations with MSW for a few years and have been wondering how much can I automate this and I would like to share a couple thoughts and hear if any of this makes sense for mocks-server.
Describe the solution you'd like
I have been following Miragejs and MSW/Data for a while and have recently stumbled upon quicktype and Zod-Mock. Quicktype is amazing. Whereas Miragejs and MSW/Data core value IMHO is in data modeling such that you can produce an interactive mocked API I believe this should be automated. Ideally we should be able to just look at network activity and infer the data model. This is exactly what quicktype enables. Further its does codegen, so we can generate zod code and leverage zod-mock to dynamically respond with faker-js mocked data that passes the type validation of the inferred type.
Additional context
Beyond just automatically mocking the data with a type-valid shape I can foresee this enabling monitoring network traffic on the fly in (certainly in dev but perhaps in other contexts) to gen types on the fly and watch for type changes as more routes are seen. Quicktype can make a single type that incorporates multiple examples.
There is probably a path towards automating the transformation/mutation bits as well but thats a deeper discussion and I just want to introduce this idea in its simplest form first.
The text was updated successfully, but these errors were encountered: