Applies to ReadyAPI 2.7, last modified on May 14, 2019

The Swagger Compliance assertion verifies that the response corresponds with the specified definition. The assertion supports the following specifications:

  • Swagger 2.0 (also known as OpenAPI 2.0)

  • OpenAPI 3.0.0

Availability

In... Checks... To learn more...
SoapUIĀ functional tests The response. See Working With Assertions in SoapUI.
ServiceV The request. See Assertions in ServiceV.

Create an assertion

Follow these steps:

SoapUI: The Assertions panel

Click the image to enlarge it.

  1. Open a test step.

  2. Click Add assertion.

In the New Assertions dialog, search for the Swagger Compliance assertion or select it manually in the Compliance, Status and Standards category.

Follow these steps:

ServiceV operation: The Assertions panel

Click the image to enlarge it.

  1. Open the virtual service.

  2. Select the operation you want to assert.

  3. Click in the Assertions panel.

In the New Assertions dialog, search for the Swagger Compliance Assertion assertion or select it manually in the Compliance, Status and Standards category.

You cannot apply this assertion to the entire virtual service, you can apply it only to individual operations.

Setting up properties

  1. In the Swagger URL field, specify the file name or URL of the desired OpenAPI or Swagger specification.

    If the definition's URL requires authentication, you will be prompted to enter credentials.

    Swagger Compliance assertion

    Click the image to enlarge it.

  2. If you enable the Strict Mode option, the assertion will fail if the definition does not contain the appropriate response. If you disable this option, the assertion passes if the response code is not specified in the definition.

  • How the assertion works:

    1. The assertion gets a response code. Then, it searches for the corresponding status code specified in the definition and checks if the response has an appropriate content-type.

      If the definition specifies the response body, the assertion verifies if the response body coincides with the specified schema.

    2. (Only for Open 3.0.0 specifications) If the response status code is not defined in the definition, the assertion compares the response against the default response.

      Currently, the assertion does not support the range of responses.
    3. By default, if the assertion cannot find an appropriate HTTP status code, it passes. If you want the assertion to fail in such cases, enable the Strict mode option.

  • When an assertion runs for the first time, ReadyAPI loads the definition into an internal cache. During the following runs, the assertion uses a cached version of the definition. ReadyAPI clears the cache when it is closed.

Add other schema compliance assertions:

See Also

Creating Project From OpenAPI or Swagger Definition
Compliance Assertions

Highlight search results