0

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"
     }
   ]
}
Daria
  • 43
  • 6
  • *I want to send object without module name because "module name" + "identityref name" leads to mix metadata and instance.* This is not true. Module name prefix is not metadata - it is a part of the lexical representation of an identityref value in JSON. In fact, if the containing leaf (its type) and the identity that defines the used value are defined in two different modules (and they often are) the prefix becomes mandatory. OTOH, if all your definitions are defined within the same module and the API you are using is still throwing exceptions, you should report a bug to its maker. – predi Dec 03 '18 at 07:47
  • Ok, but if other json nodes can be send without module name, why identityref cannot be get around this? Is exist some way to avoid use them? Do you know any communities where can I also ask this question? Thank you. – Daria Dec 03 '18 at 08:54
  • You can get an answer to the first question by reading [RFC7951, Section 6.8](https://tools.ietf.org/html/rfc7951#section-6.8). Since I do not use ODL, I cannot answer your other questions, sorry. – predi Dec 03 '18 at 09:22

0 Answers0