Skip to content

Validating yang structure data #2403

@ahassany

Description

@ahassany

I've tried to validate the example in RFC 8791 using yanglint but without a success, is yang structures fully supported for data and schema or schema only?

This the examples I tried:

module example-module {
  yang-version 1.1;
  namespace "urn:example:example-module";
  prefix exm;

  import ietf-yang-structure-ext {
    prefix sx;
  }

  sx:structure address-book {
    list address {
      key "last first";
      leaf last {
        type string;
      }
      leaf first {
        type string;
      }
      leaf street {
        type string;
      }
      leaf city {
        type string;
      }
      leaf state {
        type string;
      }
    }
  }
}

and input data:

{
  "example-module:address-book": {
    "example-module:address": [
      {
        "city": "Bedrock",
        "example-module-aug:zipcode": "70777",
        "first": "Fred",
        "last": "Flintstone",
        "street": "301 Cobblestone Way"
      },
      {
        "city": "Bedrock",
        "example-module-aug:zipcode": "70777",
        "first": "Charlie",
        "last": "Root",
        "street": "4711 Cobblestone Way"
      }
    ]
  }
}

witht the command:

yanglint  example-module.yang  example.json -f json

libyang err : Node "address-book" not found in the "example-module" module. (line 2)
YANGLINT[E]: Failed to parse input data file "example.json".

Metadata

Metadata

Assignees

No one assigned

    Labels

    is:enhancementRequest for adding new feature or enahncing functionality.status:completedFrom the developer perspective, the issue was solved (bug fixed, question answered,...)

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions