openapi.yaml
YAML · 153 рядків
1openapi: 3.1.0
2info:
3 title: FLOW External API
4 version: 1.0.0
5 description: Versioned API for external services to fire workflow events and read FLOW tasks.
6servers:
7 - url: /api/external/v1
8tags:
9 - name: Events
10 - name: Tasks
11paths:
12 /events:
13 post:
14 tags: [Events]
15 summary: Fire a FLOW event
16 operationId: fireEvent
17 parameters:
18 - name: responseMode
19 in: query
20 schema: { type: string, enum: [async, sync], default: async }
21 description: Async accepts the event; sync waits for processing and an optional CLIENT_RESPONSE.
22 requestBody:
23 required: true
24 content:
25 application/json:
26 schema: { $ref: '#/components/schemas/EventEnvelope' }
27 example:
28 event: ITEM_SCANNED
29 entityType: warehouse_item
30 entityId: ITEM-58291
31 userId: 42
32 payload:
33 barcode: '0123456789012'
34 locationId: DOCK-3
35 responses:
36 '202':
37 description: Event durably accepted for asynchronous processing.
38 content:
39 application/json:
40 schema: { $ref: '#/components/schemas/EventAccepted' }
41 '204': { description: Event processed synchronously without a CLIENT_RESPONSE body. }
42 '400':
43 description: Invalid event or workflow processing failure.
44 content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
45 '404':
46 description: No active task or fallback workflow accepted the event.
47 content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
48 '409':
49 description: Event is not allowed, ambiguous, or conflicts with active task state.
50 content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
51 default:
52 description: Workflow-defined CLIENT_RESPONSE status and body.
53 /tasks:
54 get:
55 tags: [Tasks]
56 summary: Find tasks
57 operationId: findTasks
58 parameters:
59 - { name: taskId, in: query, schema: { type: string } }
60 - { name: entityType, in: query, schema: { type: string }, example: warehouse_item }
61 - { name: entityId, in: query, schema: { type: string }, example: ITEM-58291 }
62 - name: userId
63 in: query
64 description: Exact person assignee ID. Group assignments do not match.
65 schema: { type: string }
66 - { name: type, in: query, schema: { type: string }, example: UNLOAD }
67 - name: status
68 in: query
69 description: One or more comma-separated statuses.
70 schema: { type: string, example: 'open,in_progress' }
71 - { name: limit, in: query, schema: { type: integer, minimum: 1, maximum: 200, default: 50 } }
72 - { name: offset, in: query, schema: { type: integer, minimum: 0, default: 0 } }
73 responses:
74 '200':
75 description: Matching task summaries ordered by most recently updated.
76 content: { application/json: { schema: { $ref: '#/components/schemas/TaskPage' } } }
77 /tasks/{taskId}:
78 get:
79 tags: [Tasks]
80 summary: Get a task by ID
81 operationId: getTask
82 parameters:
83 - { name: taskId, in: path, required: true, schema: { type: string } }
84 responses:
85 '200':
86 description: Task summary.
87 content: { application/json: { schema: { $ref: '#/components/schemas/Task' } } }
88 '404':
89 description: Task not found.
90 content: { application/json: { schema: { $ref: '#/components/schemas/Error' } } }
91components:
92 schemas:
93 EventEnvelope:
94 type: object
95 required: [event, entityType, entityId, userId, payload]
96 additionalProperties: false
97 properties:
98 event: { type: string, description: Event name configured on a FLOW Event block. }
99 entityType: { type: string, description: Entity category used for FLOW task routing. }
100 entityId: { type: [string, integer], description: Entity identifier used for FLOW task routing. }
101 userId: { type: number, description: Numeric ID of the user who fired the event. }
102 payload:
103 type: object
104 description: Event-specific data.
105 additionalProperties: true
106 EventAccepted:
107 type: object
108 required: [status]
109 properties:
110 status: { type: string, example: accepted }
111 Assignee:
112 type: object
113 properties:
114 type: { type: string, enum: [person, group] }
115 id: { type: string }
116 Task:
117 type: object
118 required: [id, status]
119 properties:
120 id: { type: string }
121 executionId: { type: [string, 'null'] }
122 entityType: { type: [string, 'null'] }
123 entityId: { type: [string, 'null'] }
124 parentTaskId: { type: [string, 'null'] }
125 orderId: { type: [string, 'null'] }
126 type: { type: [string, 'null'] }
127 handlerWorkflowId: { type: [string, 'null'] }
128 handlerWorkflowVersion: { type: [integer, string, 'null'] }
129 title: { type: [string, 'null'] }
130 description: { type: [string, 'null'] }
131 priority: { type: [string, 'null'] }
132 status: { type: string, enum: [open, in_progress, completed, cancelled] }
133 state: { type: [string, 'null'] }
134 progress: { type: [string, 'null'] }
135 assignee: { oneOf: [{ $ref: '#/components/schemas/Assignee' }, { type: 'null' }] }
136 version: { type: integer }
137 createdAt: { type: [string, 'null'], format: date-time }
138 updatedAt: { type: [string, 'null'], format: date-time }
139 completedAt: { type: [string, 'null'], format: date-time }
140 TaskPage:
141 type: object
142 required: [tasks, total, limit, offset]
143 properties:
144 tasks: { type: array, items: { $ref: '#/components/schemas/Task' } }
145 total: { type: integer, minimum: 0 }
146 limit: { type: integer, minimum: 1, maximum: 200 }
147 offset: { type: integer, minimum: 0 }
148 Error:
149 type: object
150 properties:
151 code: { type: string }
152 error: { type: string }
153