Alex Martinez

Feb 7, 20232 min

How to generate shareable link examples from GitHub to open in the DataWeave Playground

Updated: Sep 5, 2023


In this post:

  • The link's anatomy

  • The folder structure


Some months ago, the DataWeave engineering team created this beautiful functionality to be able to open DataWeave examples (including inputs and scripts) directly in the Playground with a single link.

Here’s an example.

In this post, we’re going to learn how to create these shareable links from a GitHub repository to open directly in the online DataWeave Playground.

For more detailed explanations with more examples, please see the video version:

The link's anatomy

Let’s use as an example the link I shared at the beginning of the post. This is the complete URL:

https://dataweave.mulesoft.com/learn/playground?projectMethod=GHRepo&repo=alexandramartinez%2Fdataweave-scripts&path=functions%2FmaskFields

Now let’s separate this to make it more readable:

You may have noticed that there are some weird characters in the query parameters’ values (%2F). This is just the representation of a slash (/) to make it safe to pass it down in a URL.

To make sure your values for the repo and path query parameters are URL-safe, you can use this tool: urlencoder.org. Simply input your value at the top and click Encode. The encoded value will be returned under the button.

Now that we have a better understanding of how the link is built, let’s now make sure our folder structure inside our repo (the maskFields folder from the previous example) is correctly set.

The folder structure

Since we are only passing the main folder to the Playground, we have to make sure everything is where it’s supposed to be. For that, we have to set the correct folder structure.

The folder structure from the previous maskFields folder example would look like this:

maskFields/
 
- inputs/
 
- payload.xml
 
- transform.dwl

As you can see, this is a simple example where there’s only one payload and only one main script (transform.dwl).

Let’s see a more detailed explanation of what this all means.

Once you have everything set up and committed/pushed to your public GitHub repository, you will be able to use the link to share your examples :)

Note: It may take up to 30 minutes for the Playground to be updated after you make any changes to the repository. So, if you do not see your changes being reflected immediately, just wait a bit.

Feel free to contact me for any questions or troubleshooting steps regarding this. I’m happy to help!

-alex

    4892
    3