-
Notifications
You must be signed in to change notification settings - Fork 396
OpenAPI v3 Callbacks #331
Description
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:
… awaiting Starting Prism…
★ star Dynamic example generation enabled.
✔ success Prism is listening on http://127.0.0.1:4010
● note POST http://127.0.0.1:4010/streams
● onData POST {$request.query.callbackUrl}/data delay 30s.
This means that after the 30s. of delay a request with sample data based on the requestBody defined inside the callbacks/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:
… awaiting Starting Prism…
★ star Dynamic example generation enabled.
✔ success Prism is listening on http://127.0.0.1:4010
● note POST http://127.0.0.1:4010/streams
30s. after a request POST http://127.0.0.1:4010/streams?callbackURL=http://callback.com
● callback request POST http://callback.com/data
The OAS3 example adds the callbackURL as a query param but I guess it can be also send as a body param.