Forum Discussion

spatial's avatar
spatial
New Contributor
4 years ago

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.

2 Replies

  • 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/

     

     

    • spatial's avatar
      spatial
      New Contributor

      Thanks. I have in the past come across this. But that is only for subscription and notification.