Skip to content

YAML anchors and aliases not being recognised with loadYaml function #2218

@ljmatan

Description

@ljmatan

If YAML anchors or aliases are introduced to a .yaml file, they won't be parsed when using the loadYaml method. Instead, null will be displayed.

Example:

import 'package:yaml/yaml.dart';

void main() {
  // YAML with an anchor and an alias
  const yamlText = '''
enums:
  - &ServerEnvironment
    name: ServerEnvironment
    description: "Test enum"

methods:
  - name: initialise
    fields:
      - name: environment
        type: *ServerEnvironment
''';

  // Parse YAML
  final doc = loadYaml(yamlText);

  // Access alias
  final typeField = doc['methods'][0]['fields'][0]['type'];

  print('typeField: $typeField'); // Expected: full map of enum, Actual: null
}

Metadata

Metadata

Assignees

No one assigned

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions