OpenAPI/Swagger Import

The OpenAPI specification with Swagger tooling is a popular way to document REST APIs. If you’re running an API in production, the chances are pretty good you’re already using it.

If so, Loadster’s OpenAPI Import feature can make load testing your API a lot easier!

It works by letting you browse your API specification and select endpoints, and automatically creating steps for those endpoints in your Loadster script.

Finding your API Specification URL

To import an endpoint from OpenAPI, you’ll need to locate the URL to your API specification.

You may already be familiar with the Swagger UI, which looks like this:

The Swagger Petstore Demo API
The Swagger Petstore Demo API

That URL at the top points to the API specification. The specification is separate from the UI. It’s typically a JSON or YAML file.

Copy this specification URL, because you’ll need it in order to import your endpoints into Loadster.

Adding an OpenAPI step to your Loadster script

To add an OpenAPI endpoint as a step in your Loadster script, choose the Import OpenAPI… option.

In the modal dialog that follows, paste in the URL to your API specification and click Browse.

A list of the API endpoints detailed in that specification will appear. If you have lots of endpoints, you can optionally filter them with a search phrase to find the one you’re interested in.

Select an endpoint and click Add Step.

A new step will appear in your script, pre-populated with the details from the OpenAPI specification. Depending on the completeness of your API specification, you might need to manually edit the body to add specific values for your load test.

Putting General Barkington up for sale in the Petstore! Sorry General...
Putting General Barkington up for sale in the Petstore! Sorry General...

When should I use OpenAPI Import?

Creating your Loadster steps directly from OpenAPI is a good idea when your API is already documented that way, and you’re looking to save time as opposed to manually creating steps. It also saves you the effort of bouncing back and forth between multiple browser tabs to reference your API documentation, since the endpoints are also available to you in Loadster.

Alternatively, if your API is meant to be hit by a web browser (as with a Single Page Application), then you might save even more time by recording your script with the Loadster Recorder browser extension.

In either case, you can always edit the steps afterwards, for precise control over the requests that Loadster sends to your API.