Skip to content

Commit 144a1e1

Browse files
committed
Add empty mapping example
As suggested by @tetron, thanks!
1 parent 2efb203 commit 144a1e1

File tree

1 file changed

+24
-6
lines changed

1 file changed

+24
-6
lines changed

concepts.md

Lines changed: 24 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -93,8 +93,12 @@ https://github.com/common-workflow-language/common-workflow-language/tree/master
9393

9494
### <a name="map">`map<>`</a>
9595

96-
The "type: `array<ComplexType> | map<key_field, ComplexType>`" syntax in the CWL
97-
specifications means there are two or more ways to write the given value.
96+
Note: This section is non-normative.
97+
98+
The
99+
> type: array<ComplexType> |
100+
> map<`key_field`, ComplexType>
101+
syntax in the CWL specifications means there are two or more ways to write the given value.
98102

99103
Option one is a array and is the most verbose option.
100104
In our example here we use the generic`ComplexType`, but
@@ -113,6 +117,7 @@ some_cwl_field:
113117
- key_field: a_complex_type2
114118
field2: foo2
115119
field3: bar2
120+
- key_field: a_complex_type3
116121
```
117122

118123
Specific example using [Workflow.inputs](Workflow.html#InputParameter):
@@ -127,11 +132,15 @@ inputs:
127132
- id: workflow_input02
128133
type: File
129134
format: http://edamontology.org/format_2572
135+
- id: workflow_input03
130136
```
131137

132138
Option two is enabled by the `map<…>` syntax. Instead of an array of entries we
133139
use a mapping, where one field of the `ComplexType` (here named `key_field`)
134-
becomes the key in the map, and its value is the rest of the `ComplexType`.
140+
becomes the key in the map, and its value is the rest of the `ComplexType`
141+
without the key field. If all of the other fields of the `ComplexType` are
142+
optional and unneeded, then we can indicate this with an empty mapping as the
143+
value: `a_complex_type3: {}`
135144

136145
Generic example:
137146
```
@@ -142,6 +151,7 @@ some_cwl_field:
142151
a_complex_type2:
143152
field2: foo2
144153
field3: bar2
154+
a_complex_type3: {} # we accept the defualt values for "field2" and "field3"
145155
```
146156

147157
Specific example using [Workflow.inputs](Workflow.html#InputParameter):
@@ -156,6 +166,7 @@ inputs:
156166
workflow_input02:
157167
type: File
158168
format: http://edamontology.org/format_2572
169+
workflow_input03: {} # we accept the default value for "type"
159170
```
160171

161172
Sometimes we have a third and even more compact option denoted like this:
@@ -170,6 +181,7 @@ Here's the generic example:
170181
some_cwl_field:
171182
a_complex_type1: foo # we accept the default value for field3
172183
a_complex_type2: foo2 # we accept the default value for field3
184+
a_complex_type3: {} # we accept the defualt values for "field2" and "field3"
173185
```
174186

175187
Specific example using [Workflow.inputs](Workflow.html#InputParameter):
@@ -181,6 +193,7 @@ Specific example using [Workflow.inputs](Workflow.html#InputParameter):
181193
inputs:
182194
workflow_input01: string
183195
workflow_input02: File # we accept the default of no File format
196+
workflow_input03: {} # we accept the default of no "type"
184197
```
185198

186199

@@ -194,6 +207,8 @@ some_cwl_field:
194207
field2: foo2
195208
field3: bar2 # we did not accept the default value for field3
196209
# so we had to use the slightly expanded syntax
210+
my_complex_type3: {} # as before, we accept the default values for both
211+
# "field2" and "field3"
197212
```
198213

199214
Specific example using [Workflow.inputs](Workflow.html#InputParameter):
@@ -204,16 +219,19 @@ Specific example using [Workflow.inputs](Workflow.html#InputParameter):
204219
```
205220
inputs:
206221
workflow_input01: string
207-
workflow_input02: # we use the longer way
208-
type: File # because we want to specify the format too
222+
workflow_input02: # we use the longer way
223+
type: File # because we want to specify the "format" too
209224
format: http://edamontology.org/format_2572
225+
workflow_input03: {} # back to the short form as this entry
226+
# uses the default of no "type" just like the prior
227+
# examples
210228
```
211229

212230

213231
Note: The `map<…>` version is optional, the verbose option #1 is always allowed,
214232
but for presentation reasons option 3 and 2 may be preferred by human readers.
215233

216-
Another explanation, aimed at implementors, is in the
234+
The normative explanation for these variations, aimed at implementors, is in the
217235
[Schema Salad specification](SchemaSalad.html#Identifier_maps).
218236

219237
## Identifiers

0 commit comments

Comments
 (0)