Files
gh-jeremylongshore-claude-c…/skills/skill-adapter/assets/example_contract.json
2025-11-29 18:52:09 +08:00

129 lines
3.4 KiB
JSON

{
"_comment": "Pact contract example generated by the api-contract-generator plugin.",
"provider": {
"name": "Article Service"
},
"consumer": {
"name": "Article Reader"
},
"interactions": [
{
"_comment": "An interaction represents a single request-response pair.",
"description": "a request for an article with ID 123",
"request": {
"method": "GET",
"path": "/articles/123",
"headers": {
"Accept": "application/json"
}
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"body": {
"_comment": "Example article data.",
"id": 123,
"title": "My First Article",
"content": "This is the content of my first article.",
"author": "John Doe",
"publicationDate": "2024-01-01T00:00:00Z",
"tags": ["news", "technology"]
},
"matchingRules": {
"_comment": "Define rules for matching request and response elements.",
"$.body.id": {
"match": "type"
},
"$.body.title": {
"match": "type"
},
"$.body.content": {
"match": "type"
},
"$.body.author": {
"match": "type"
},
"$.body.publicationDate": {
"match": "regex",
"regex": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"
},
"$.body.tags": {
"match": "type"
}
}
},
"providerStates": [
{
"name": "an article with ID 123 exists",
"params": {
"articleId": 123
}
}
]
},
{
"_comment": "Another interaction representing a request for all articles.",
"description": "a request for all articles",
"request": {
"method": "GET",
"path": "/articles",
"headers": {
"Accept": "application/json"
},
"query": "page=1&limit=10"
},
"response": {
"status": 200,
"headers": {
"Content-Type": "application/json; charset=utf-8"
},
"body": [
{
"id": 123,
"title": "My First Article",
"content": "This is the content of my first article.",
"author": "John Doe",
"publicationDate": "2024-01-01T00:00:00Z",
"tags": ["news", "technology"]
},
{
"id": 456,
"title": "Another Article",
"content": "This is another article.",
"author": "Jane Smith",
"publicationDate": "2024-01-05T10:00:00Z",
"tags": ["sports", "local"]
}
],
"matchingRules": {
"$.body[*].id": {
"match": "type"
},
"$.body[*].title": {
"match": "type"
},
"$.body[*].content": {
"match": "type"
},
"$.body[*].author": {
"match": "type"
},
"$.body[*].publicationDate": {
"match": "regex",
"regex": "^\\d{4}-\\d{2}-\\d{2}T\\d{2}:\\d{2}:\\d{2}Z$"
},
"$.body[*].tags": {
"match": "type"
}
}
}
}
],
"metadata": {
"pactSpecification": {
"version": "3.0.0"
}
}
}