Complete Configuration Examples
Complete Sample Configuration with All Attributes
This example shows all available configuration options:
- Version 3 (recommended)
- Version 2
- specmatic.yaml
- specmatic.json
version: 3
systemUnderTest:
service:
$ref: "#/components/services/onlineStoreServiceV1"
runOptions:
$ref: "#/components/runOptions/onlineStoreServiceV1Test"
dependencies:
services:
- service:
$ref: "#/components/services/orderServiceV1"
runOptions:
$ref: "#/components/runOptions/orderServiceV1Mock"
components:
sources:
centralContractRepo:
git:
url: https://github.com/specmatic/specmatic-order-contracts.git
services:
onlineStoreServiceV1:
description: Online Store Service (V1)
definitions:
- definition:
source:
$ref: "#/components/sources/centralContractRepo"
specs:
- io/specmatic/examples/store/openapi/online_store_v1.yaml
orderServiceV1:
description: Payment Service (V1)
definitions:
- definition:
source:
$ref: "#/components/sources/centralContractRepo"
specs:
- io/specmatic/examples/store/openapi/api_order_v1.yaml
runOptions:
onlineStoreServiceV1Test:
openapi:
type: test
baseUrl: http://localhost:8080
orderServiceV1Mock:
openapi:
type: mock
baseUrl: http://localhost:8090
adapters:
stub-hoks:
test_load_contract: python test_load_contract.py
stub_load_contract: python stub_load_contract.py
post_specmatic_response_processor: python post_specmatic_response_processor.py
pre_specmatic_request_processor: python pre_specmatic_request_processor.py
pre_specmatic_response_processor: python pre_specmatic_response_processor.py
specmatic:
settings:
backwardCompatibility:
strictMode: true
baseBranch: origin/v3
mock:
delayInMilliseconds: 1000
generative: true
test:
timeoutInMilliseconds: 1000
governance:
report:
formats:
- ctrf
- html
outputDirectory: reports/specmatic
successCriteria:
enforce: true
maxMissedOperationsInSpec: 10
minCoveragePercentage: 75
license:
path: "{LICENSE_PATH:/path/to/license/file-or-directory}"
{
"version": 3,
"systemUnderTest": {
"service": {
"$ref": "#/components/services/onlineStoreServiceV1",
"runOptions": {
"$ref": "#/components/runOptions/onlineStoreServiceV1Test"
}
}
},
"dependencies": {
"services": [
{
"service": {
"$ref": "#/components/services/orderServiceV1",
"runOptions": {
"$ref": "#/components/runOptions/orderServiceV1Mock"
}
}
}
]
},
"components": {
"sources": {
"centralContractRepo": {
"git": {
"url": "https://github.com/specmatic/specmatic-order-contracts.git"
}
}
},
"services": {
"onlineStoreServiceV1": {
"description": "Online Store Service (V1)",
"definitions": [
{
"definition": {
"source": {
"$ref": "#/components/sources/centralContractRepo"
},
"specs": [
"io/specmatic/examples/store/openapi/online_store_v1.yaml"
]
}
}
]
},
"orderServiceV1": {
"description": "Payment Service (V1)",
"definitions": [
{
"definition": {
"source": {
"$ref": "#/components/sources/centralContractRepo"
},
"specs": [
"io/specmatic/examples/store/openapi/api_order_v1.yaml"
]
}
}
]
}
},
"runOptions": {
"onlineStoreServiceV1Test": {
"openapi": {
"type": "test",
"baseUrl": "http://localhost:8080"
}
},
"orderServiceV1Mock": {
"openapi": {
"type": "mock",
"baseUrl": "http://localhost:8090"
}
}
},
"adapters": {
"stub-hoks": {
"test_load_contract": "python test_load_contract.py",
"stub_load_contract": "python stub_load_contract.py",
"post_specmatic_response_processor": "python post_specmatic_response_processor.py",
"pre_specmatic_request_processor": "python pre_specmatic_request_processor.py",
"pre_specmatic_response_processor": "python pre_specmatic_response_processor.py"
}
}
},
"specmatic": {
"settings": {
"backwardCompatibility": {
"strictMode": true,
"baseBranch": "origin/v3",
"mock": {
"delayInMilliseconds": 1000,
"generative": true
},
"test": {
"timeoutInMilliseconds": 1000
}
}
},
"governance": {
"report": {
"formats": [
"ctrf",
"html"
],
"outputDirectory": "reports/specmatic"
},
"successCriteria": {
"enforce": true,
"maxMissedOperationsInSpec": 10,
"minCoveragePercentage": 75
}
},
"license": {
"path": "{LICENSE_PATH:/path/to/license/file-or-directory}"
}
}
}
Configuration Structure Summary (v3)
The complete configuration file supports the following top-level sections:
- version - Configuration version number (latest being
3). - components - Reusable components and definitions. Key sub-sections include:
components.sources- Define contract sources (Git repositories or filesystem locations) used to load API specs.components.services- Service definitions referenced bysystemUnderTestanddependencies. Each service typically containsdefinitionswhich reference asourceand one or morespecs.components.runOptions- Named run configurations (for example,openapi.type=testormock, andbaseUrl)components.adapters- Adapter definitions for massaging contract specifications, or for mutating request/responses from the proxy and/or stub.
- systemUnderTest - Defines the primary system under test. Contains a
components.serviceentry and usually an associatedrunOptionsprofile for executing contract tests. - dependencies - Defines dependent services used for service virtualization. Typically contains a
servicesarray where each item references acomponents.servicesentry and optionalrunOptions(often used to point to mock instances). - specmatic - Specmatic-specific configuration:
specmatic.settings- Runtime and backward-compatibility settings (mock/test options, strictMode, baseBranch, delays, timeouts, etc.).specmatic.governance- Reporting and success criteria (formats, outputDirectory, enforcement thresholds).specmatic.license- License path or configuration.
For detailed information on each section, refer to the linked documentation pages.
- specmatic.yaml
- specmatic.json
version: 2
contracts:
- git:
url: https://github.com/specmatic/specmatic-order-contracts
branch: main
provides:
- com/petstore/store.yaml
consumes:
- com/petstore/payment.yaml
hooks:
hook_name: command
report:
formatters:
- type: text
layout: table
- type: html
layout: table
- type: ctrf
layout: table
types:
APICoverage:
OpenAPI:
successCriteria:
minThresholdPercentage: 100
maxMissedEndpointsInSpec: 0
enforce: true
{
"version": 2,
"contracts": [
{
"git": {
"url": "https://github.com/specmatic/specmatic-order-contracts",
"branch": "main"
},
"provides": [
"com/petstore/store.yaml"
],
"consumes": [
"com/petstore/payment.yaml"
]
}
],
"hooks": {
"hook_name": "command"
},
"report": {
"formatters": [
{
"type": "text",
"layout": "table"
},
{
"type": "html",
"layout": "table"
},
{
"type": "ctrf",
"layout": "table"
}
],
"types": {
"APICoverage": {
"OpenAPI": {
"successCriteria": {
"minThresholdPercentage": 100,
"maxMissedEndpointsInSpec": 0,
"enforce": true
}
}
}
}
}
}
Configuration Structure Summary (v2)
The complete configuration file supports the following top-level sections:
- version - Configuration version number (latest being
3) contracts- Define API specifications from Git or filesystemadapters- Customizing specifications, requests and responsestest- Contract testing configurationmock- Service virtualization configurationreport- Report generation and formatting optionsexamples- Directories for externalized examples
For detailed information on each section, refer to the specific documentation pages.