-
-
Notifications
You must be signed in to change notification settings - Fork 5
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
YAML map/dictionary ordering MUST be preserved #62
Comments
👎 as proposed https://yaml.org/spec/1.2.2/#3221-mapping-key-order
The correct way to do this per the YAML spec is like this:
Which is equivalent to
(per Example 8.19 Compact Block Mappings in https://yaml.org/spec/1.2.2/#822-block-mappings) It wouldn't be a huge reach to make schema salad recognize these single key dicts as a special case, this would be a extension on "idmaps" which is how maps are converted to list of objects right now. So my counter proposal is to use the recommended YAML approach in situations where we want to preserve order but want a more convenient syntax for writing identifiers. It is also worth noting that the post-processed document that to which schema and JSON-LD context applies, many things that are converted to lists (in particular, the |
@tetron I agree, contradicting the YAML spec is not nice. However it would be a really positive user experience boost, and less clunky that their recommended lists of single-entry dicts. Lets say there was a stand-along tool that would convert the map syntax in selected fields ( Some examples to motivate the discussion: Original inputs:
my_input: File
other_input:
type: string
label: This is important! would have to become the following in CWL v1.3+ to preserve order inputs:
- my_input: File
- other_input:
- type: string
- label: This important! By my proposal the original document does not need re-writing to ensure the ordering of the inputs:
- { id: my_input, type: File }
- id: other_input
type: string
label: This is important! |
Unless the ordering of label and type is relevant here, you'd only need to order the input items themselves, writing it like this:
Schema salad parsers exist for C++, D, C#, Java, Python, and Typescript. I think it would be useful to investigate which YAML parsers (besides I understand what you're trying to do but I think this potentially creates a huge headache for implementers, when we already have two other proposed solutions using the explicit sequence syntax that don't have any of these problems. |
With common-workflow-language/schema_salad#899 merged ruaml.yaml / cwl-utils & typescript / cwl-ts-auto will preserve the mapping order |
I have confirmed that yaml-cpp / cwl-cpp-auto preserve the order of maps (though I ran into some other issues with cwl-cpp-auto itself) |
@tetron I will keep testing, but given the trend of order-preserving maps I suggest the following:
|
for UI listings of
inputs
,outputs
, record schemafields
, and workflowsteps
.Todo:
The text was updated successfully, but these errors were encountered: