File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -138,26 +138,36 @@ module Decode =
138138 /// Decode an InputRecordSchema from a YAMLElement
139139 and inputRecordSchemaDecoder : ( YAMLiciousTypes.YAMLElement -> InputRecordSchema ) =
140140 Decode.object ( fun get ->
141- // Decode fields using Overflow to get the map form
142- let fieldsDict =
143- get.Optional.Field
144- " fields"
145- ( Decode.object ( fun get2 -> get2.Overflow.FieldList []))
146-
141+ // Try to decode fields as an array (flow-style) or as a map (block-style)
147142 let decodedFields =
148- match fieldsDict with
149- | Some dict ->
150- let fields = ResizeArray< InputRecordField>()
151- for kvp in dict do
152- let fieldType = cwlTypeDecoder' kvp.Value
153-
154- fields.Add({
155- Name = kvp.Key
156- Type = fieldType
157- Doc = None
158- Label = None
159- })
160- Some fields
143+ // Get the fields element directly
144+ let fieldsElement = get.Optional.Field " fields" id
145+
146+ match fieldsElement with
147+ | Some ( YAMLElement.Object []) ->
148+ // Empty array case: fields: []
149+ Some ( ResizeArray< InputRecordField>())
150+ | Some element ->
151+ // Try to decode as an array (flow-style: [{name: x, type: y}])
152+ try
153+ let fields = Decode.resizearray inputRecordFieldDecoder element
154+ Some fields
155+ with _ ->
156+ // Fall back to map form (block-style: {x: y})
157+ try
158+ let dict = Decode.object ( fun get2 -> get2.Overflow.FieldList []) element
159+ let fields = ResizeArray< InputRecordField>()
160+ for kvp in dict do
161+ let fieldType = cwlTypeDecoder' kvp.Value
162+
163+ fields.Add({
164+ Name = kvp.Key
165+ Type = fieldType
166+ Doc = None
167+ Label = None
168+ })
169+ Some fields
170+ with _ -> None
161171 | None -> None
162172
163173 {
You can’t perform that action at this time.
0 commit comments