The journey
| Say this |
What happens |
api-contract |
Author or review an OpenAPI 3.1 contract — endpoints, schemas, error codes |
event-contract |
Author or review an AsyncAPI 2.x event contract — channels and message shapes |
1. Author the contract
Type api-contract and describe the API surface — resources, actions, and the consumers who will call it.
api-contract [orders service: create, get, cancel]
Endpoint Method Schema
/orders POST OrderCreate → OrderResponse
/orders/{order_id} GET → OrderResponse
/orders/{order_id} DELETE → (204 No Content)
Error responses: 400, 404, 409, 500 (Problem schema)
- Output: a first-draft OpenAPI 3.1 contract — endpoints, schemas, and error responses taking shape.
2. Review from the consumer’s perspective
The agent runs a consumer-perspective check against the house standard and surfaces the contract at the contract review gate.
Consumer-perspective check
● All endpoints secured (Bearer token)
● Error shapes consistent (Problem schema)
⚠ POST /orders: missing 409 Conflict for duplicate order_id
Contract review ›
- You decide: approve the contract — check error codes first; a contract covering only 200 responses is incomplete.
- Output: a ratified contract covering the consumer’s full perspective, including all error codes.
3. Commit the versioned contract
The agent emits the ratified contract as a versioned YAML file. For event-driven interfaces, run event-contract through the same review flow before committing.
event-contract [order.placed event]
Channel Message Category
orders/order.placed.v1 OrderPlacedV1 business-event
Envelope: CloudEvents (structured mode)
Payload: order_id · customer_id · items[] · total_amount
- Output: versioned OpenAPI 3.1 or AsyncAPI 2.x contract files committed alongside the services they govern.