This post briefly describes how to continuously test an API using a Swagger / OpenAPI definition from a continuous integration or delivery pipeline. There are only two quick steps:
1. Import a Swagger / OpenAPI definition
Navigate to the import form. If you don't have an account, create one here
Click the Import a Swagger Spec button
Enter the URL your Swagger spec is hosted on (or upload a file)
Click Import spec to see a preview of the import
Click Create service and tests
In the above image, I'm importing a Swagger definition I created for the GitHub API. The import will contain 6 tests and 6 assertions; one for each endpoint.
2. Create a deployment in Assertible from CI
Now that you have a web service created, it's trivial to automate tests from your continuous integration or delivery pipeline using the Deployments API.
The script below creates a new deployment in Assertible. When Assertible recieves a new deployment, it will execute the tests for your web service and register the deployment information.
curl -u $ASSERTIBLE_API_TOKEN: -XPOST https://assertible.com/deployments -d'{
"service" : "'"${ASSERTIBLE_SERVICE_ID}"'",
"environment" : "production",
"version" : "v2"
}'
One cool feature of the deployments API is that it has a seamless integration with GitHub. Not only can you view the status of your tests directly on pull requests, you can also create links to your deployments.
Check out the GitHub deployments integration for more details.
Get started testing your Swagger API now!
Assertible is free to use. Contact us if you have any questions or
feedback!
For a more in-depth Swagger / OpenAPI testing tutorial, check out Testing an API using Swagger
:: Christopher Reichert
Categories
The easiest way to test and
monitor your web services
Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.
Get started with GitHubSign up for freeRecent posts
Tips for importing and testing your API spec with Assertible 05/26/2020
New feature: Encrypted variables 10/30/2019
New feature: Smarter notifications 5/17/2019