---
title: "run an OpenAPI spec as a contract test against a live service"
method: PUT
path: "/mockserver/contractTest"
tags: ["contract"]
---

# run an OpenAPI spec as a contract test against a live service

`PUT /mockserver/contractTest`

## Request

- Base URL: `http://localhost:1080`
- URL: `http://localhost:1080/mockserver/contractTest`
- Auth: none declared

Runs each operation of an OpenAPI specification against a live service and validates that the actual responses conform to the spec. Supply the spec as a URL, file path or inline JSON/YAML ("spec", or its alias "specUrlOrPayload"), the base URL of the service under test ("baseUrl"), and optionally a single "operationId" to restrict the run. The target host is subject to the SSRF policy (forwardProxyBlockPrivateNetworks). Returns a per-operation pass/fail report.

## Request body

- ContractTestRequest: request to run an OpenAPI spec as a contract test against a live service
  - `spec` string, required: the OpenAPI spec as a URL, file path, or inline JSON/YAML (alias: specUrlOrPayload)
  - `specUrlOrPayload` string: alias for spec
  - `baseUrl` string, required: base URL of the live service under test; any path prefix is prepended to each operation path
  - `operationId` string: optional — restrict the run to a single operation; when absent all operations are tested

## Response `200`

contract test completed (inspect allPassed and per-operation results)

- ContractTestReport: the result of a contract test run
  - `baseUrl` string
  - `totalOperations` integer
  - `passed` integer
  - `failed` integer
  - `allPassed` boolean
  - `results` object[]
    - `operationId` string
    - `method` string
    - `path` string
    - `statusCodeReceived` integer
    - `passed` boolean
    - `validationErrors` string[]

## Other responses

- `400`: missing/blank spec or baseUrl, invalid baseUrl, or an error running the contract test
- `403`: contract test blocked by SSRF policy (target is a private/loopback/metadata address)
- `501`: contract testing not available (no HTTP client wired)

---

[API](https://skmtc.dev/mock-server/apis/mockserver-api.md) · [All operations](https://skmtc.dev/mock-server/apis/mockserver-api/llms.txt) · [OpenAPI document](https://skmtc.dev/mock-server/apis/mockserver-api/revisions/9239b693996e?raw)
