Solution for Chapter 4: Designing APIs

Design and Build Great Web APIs — by Mike Amundsen (115 / 127)

The Pragmatic Programmers
The Pragmatic Programmers
2 min readApr 28, 2021

--

👈 3: APIs | TOC | 5: ing APIs 👉

In the Chapter Exercise, you were instructed to complete a detailed version of the credit-check-workflow.txt document, resolve the names in that workflow against the https://schema.org site, and then use that updated workflow document to create your credit-check-diagram.wsd document. Finally, you were instructed to use that WSD document to generate a PNG diagram of the CreditCheck service workflow.

Detailed credit-check-workflow.txt

This first step involves making sure you include possible property values and navigation actions that will be exposed by the CreditCheck service. This is also a good time to resolve any property names against your company dictionary to make sure you only expose names that everyone else using your API already understands. I combined both steps into one and produced the following updated credit-check-workflow.txt document:

Create a WSD Document

The next step is to create a web sequence diagram (WSD) version of the workflow. I created one called credit-check-diagram.wsd that looks like this:

Generate a PNG File

Finally, I used the wsdgen utility to generate a PNG version of the WSD file using the following command-line action:

This generates the file credit-check-diagram.png, which should look something like this:

images/designing/credit-check-diagram.png

Be sure to save your project updates using git too.

👈 3: APIs | TOC | 5: ing APIs 👉

Design and Build Great Web APIs by Mike Amundsen can be purchased in other book formats directly from the Pragmatic Programmers. If you notice a code error or formatting mistake, please let us know here so that we can fix it.

Unlisted

--

--

The Pragmatic Programmers
The Pragmatic Programmers

We create timely, practical books and learning resources on classic and cutting-edge topics to help you practice your craft and accelerate your career.