-
Notifications
You must be signed in to change notification settings - Fork 166
Description
What would you like to be added:
Currently the DSL states for the switch case that: when
A runtime expression used to determine whether or not the case matches.
If not set, the case will be matched by default if no other case match.
Note that there can be only one default case, all others MUST set a condition.
This wording implies that the default case does not follow ordering because it is only matched by default if no other case match
therefore these two would be equivalent:
document:
dsl: 1.0.0-alpha1
namespace: test
name: sample-workflow
version: 0.1.0
do:
- processOrder:
switch:
- case1:
when: .orderType == "electronic"
then: processElectronicOrder
- case2:
when: .orderType == "physical"
then: processPhysicalOrder
- default:
then: handleUnknownOrderTypeand
document:
dsl: 1.0.0-alpha1
namespace: test
name: sample-workflow
version: 0.1.0
do:
- processOrder:
switch:
- case1:
when: .orderType == "electronic"
then: processElectronicOrder
- default:
then: handleUnknownOrderType
- case2:
when: .orderType == "physical"
then: processPhysicalOrderI think this is a bit ambiguous and would change the wording to something like:
If
whenis not specified it always matches.
This would then mean that the only logical place to put a default case would be at the end. Interested in what you folks think.
Note that there can be only one default case, all others MUST set a condition.
This is currently not validated by the schema. I think it could be It is doable with contains. This schema ensures only one case has no when
type: object
required: [ switch ]
unevaluatedProperties: false
properties:
switch:
type: array
minItems: 1
contains:
type: object
minProperties: 1
maxProperties: 1
additionalProperties:
type: object
properties:
when: false
minContains: 0
maxContains: 1
items:
type: object
minProperties: 1
maxProperties: 1
title: SwitchItem
additionalProperties:
type: object
title: SwitchCase
required: [ then ]
properties:
when:
type: string
description: A runtime expression used to determine whether or not the case matches.
then:
$ref: '#/$defs/flowDirective'
description: The flow directive to execute when the case matches.The DSL does not specify what happens when no case matches. Does it fall through to the next task? (I don't think this should be the intended behavior) Or which error is raised?
And my last question: would it make sense to enforce that the default case is named default?
Why is this needed:
Metadata
Metadata
Assignees
Labels
Type
Projects
Status