123 lines
2.7 KiB
YAML
123 lines
2.7 KiB
YAML
asyncapi: 3.0.0
|
|
info:
|
|
title: Order Service (NATS)
|
|
version: 1.0.0
|
|
description: Event-driven order service using NATS
|
|
|
|
servers:
|
|
nats:
|
|
host: nats://localhost:4222
|
|
protocol: nats
|
|
description: Local NATS server
|
|
|
|
channels:
|
|
order.created:
|
|
address: order.created
|
|
messages:
|
|
OrderCreated:
|
|
$ref: '#/components/messages/OrderCreated'
|
|
|
|
order.placed:
|
|
address: order.placed
|
|
messages:
|
|
OrderPlaced:
|
|
$ref: '#/components/messages/OrderPlaced'
|
|
|
|
operations:
|
|
onOrderCreated:
|
|
action: receive
|
|
channel:
|
|
$ref: '#/channels/order.created'
|
|
messages:
|
|
- $ref: '#/channels/order.created/messages/OrderCreated'
|
|
|
|
onOrderPlaced:
|
|
action: send
|
|
channel:
|
|
$ref: '#/channels/order.placed'
|
|
messages:
|
|
- $ref: '#/channels/order.placed/messages/OrderPlaced'
|
|
|
|
components:
|
|
messages:
|
|
OrderCreated:
|
|
name: OrderCreated
|
|
title: Order Created
|
|
summary: Event emitted when an order is created.
|
|
payload:
|
|
$ref: '#/components/schemas/OrderCreated'
|
|
|
|
OrderPlaced:
|
|
name: OrderPlaced
|
|
title: Order Placed
|
|
summary: Event emitted when an order is placed.
|
|
payload:
|
|
$ref: '#/components/schemas/OrderPlaced'
|
|
|
|
schemas:
|
|
OrderCreated:
|
|
$id: OrderCreated
|
|
title: OrderCreated
|
|
type: object
|
|
required:
|
|
- orderId
|
|
- customerId
|
|
- createdAt
|
|
properties:
|
|
orderId:
|
|
type: string
|
|
format: uuid
|
|
example: "550e8400-e29b-41d4-a716-446655440000"
|
|
customerId:
|
|
type: string
|
|
example: "cust-123"
|
|
createdAt:
|
|
type: string
|
|
format: date-time
|
|
example: "2025-06-03T12:00:00Z"
|
|
status:
|
|
type: string
|
|
enum:
|
|
- created
|
|
- pending
|
|
- confirmed
|
|
default: created
|
|
|
|
OrderPlaced:
|
|
$id: OrderPlaced
|
|
title: OrderPlaced
|
|
type: object
|
|
required:
|
|
- orderId
|
|
- customerId
|
|
- items
|
|
- placedAt
|
|
properties:
|
|
orderId:
|
|
type: string
|
|
format: uuid
|
|
example: "550e8400-e29b-41d4-a716-446655440001"
|
|
customerId:
|
|
type: string
|
|
example: "cust-123"
|
|
items:
|
|
type: array
|
|
items:
|
|
type: object
|
|
required:
|
|
- productId
|
|
- quantity
|
|
properties:
|
|
productId:
|
|
type: string
|
|
quantity:
|
|
type: integer
|
|
minimum: 1
|
|
placedAt:
|
|
type: string
|
|
format: date-time
|
|
example: "2025-06-03T12:05:00Z"
|
|
totalAmount:
|
|
type: number
|
|
format: double
|