add DTO object generator

This commit is contained in:
marys
2026-06-03 15:08:11 +02:00
parent 4daa2241c7
commit dd31750e1a
17 changed files with 190 additions and 3306 deletions
+122
View File
@@ -0,0 +1,122 @@
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
-70
View File
@@ -1,70 +0,0 @@
# .venv/bin/asyncapi-python-codegen asyncapi.yaml out --force-write
# kouknout na FastStream
# https://nats.io/blog/nats-supported-by-faststream/#writing-app-code
# https://github.com/asyncapi/python-paho-template
# https://www.asyncapi.com/docs/tools/generator/generator-template
# https://www.asyncapi.com/docs/tools/generator/generator-template --force-write
# https://pypi.org/project/asyncapi-python/
# https://github.com/G-USI/asyncapi-python
asyncapi: 3.0.0
info:
title: Job Events
version: 1.0.0
servers:
nats_localhost:
host: localhost:4222
protocol: nats
channels:
run_test:
address: mtr_test.run_test
messages:
run_test:
$ref: '#/components/messages/mtr_request'
return_uuid:
address: null
messages:
run_test:
$ref: '#/components/messages/mtr_uuid'
operations:
get_mtr_test:
action: send
channel:
$ref: '#/channels/run_test'
reply:
address:
location: "$message.header#/replayTo"
channel:
$ref: '#/channels/return_uuid'
components:
schemas:
mtr_request_schema:
payload:
type: object
properties:
to_server:
type: string
mtr_sleep:
type: integer
mtr_uuid_schema:
payload:
type: object
properties:
uuid:
type: string
messages:
mtr_request:
name: mtr_request
payload:
type: object
# required:
# - to_server
$ref: '#/components/schemas/mtr_request_schema'
mtr_uuid:
payload:
$ref: '#/components/schemas/mtr_uuid_schema'