Last updated

Project 6: Kitchen API

ScheduleFlex Meld
Time allowed4 hours

New teams for June and July.

Update Realm

Update to the latest version of the RC of Realm.

At the time I write this, it's 0.83.0-rc.5.

Cheat: How to do this

Edit the package.json and replace the version of Realm with 0.82.2-rc.1 (or any other latest version).

package.json
 "dependencies": {
    "@redocly/realm": "0.83.0-rc.5"
  }

We'll always update because we want to test the latest release candidate (until it becomes the minor version). Then, we'll update to the latest minor version.

Kitchen API

The boss said we need to have our Kitchen API documented on the website alongside the Petstore, Museum, and Train Travel.

When asked for the OpenAPI file, the boss said, "There isn't one... you'll need to make it."

When asked for any information about the API, the boss gave the following example requests and responses.

Request: POST /ingredients
{
  "kitchenId": "altman-family",
  "name": "broccoli",
  "quantity": 1.5,
  "unit": "cups",
  "useBefore": "2019-08-24T14:15:22Z"
}
Response: 201
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object": "ingredient",
  "kitchenId": "altman-family",
  "name": "broccoli",
  "quantity": 1.5,
  "unit": "cups",
  "useBefore": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z"
}
200 Response for: GET /ingredients/{ingredientId}
{
  "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
  "object": "ingredient",
  "kitchenId": "altman-family",
  "name": "broccoli",
  "quantity": 1.5,
  "unit": "cups",
  "useBefore": "2019-08-24T14:15:22Z",
  "createdAt": "2019-08-24T14:15:22Z"
}
200 Response for: GET /ingredients
{
  "object": "list",
  "page": {
    "endCursor": "ZG9uJ3QgZGVjb2RlIG1l",
    "startCursor": "ZG9uJ3QgZGVjb2RlIG1l",
    "hasNextPage": false,
    "hasPrevPage": false,
    "limit": 10,
    "total": 0
  },
  "items": [
    {
      "id": "497f6eca-6276-4993-bfeb-53cbbbba6f08",
      "object": "ingredient",
      "kitchenId": "altman-family",
      "name": "broccoli",
      "quantity": 1.5,
      "unit": "cups",
      "useBefore": "2019-08-24T14:15:22Z",
      "createdAt": "2019-08-24T14:15:22Z"
    }
  ],
  "total": 1
}

Errors follow the problem+json format.

When asked about the server, the boss said it's a variable -- it depends on the tenant.

When asked about security, the boss said JWT Bearer token.

The boss also said use OpenAPI 3.1.

Cheat: Link to the docs (better if you try to find it)

Replay

Test the API against the mock server using Replay. Be sure to test all four requests.

For the post request, try to also get an error by putting in some bad data in the request.

The boss is especially looking for feedback on the replay experience.

Debrief

Debrief on your experience. What made you smile? What did you find confusing?