A common REST scenario
Two developers have a meeting to discuss a new feature they need to build. The frontend dev shares the UX mocks and describes what they need from the backend. The backend dev goes away for a day or two and implements a couple of new REST endpoints. Once they’re done, they send the frontend dev a Postman collection with a series of sample requests, which act as documentation. The frontend dev then starts building their own code on top of it. They quickly realize that one of the endpoints is missing some data that needs to be shown in the UI, so they talk to the backend dev, who updates the endpoint’s implementation the next day. This back-and-forth goes on with various tweaks to the endpoints over the duration of two weeks. The frontend dev gets a little frustrated. The backend dev isn’t enjoying the process either and starts to grow resentful. How they wish there was a better way! What we’re missing here is an API contract, agreed upon before implementation even started. This could take the form of a simple text document that describes for each endpoint:- what the endpoint does, in unambiguous, human-friendly terms
- its HTTP method and path (including any dynamic path parameters)
- the request payload schema
- the response payload schema
- any other information such as headers, query parameters and so on
- example requests and responses