1) 编写 RAML 时,我可以在模式定义中使用嵌套吗?
例如:
schemas:
- DNSResponse: |
{
"type": "object",
"properties": {
"AnswerSection": {
"type": "array",
"items": (((I want a re-useable schema here. ex: ARecord)))
},
"AA": {"type": "boolean"},
"AD": {"type": "boolean"},
...
}
}
- ARecord: |
{
"type": "object",
"properties": {
"address": "string",
"ttl": "number",
"name": "string"
}
}
2)我可以在一组可嵌套模式周围使用选择/枚举吗?
"items": [ARecord, MXRecord, PTRRecord, ...]
1)是的,可以。看这个例子 https://github.com/mulesoft/raml-for-jax-rs/blob/master/raml-to-jaxrs/examples/jersey-example/src/main/resources/raml/sales-enablement-api.raml。那将是:
"items": { "$ref": "ARecord" }
2) 我相信这在 JSON Schema 的草案 4 中是可能的,使用oneOf http://json-schema.org/latest/json-schema-validation.html#anchor88指示。但我认为 RAML 不支持这一点。或者,您可以创建一个基本架构,并让 ARecord、MXRecord 和 PTRRecord 扩展此基本架构,然后允许基本架构的项目。这在语义上不会很丰富,但可以帮助您入门。
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)