Skip to main content

OpenAPI Setup Guide

In this article, we will go through the process of optimizing the API services of a blog web application using Resilis and OpenAPI/Swagger. If you are looking for an explainer of what Resilis is and does, you should check this intro first.

This guide will walk you through how to set up a Resilis account, import an OpenAPI/Swagger file, and generate a new endpoint for your application. This new endpoint will give you access to Resilis super performant and cost-saving infrastructure for your APIs.

Prerequisites

To follow through with this guide, you will need the following:

  • A Resils account. Sign up here.
  • A basic knowledge of APIs.
  • An OpenAPI/Swagger documentation of any deployed API services.

Generating OpenAPI/Swagger JSON

The first step to setting up an optimized API service with Resilis is generating the JSON representation of our OpenAPI documentation. This JSON file or URL will give Resilis access to read your API specs and import them to our platform. This guide assumes you have production OpenAPI/Swagger documentation.

  • Go to your production Swagger UI page. This guide assumes you have a route set up to view your Swagger UI on production. It can be any name other than /docs which my demo application uses.

  • On the homepage, append .json to the end of the homepage URL to confirm the JSON specs are showing and are accessible. This guide assumes that you have this /{route}.json route set up in your application where you defined your OpenAPI specification JSON response.

  • Copy the JSON URL and head to your Resilis dashboard to import the API services.

Alternatively, if you do not have any OpenAPI/Swagger documentation, you can use this demo documentation using this JSON URL https://aphrodite-resilis.onrender.com/docs.json and follow through with the guide too.

Creating API Service from OpenAPI/Swagger Documentation

Now that we have an OpenAPI/Swagger JSON URL, the next step is to import our API service to Resilis. To import your collection to Resilis, follow the steps below:

  • From your Resilis dashboard, click on the Create new service button as shown below:

  • Next, you will be prompted to choose a name for your service, fill in the name, and click Continue to proceed.

  • The service will be created and you will be prompted to start setting up the newly created service. Click the Start Setting Up button to continue.

  • You will get an option to use OpenAPI/Swagger import (the recommended method) or manual import. For this guide, we will use Swagger. Click on the OpenAPI/Swagger Import option to select it and click Continue to proceed.

  • The next step is to add the OpenAPI/Swagger JSON URL we generated earlier. Paste the URL and click Import to proceed.

  • Upon successful import, you will get a response as shown below and will be prompted to Go to Dashboard. If the import failed, you will get an error response which will give you insight on why it failed. Always make sure the OpenAPI/Swagger JSON URL is correct to avoid failure.

  • In your Resilis dashboard, on the Endpoints tab, you will see the imported endpoints from your OpenAPI/Swagger documentation. Also, a new URL that is mapped to your original endpoint URL will be generated. This new URL is what you will use in your application as the base URL to access the Resilis-optimized APIs.

Testing the New API Service on Postman

In this section, we will test the Resilis-generated endpoints to confirm it work using the new domain. Go to your Postman, and create a new request as shown below if you used the demo I shared earlier or use your endpoints as it is in your application if you imported your collection.

For Get Users Request:

For Get Posts Request:

Conclusion

In this comprehensive guide, we have learned how to import our OpenAPI/Swagger documentation to Resilis for optimized API performance, low latency, and cost efficiency. Let's recap the key components and takeaways from this guide:

  • Generating the OpenAPI/Swagger JSON URL to use when importing our API service to Resilis.
  • Follow through on creating a Resilis service and importing API services using the URL we generated
  • Testing the new domain with the endpoints in our applications to confirm that Resilis has been setup successfully

Some Advantages of Resilis

  • Resilis enhances user experience with fast API responses, improving engagement, customer satisfaction, and conversion rates.
  • Resilis offloads request from origin servers to over 300 edge locations, cutting costs and ensuring faster API responses for users.
  • Resilis reduces costs with edge caching and asynchronous processing, lessening server load and efficiently managing high traffic without expensive upgrades.
  • Resilis strengthens APIs for reliable performance during peak traffic, with advanced DDoS protection ensuring uninterrupted, seamless service.
  • You can easily set up Resilis using your Postman collection or any API documentation that uses OpenAPI spec

References