05/10/2017 Featured Christopher Reichert

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

  2. Create a deployment in Assertible from CI

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

Assertible import form GitHub API dry run

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.

Assertible status check on GitHub pull request

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

Define and test your web service with Assertible Track and test API deployments across environments Schedule API monitoring and failure alerts

Reduce bugs in web applications by using Assertible to create an automated QA pipeline that helps you catch failures & ship code faster.

Sign up for free