OpenAPI (OAS)
The OAS plugin is the primary driver for spec-first verification, mapping OpenAPI 3.0/3.1 operations to Drift test cases.
When to Use This Plugin
Use the OAD plugin when your test suite targets an OpenAPI or Swagger specification. It is the foundational plugin required for most Drift test suites.
Registering the Plugin
Add the plugin to the plugins section of your Drift file:
plugins: - name: oas
Supported Specification Formats
Use the following table to confirm which specification formats Drift supports.
Specification format | Support status |
|---|---|
Swagger 2.0 | Supported |
OpenAPI 3.0 | Supported |
OpenAPI 3.1 | Supported |
OpenAPI 3.2 | Not supported |
Swagger earlier than 2.0 | Not supported |
Mapping Operations
Each test operation in Drift maps to an endpoint in your OpenAPI file via the target property.
operations:
getAllValues:
target: my-oas:getProductByID # Points to the operationId in the OpenAPI document
description: "Get all values"Setting Parameters
Drift automatically maps values from the parameters section of your YAML to the corresponding path, query, or header requirements in the OpenAPI document.
operations:
getProduct:
target: my-oas:getProductByID
parameters:
path:
id: 100
query:
value: testBound Context Values
You can reference metadata from the current operation in the OpenAPI document as a bound value. This is useful for using spec-defined examples as test inputs.
parameters:
path:
id: ${my-oas:operation.parameters.id.example} # Injects the example from the spec
query:
value: ${my-oas:operation.summary} # Injects the summary textSupported Metadata Properties:
tags,summary,description,operationId.parameters(includingexample,examples, and extensions viaext).deprecatedandextensions(viaext).