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

痴心易碎 提交于 2019-12-13 03:22:54

问题


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"
			  }
			]
}

来源:https://stackoverflow.com/questions/53560965/how-to-exclude-module-name-in-leaf-value-of-identityref-during-odl-validation

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!