cancel
Showing results for 
Search instead for 
Did you mean: 

Process workflow using API contract

spatial
Occasional Visitor

Process workflow using API contract

Hello,

          I have a question about a process workflow and its representation in the API contract. So, for example, I want to process a payment. I define a payment API. When the payment is received from another service, that service contacts a fraud detection system. My service will receive the payment but does not deliver the order. It waits for the fraud detection system to send a report. If the report is clean then I will deliver the order. This is the general idea of a workflow I have.

 

Is there a recommended way to model this swagger contract ? I am not asking about DDD principles here. That will be taken care by the backend code.

Can Open API model a workflow like this ? It is stateless and driven by API call events.

 

Thanks.

1 REPLY 1
joejoyce
Staff

Re: Process workflow using API contract

Hey @spatial. If I'm understanding the scenario correctly, I think this could be implemented in an OpenAPI definition using Links and Callbacks.

 

OpenAPI Links can be used to define a relationship and traversal mechanism between two different operations. Callbacks can be used to describe asynchronous requests that your API sends in response to some event. Does this sound like it might help for the scenario you've described?

 

Relevant links to OAS documentation:

 

https://swagger.io/docs/specification/callbacks/

 

https://swagger.io/docs/specification/links/

 

 

New Here?
Join us and watch the welcome video:
Announcements
Top Kudoed Authors