How to exclude module name in leaf value of Identityref during ODL validation?

247 views Asked by At

I have YANG model and JSON object which will be verified by ODL (see bellow).

I need to exclude module name from JSON to verify.

When I exclude module name from identityref ("type": "center-car-sale-type:sedan") and send only identityref name ("type": "sedan") ODL throw exception that this identityref is not found.

I want to send object without module name because "module name" + "identityref name" leads to mix metadata and instance.

How can I set up ODL validation to avoid module name in leaf value for identityref?

I parse JSON by JsonParserStream.parse(JsonReader) from org.opendaylight.yangtools.yang.data.codec.gson module.

Thank you in advance!

YANG model:

identity car-type {
    description
      "Car type.";
  }

  identity sedan {
    base car-type;
  }
  identity minivan {
    base car-type;
  }

grouping car {
    uses main-properties;
    leaf type {
      type identityref {
        base car-type;
      }
 }  
 leaf max-speed {
      type string;
 }
} 
grouping main-properties {
    leaf id {
      type string;
 }  
 leaf name {
      type string;
 } 
}
 
list car {
 uses car;
 key "id";
}

JSON:

{
 "car": [
     {
    "id": "1",
    "name": "Toyota",
    "description": "Toyota car",
    "type": "center-car-sale-type:sedan",
    "max-speed": "300"
     },
     {
    "id": "2",
    "name": "Honda",
    "description": "Honda car",
    "type": "center-car-sale-type:minivan",
    "max-speed": "250"
     }
   ]
}

0

There are 0 answers