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, Speedway’s OpenAPI Import feature can make creating scripts for 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 Speedway script.

Finding the URL to your API specification

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 sometimes 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, and it describes each of your API’s endpoints in detail.

Make note of this specification URL, because you’ll need it in order to import your endpoints into Speedway.

Adding an OpenAPI step to your Speedway script

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

Importing from OpenAPI

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.

Filtering Endpoints from OpenAPI

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 test.

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

When does importing from OpenAPI make sense?

Creating your Speedway 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 trouble of bouncing back and forth between multiple browser tabs to reference your API documentation, since the endpoints are also available to you in Speedway.

Alternatively, if your API is meant to be hit by a web browser (as with a single page web application), then you might save even more time by recording your script with the Speedway Recorder browser extension.

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