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 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 Loadster 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:
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 Loadster.
Adding an OpenAPI Step to Your Loadster Script
To add an OpenAPI endpoint as a step in your protocol 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 test.
When Does OpenAPI Import Make Sense?
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 trouble 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 web 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.