Working on Generating API fixture

hphan9

Emily

Posted on November 2, 2021

Working on Generating API fixture

In the second week of Hacktoberfest, I found an interesting project to work on_ Medusa. Medusa is a headless commerce platform that enables developers to create a digital commerce experiences.

Issue

The project owner want to generate fixtures for models returned by their API, so the users can see it as an example how data returns back when making an API call. I chose the Region model to work on.
The first challenge I had is setting up the development environment to start contributing. I met several errors that was not discussed in the documentation. Luckily, they have a Discord group and it is really active. I found other contributors had same issues before so I followed their advice and resolved the problem. I also helped newer contributor to overcome the same challenge. It felt great that I can help other developers.

Solution

The process for creating API fixture was straightforward. The project owners were really thoughtful and they created a video to walkthrough the problem and solution.
Basically, I had to write an integration test for GetRegionsRegion API call and the result of this call will be saved in the fixture folder.
The fixture I created is here

{
  "region": {
    "id": "reg_01FHTESN727620KGC7KASK5KSM",
    "name": "Scandinavia",
    "currency_code": "dkk",
    "tax_rate": "0",
    "tax_code": null,
    "countries": [],
    "payment_providers": [
      {
        "id": "test-pay",
        "is_installed": true
      }
    ],
    "fulfillment_providers": [
      {
        "id": "test-ful",
        "is_installed": true
      }
    ],
    "created_at": "2021-10-12T14:34:10.528Z",
    "updated_at": "2021-10-12T14:34:10.528Z",
    "deleted_at": null,
    "metadata": null
  }
}
Enter fullscreen mode Exit fullscreen mode

You can take a look on my Pull request here.
In overall, it is great experience. The project owners was really nice and helpful. I would love to contribute more to this project.

💖 💪 🙅 🚩
hphan9
Emily

Posted on November 2, 2021

Join Our Newsletter. No Spam, Only the good stuff.

Sign up to receive the latest update from our blog.

Related