When you’re developing a dynamic, data-driven mobile app using a REST API to connect to an external service, there can be a lot of pieces to fit together. Testing with mock data can help.

A variety of tools, such as Postman, can help to connect the dots between your data and your app; for example, by making test requests that you can refine and then build into your application development process. Dropsource is designed to make it quick and easy to connect an app to an API, and we’ve found certain tools helpful when integrating web data with the platform, both within our own internal projects and those we help our users bring to life.

Mocking Data with Stoplight

Stoplight API Designer, from Stoplight.io

When building requests to APIs, Dropsource uses OpenAPI (formerly Swagger), an open specification standard for describing the endpoints in an API in a machine-readable format that applications can consume. One third party tool we’ve frequently found useful is Stoplight.io, both for testing API endpoints using mock data, and for generating your specification file when you’re ready to connect your Dropsource app to your web service.

Stoplight is an API toolkit that allows you to design, host, test, and document your API requests. If you’re developing an API specifically for a mobile app, or are planning to use an existing API in an app you’re building in Dropsource, you’ll typically find making the connections between your app UI / functionality and your requests will require a bit of trial and error.

We’ve found Stoplight particularly useful for testing API requests when your project is still at the prototyping stage, because you can create an API design and test it using mock data before your real data source is in place. Another reason Stoplight provides a valuable integration step for Dropsource apps is that, at the click of a button, it allows you to generate an OpenAPI (formerly Swagger) specification file that you can then import directly into the Dropsource editor.

Automated API Requests

When you add an API specification to your Dropsource project, our platform uses the description of each endpoint in the spec file to build requests into your app code automatically. You can bind the requests to your app UI, sending parameters (for example from user input), and displaying responses in your pages, or optionally processing them within your app functionality. You can even detect and handle failed API requests using error status codes, and can authenticate your requests using a variety of auth schemes. Whatever you define in your specification, Dropsource will expose inside the editor, so that you can build your API design into your app’s user experience.

Using Mock Data from Stoplight in Dropsource

We created an easy to follow tutorial in our help center outlining how to create a simple mock data API in Stoplight, add a request with some sample data, export API documentation, and plug that spec right into Dropsource. By following the tutorial, you’ll learn the essentials in building data-driven apps in Dropsource, making an API request that will display the sample data from Stoplight in your app’s pages via a few straightforward steps.

Want to try it for yourself? Just click here to explore the tutorial.