Runscope API Monitoring    Learn More →

How to Merge OpenAPI Definition Files

By Heitor Tashiro Sergent on .

thumbnail.jpg

I recently saw a Twitter thread that started with a simple question: how to combine multiple OpenAPI 3 definition files back together? One of the answers on that Twitter thread came from Mike Ralphson, and he pointed out that speccy, an open-source project, could help with that.

Now, you might ask yourself, why would someone want to merge an OpenAPI definition file back together? Isn't the point of separating it into multiple files to have better organization? Well, merging a definition file back together into a single one can be useful if you have tooling that doesn't support definition files with references and requires a single one to be uploaded, whether that is for documentation tooling, a UI definition editor, or maybe for API Gateway support.

speccy

speccy is an open-source project written in Node.js, that allows the user to lint, merge, and visualize an OpenAPI definition in a human-readable format.

For our purposes, we're just going to focus on the merging aspect of it.

How to Merge OpenAPI 3 Files

To use speccy, first we need to have Node.js installed in our machine. You can either download it from the Node.js website, or open the terminal and run:

curl "https://nodejs.org/dist/latest/node-${VERSION:-$(wget -qO- https://nodejs.org/dist/latest/ | sed -nE 's|.*>node-(.*)\.pkg</a>.*|\1|p')}.pkg" > "$HOME/Downloads/node-latest.pkg" && sudo installer -store -pkg "$HOME/Downloads/node-latest.pkg" -target "/"

Then, we can install speccy by opening the terminal and running:

npm install -g speccy@0.8.7

And finally, still in the terminal, go to the directory where your OpenAPI definition files are and run:

speccy resolve spec.yaml -o spec-output.yaml

`resolve` is the command to merge definition files back into one. It's followed by the path to the main definition file that includes references to other files you wish to merge. Next, we add the option flag -o to output the resulting definition to a new file named spec-output.yaml.

If you want to test this on a definition file that's broken up into separate files but you don't have one at the moment, you can use this example I set up using the Pet Store example: https://github.com/heitortsergent/openapi3-ref-example

And if you're curious about the way I split up this OpenAPI definition, I used this great blog post by Jack Skinner as a reference: Maintaining large design-first API specs.

And you're all set.

Note: you might have noticed that we are using a specific version of speccy, 0.8.7, in the install command. At the time of writing, there was a known issue with the latest version where the output flag for the resolve command was not working. I would recommend using the latest version if that bug has been fixed. And always be kind to open-source maintainers. :)

Categories: openapi, tutorial


How to Debug Common API Errors

By Heitor Tashiro Sergent on .

Introduction

Debugging and troubleshooting APIs is something that any developer that works with APIs has to go through at some point. In an ideal world, APIs would always return a 200 OK with just the right data that we need, or in case of a failure, it would return us the perfect status code and error message allowing us to easily understand what went wrong.

In reality, APIs don't always work like that. API developers might have constraints that do not allow them to implement the most informative status code or error message, API errors can be triggered by real-world conditions that are hard to account or test for, and sometimes ourselves, as API users, can make requests with typos or mistakes that APIs just don't know how to handle.

In this post, we're going to focus on API users and what they can do to debug common API errors they might encounter when testing and working with APIs, whether these APIs are public or private […]

Read More →

Categories: testing, debugging, apis


Customizing Slack Notifications from Runscope using AWS Lambda

By Sam Aybar on .

Runscope gives you many options in terms of how you can be notified when your APIs are down. Whether you use email, Slack, PagerDuty, Microsoft Teams, or want to build your own solution using Webhook notifications, Runscope can ensure your team is notified quickly using your channel (or channels!)

We’ve had some customers ask about how they could customize their Slack notifications. We’ve tried to make these notifications as helpful as we can, but we recognize that every team has their own unique needs.

Using advanced webhook notifications, you can build your own customizable Slack alerts. whether you want to include a custom message, a link to another resource, or some other useful information from your team, a custom alert allows you to tailor Runscope to your team's needs.  To help you do this, we created a walkthrough video which you can find here […]

Read More →

Categories: tutorial, integrations, howto


How Trustpilot Leverages Runscope Webhooks and Custom Slack Notifications

By Heitor Tashiro Sergent on .

Trustpilot is a review platform where people can read, write, and share reviews for all kinds of businesses. They have also been Runscope users since 2015, and we have featured them in other blog posts, such as how they monitor over 600 microservices.

One of the most important parts of API monitoring is getting notified when something breaks. Trustpilot uses Slack as their main communication hub, and so they rely on notifications that are sent from Runscope to Slack in case something breaks.

The default Runscope-Slack integration was enough for the Trustpilot team for a while. They made sure to use the threshold feature to only receive notifications after a test failed 3 times in a row, and again when the test returns passing, to control the overall number of notifications they would get.

But as their architecture evolved, and their Runscope usage grew, the amount of notifications grew as well. Add those up with other 3rd-party services, and they really started to build up. And getting too many alerts can be just as bad as getting zero alerts. The team started suffering from notification fatigue […]

Read More →

Categories: apis, community, customers, debugging, integrations, monitoring


How To Send Runscope Webhook Notifications to Google Hangouts Chat with EventN

By Sam Aybar on .

I’ve written before about how you can use webhooks with Runscope to extend the functionality of Runscope. In case you missed that post, Runscope has a number of built-in integrations, but some users want custom notifications with apps that we may not currently support. Webhook notifications are POST requests that are made at the completion of a test, and include a payload with details about the test run. If you can listen for these notifications, you can write your own code to deliver Runscope notifications anywhere that has an API you can use.

One service we don’t yet have a built-in integration is Google Hangouts Chat, the GSuite tool that facilitates group communication. In this blog post, I am going to describe how you can integrate Runscope with Hangouts Chat so you can get your team notified about Runscope tests in this GSuite tool.

Here is a snippet of what the webhook […]

Read More →

Categories: tutorial, product, integrations


Everything is going to be 200 OK®