我有一个名为SampleRequestMessage.jsd的JSD。在这个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"
]
}
我想要这个JSD的Schema对象,以便我可以针对JSON验证它。现在我如何加载Parent JSD的所有引用。在这种情况下,它是SampleRequestMessageProperties.jsd。这个JSD是从一个依赖jar中提取的。我可能必须从多个文件夹中提取引用的JSD并为父JSD创建一个Schema对象。我怎样才能做到这一点?请帮忙
答案 0 :(得分:0)
你可以这样做:
{
"$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"
]
}
这将验证以下json。
{
"messageProperties": {"test": "hello"},
"endpointURL": "test.com",
"userName": "test",
"password": "secret"
}
}
定义也可以在外部文件中。如需更多信息:refer json schmea
希望这有帮助