Skip to content
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 1.1 indicators #487

Open
am11 opened this issue May 6, 2020 · 2 comments
Open

YAML 1.1 indicators #487

am11 opened this issue May 6, 2020 · 2 comments

Comments

@am11
Copy link
Contributor

am11 commented May 6, 2020

Some of the v1.1 types are supported by the base parser, while others are not: https://yaml.org/type/. For instance, we can implement !!merge or Merge Key Language-Independent Type in base parser and deprecate MergingParser which only does the copy/paste, and disregards the overriding rules per spec.

These are currently not covered by the official spec test suite, so it would require test coverage of our own.

@aaubry
Copy link
Owner

aaubry commented May 6, 2020

This is part of the work that I am doing on Schemas. Yaml 1.1 is just another shema.

@am11
Copy link
Contributor Author

am11 commented May 7, 2020

It is a little bit more involved. Our standard parser (Parser.cs) is tokenizing <<: indicator exactly as the other frameworks with full merge key type support, so we do not need MergingParser.cs for Merge Key Language-Independent Type. Perhaps we can consider deprecating MergingParser altogether right away to avoid confusion.

However, it is the responsibility of deserializer, to merge and override values by the spec.
Currently we do not have alias support in JSON emitter:

public override void Emit(AliasEventInfo eventInfo, IEmitter emitter)
{
throw new NotSupportedException("Aliases are not supported in JSON");
}

so it is not easy to visualize the feature parity of Merge Key type. (I did not find any issue tracking it, should we open one?)

The end to end expectation for this example input:

x:
  y: &anchor1
    name: yy
    env:
      a: "a1"
      b: $b
  z:
    <<: *anchor1
    name: zz
    env:
      c: "cc"
      a: "az1"
      b: $b

is:

{
   "x": {
      "y": {
         "name": "yy",
         "env": {
            "a": "a1",
            "b": "$b"
         }
      },
      "z": {
         "name": "zz",
         "env": {
            "c": "cc",
            "a": "az1",
            "b": "$b"
         }
      }
   }
}

In other words, this program should not throw runtime exception: https://dotnetfiddle.net/rk9eWv and output the JSON as shown above.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants