[英]How to load JSDs from multiple sources and create a java schema object?
I have a JSD named SampleRequestMessage.jsd . 我有一个名为SampleRequestMessage.jsd的JSD。 In this jsd i have a reference to another jsd SampleRequestMessageProperties.jsd as shown below
在这个jsd中,我引用了另一个jsd SampleRequestMessageProperties.jsd,如下所示
{
"$schema": "http://json-schema.org/draft-04/schema#",
"javaName": "SampleConfigureNodeRequestMessage",
"description": "This message comes from sample-paqx and gets translated into Southbound version of this message",
"_meta": {
"message":"com.dell.cpsd.sample.configure.node.request",
"version":"1.0"
},
"type" : "object",
"id" : "**SampleRequestMessage.jsd**",
"properties" : {
"messageProperties" : {
"type" : "object",
"$ref" : "**SampleRequestMessageProperties.jsd**"
},
"endpointURL" : {
"type" : "string"
},
"userName" : {
"type" : "string"
},
"password" : {
"type" : "string"
}
},
"required":[
"messageProperties",
"endpointURL",
"userName",
"password"
]
}
I want the Schema object of this JSD so that I can validate it against a JSON. 我想要此JSD的Schema对象,以便可以针对JSON对其进行验证。 Now how can I load all the references of the Parent JSD.In this case it is SampleRequestMessageProperties.jsd.
现在如何加载父JSD的所有引用。在本例中为SampleRequestMessageProperties.jsd。 This JSD is pulled from one of the dependency jars.
此JSD是从其中一个依赖项jar中提取的。 I may have to pull the referenced JSDs from multiple folders and create a Schema object for parent JSD.
我可能不得不从多个文件夹中提取引用的JSD,并为父JSD创建一个Schema对象。 How can I do this?
我怎样才能做到这一点? Please help
请帮忙
You could do it like this: 您可以这样做:
{
"$schema": "http://json-schema.org/draft-04/schema#",
"javaName": "SampleConfigureNodeRequestMessage",
"description": "This message comes from sample-paqx and gets translated into Southbound version of this message",
"_meta": {
"message":"com.dell.cpsd.sample.configure.node.request",
"version":"1.0"
},"definitions": {
"SampleRequestMessage": {
"type": "object",
"properties": {
"test": { "type": "string" }
},
"required": ["test"]
}
},
"type" : "object",
"properties" : {
"messageProperties" : {"$ref": "#/definitions/SampleRequestMessage"
},
"endpointURL" : {
"type" : "string"
},
"userName" : {
"type" : "string"
},
"password" : {
"type" : "string"
}
},
"required":[
"messageProperties",
"endpointURL",
"userName",
"password"
]
}
This would validate the following json. 这将验证以下json。
{
"messageProperties": {"test": "hello"},
"endpointURL": "test.com",
"userName": "test",
"password": "secret"
}
}
The definitions can also be in a external file. 定义也可以在外部文件中。 For more infos: refer json schmea
有关更多信息: 请参阅json schmea
Hope this helps 希望这可以帮助
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.