DEV Community

Emily
Emily

Posted on • Updated on

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.

Top comments (3)

Collapse
 
simonfischerse profile image
SimonFischerSE

Hey Emily.

Happy to hear that you enjoyed contributing to Medusa during Hacktoberfest! Noticed that the link to our webpage is broken (it refers to our old domain), thought you might be interested in updating it to our live-page medusajs.com?

Thanks ahead of time!

Collapse
 
hphan9 profile image
Emily

Thank you Simon. I updated it :) It was great experience contributing to Medusa :)

Collapse
 
simonfischerse profile image
SimonFischerSE

Thank you, really appreciate you doing that!