Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Mock API by pointing to Open API spec #531

Open
svrooij opened this issue Jan 27, 2024 · 2 comments
Open

Mock API by pointing to Open API spec #531

svrooij opened this issue Jan 27, 2024 · 2 comments
Labels
enhancement New feature or request needs spec Issue needs specification

Comments

@svrooij
Copy link
Contributor

svrooij commented Jan 27, 2024

It would be very cool if you could point the dev proxy to some openapi spec url and have it mock that api.

And as an extra feature it should use AI (bring your own key) that checks the object type and tries to mock reasonable data.

So if you mock a /users/{id} endpoint it would generate a reasonable response for a givenName or a mail property.

The generated response should be saved for economic reasons off course.

@waldekmastykarz waldekmastykarz added enhancement New feature or request help wanted We'd appreciate your help labels Jan 27, 2024
@waldekmastykarz
Copy link
Collaborator

Great idea! We could go about it in two ways:

  1. Build a plugin that takes an OpenAPI spec as input and generates the necessary mock responses when requested. Like you suggested, it caches the generated mocks for subsequent use. Here, we'd also need to consider invalidating the cache when the spec changed.
  2. Build a command that converts an OpenAPI spec into mocks. The benefit here is that you only process the spec once and get a set of mocks which you can reuse without the spec. You can also fine tune the generated mocks to your needs.

Thoughts?

@waldekmastykarz waldekmastykarz added needs spec Issue needs specification and removed help wanted We'd appreciate your help labels Jan 27, 2024
@svrooij
Copy link
Contributor Author

svrooij commented Feb 14, 2024

I'm all for having it done automatically. So you point it to an OpenAPI spec and it should start getting those requests. And if you say "here is my open AI key, please generate mocks for all endpoints". It should do that once. maybe even hash the spec of a single action? That would allow caching the mock on a per request base, which is probably cheaper than regenerating mocks for all requests if only a single request in the openapi spec has changed.

Maybe even do the generating of the mocks on the fly (with a 429 to delay the client 😉) so only request that are tested get (expensive) mocks, and not every request in the spec.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request needs spec Issue needs specification
Projects
None yet
Development

No branches or pull requests

2 participants