-
Notifications
You must be signed in to change notification settings - Fork 356
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
OpenAPI v3 Callbacks #331
Comments
Another source of inspiration for this feature is the Stripe CLI, specifically the listen command: https://github.com/stripe/stripe-cli#listen |
This issue is being worked on for callbacks in a cool way, @StefanDywersant has started some code where basically when you make a HTTP request to prism, if it is going to send callbacks it will fire HTTP requests at the callback URL defined in the users description document. Awesome! This covers "Callbacks" well.
We will not be able to cover webhooks in this way, but some of the same code could be used internally. Maybe take a look at webhooks and try to keep that in mind when building this solution. So, @StefanDywersant, we might need to split this in two. We can keep this issue for callbacks, but this issue and your PR will need to avoid using the word "webhook" as that will clash with the proposal. I'll make a new issue for webhooks, which will need to be initiated by the user via a CLI interface as we were suggesting above with the stripe-cli example. Does this sound good? |
@philsturgeon completely. I wasn't aware that there is upcoming |
As you can see in the OAS3 docs: https://github.com/OAI/OpenAPI-Specification/blob/master/versions/3.0.0.md#callback-object-example callbacks are now part of the specification.
It would be nice if prims could load the callback objects from the document and trigger the corresponding callback requests.
Here you have some ideas:
Given the callback-example document from the specification, if we run:
prism mock callback-example.yaml --callback_delay=30000
The CLI output could be something like:
This means that after the 30s. of delay a request with sample data based on the
requestBody
defined inside thecallbacks/onData
will be triggered to the{$request.query.callbackUrl}/data
URL.In case no delay is provided the callback request will be trigger immediately.
The CLI could also log when the request is made to the callback URL:
30s. after a request
POST http://127.0.0.1:4010/streams?callbackURL=http://callback.com
The OAS3 example adds the callbackURL as a query param but I guess it can be also send as a body param.
The text was updated successfully, but these errors were encountered: