XML Plugin
The XML plugin adds support for XML request and response bodies in Drift.
1. When to Use This Plugin
Enable the XML plugin when your API specification defines operations that send or receive application/xml payloads.
2. Registering the Plugin
Add the plugin to the plugins section of your Drift file:
plugins:
- name: oas
- name: xml
3. Sending XML Bodies
XML request bodies must be sent as structured content. Drift maps the object to XML using the schema definition in your OpenAPI specification.
operations:
createPet_Success:
target: petstore-oas:addPet
description: "Create a new pet with a valid payload"
parameters:
headers:
content-type: application/xml
request:
body:
Pet:
id: 99
name: "bluey"
photoUrls:
- "https://example.com/pets/bluey.jpg"
status: "available"
expected:
response:
statusCode: 200
If the media type is defined in your OpenAPI specification, Drift uses that definition and you do not need to repeat the Content-Type header.
Body syntax
The structured body maps to XML as follows:
- A key prefixed with
@sets an XML attribute:"@id": 10becomes<element id="10">. - A plain key sets a child element:
name: blueybecomes<name>bluey</name>. "#text"sets an explicit text node:"#text": 10.99becomes the text content of the element.
4. Supported OpenAPI XML Schema Features
Drift supports these OpenAPI XML schema features:
Supported:
xml:
attribute: true
xml:
wrapped: true
Not supported:
xml:
prefix: "smp"
namespace: "http://example.com/schema"
Drift does not support XML namespace or prefix matching.
5. Validation Behavior
The XML plugin enables Drift to work with XML payloads defined in your API specification during request execution and response validation.