Skip to content

Commit 39364e4

Browse files
committed
fix: refactor step schema to isolate operation-specific fields and deduplicate operation step parameter rules
1 parent 0daa4d7 commit 39364e4

9 files changed

Lines changed: 127 additions & 34 deletions

src/schemas/validation/schema.yaml

Lines changed: 19 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -172,9 +172,6 @@ $defs:
172172
description:
173173
description: A description of the step. CommonMark syntax MAY be used for rich text representation
174174
type: string
175-
operationId:
176-
description: The name of an existing, resolvable operation, as defined with a unique operationId and existing within one of the sourceDescriptions
177-
type: string
178175
timeout:
179176
description: The duration in milliseconds to wait before timing out the step
180177
type: integer
@@ -233,29 +230,28 @@ $defs:
233230
- $ref: '#/$defs/selector-object'
234231
required:
235232
- stepId
233+
operation-step-parameters:
234+
type: array
235+
uniqueItems: true
236+
items:
237+
oneOf:
238+
- $ref: '#/$defs/reusable-object'
239+
- $ref: '#/$defs/parameter-object'
240+
required:
241+
- in
236242
openapi-step-object:
237243
allOf:
238244
- $ref: '#/$defs/step-object-base'
239245
- type: object
240246
properties:
247+
operationId:
248+
description: The name of an existing, resolvable operation, as defined with a unique operationId and existing within one of the sourceDescriptions
249+
type: string
241250
operationPath:
242251
description: A reference to a Source combined with a JSON Pointer to reference an operation
243252
type: string
244-
- if:
245-
oneOf:
246-
- required:
247-
- operationPath
248-
- required:
249-
- operationId
250-
then:
251-
properties:
252-
parameters:
253-
items:
254-
oneOf:
255-
- $ref: '#/$defs/reusable-object'
256-
- $ref: '#/$defs/parameter-object'
257-
required:
258-
- in
253+
parameters:
254+
$ref: '#/$defs/operation-step-parameters'
259255
- oneOf:
260256
- required:
261257
- operationId
@@ -268,6 +264,9 @@ $defs:
268264
- $ref: '#/$defs/step-object-base'
269265
- type: object
270266
properties:
267+
operationId:
268+
description: The name of an existing, resolvable operation, as defined with a unique operationId and existing within one of the sourceDescriptions
269+
type: string
271270
channelPath:
272271
description: A reference to a Source combined with a JSON Pointer to reference an async channel
273272
type: string
@@ -284,23 +283,10 @@ $defs:
284283
enum:
285284
- send
286285
- receive
286+
parameters:
287+
$ref: '#/$defs/operation-step-parameters'
287288
required:
288289
- action
289-
- if:
290-
oneOf:
291-
- required:
292-
- operationId
293-
- required:
294-
- channelPath
295-
then:
296-
properties:
297-
parameters:
298-
items:
299-
oneOf:
300-
- $ref: '#/$defs/reusable-object'
301-
- $ref: '#/$defs/parameter-object'
302-
required:
303-
- in
304290
- if:
305291
required:
306292
- correlationId

tests/schema/fail/invalid-async-correlation-id-non-receive-action.arazzo.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
arazzo: 1.1.0
22
info:
3-
title: Minimal Arazzo Example for AsyncAPI
3+
title: CorrelationId should only be present when action is receive
44
version: 1.0.0
55
sourceDescriptions:
66
- name: exampleAPI
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
arazzo: 1.1.0
2+
info:
3+
title: Async step parameter requires in
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: eventAPI
7+
url: https://events.com/asyncapi.yaml
8+
type: asyncapi
9+
workflows:
10+
- workflowId: asyncWorkflow
11+
steps:
12+
- stepId: sendEvent
13+
operationId: $sourceDescriptions.eventAPI.orderCreated
14+
action: send
15+
parameters:
16+
- name: correlationId
17+
value: abc123
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
arazzo: 1.1.0
2+
info:
3+
title: OpenAPI step parameter requires in
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: userAPI
7+
url: https://users.com/openapi.yaml
8+
type: openapi
9+
workflows:
10+
- workflowId: openapiWorkflow
11+
steps:
12+
- stepId: getUsers
13+
operationId: $sourceDescriptions.userAPI.listUsers
14+
parameters:
15+
- name: limit
16+
value: 10
17+
successCriteria:
18+
- condition: $statusCode == 200

tests/schema/fail/invalid-workflow-step-with-operationId.arazzo.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ arazzo: 1.1.0
22
info:
33
title: Workflow step cannot have operationId
44
version: 1.0.0
5+
sourceDescriptions:
6+
- name: exampleAPI
7+
url: https://example.com/asyncapi.yaml
8+
type: asyncapi
59
workflows:
610
- workflowId: parentWorkflow
711
steps:

tests/schema/fail/invalid-workflow-success-criteria.arazzo.yaml

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,10 @@ arazzo: 1.1.0
22
info:
33
title: Invalid workflow step success criteria
44
version: 1.0.0
5+
sourceDescriptions:
6+
- name: exampleAPI
7+
url: https://example.com/asyncapi.yaml
8+
type: asyncapi
59
workflows:
610
- workflowId: parentWorkflow
711
steps:
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
arazzo: 1.1.0
2+
info:
3+
title: Async step parameter with in
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: eventAPI
7+
url: https://events.com/asyncapi.yaml
8+
type: asyncapi
9+
workflows:
10+
- workflowId: asyncWorkflow
11+
steps:
12+
- stepId: sendEvent
13+
operationId: $sourceDescriptions.eventAPI.orderCreated
14+
action: send
15+
parameters:
16+
- name: correlationId
17+
in: header
18+
value: abc123
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
arazzo: 1.1.0
2+
info:
3+
title: OpenAPI step parameter with in
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: userAPI
7+
url: https://users.com/openapi.yaml
8+
type: openapi
9+
workflows:
10+
- workflowId: openapiWorkflow
11+
steps:
12+
- stepId: getUsers
13+
operationId: $sourceDescriptions.userAPI.listUsers
14+
parameters:
15+
- name: limit
16+
in: query
17+
value: 10
18+
successCriteria:
19+
- condition: $statusCode == 200
Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
arazzo: 1.1.0
2+
info:
3+
title: Workflow step parameter does not require in
4+
version: 1.0.0
5+
sourceDescriptions:
6+
- name: userAPI
7+
url: https://users.com/openapi.yaml
8+
type: openapi
9+
workflows:
10+
- workflowId: parentWorkflow
11+
steps:
12+
- stepId: nestedWorkflow
13+
workflowId: childWorkflow
14+
parameters:
15+
- name: userId
16+
value: 10
17+
- workflowId: childWorkflow
18+
inputs:
19+
type: object
20+
properties:
21+
userId:
22+
type: integer
23+
steps:
24+
- stepId: childStep
25+
operationId: $sourceDescriptions.userAPI.listUsers
26+
successCriteria:
27+
- condition: $statusCode == 200

0 commit comments

Comments
 (0)