我如何引用一个模型使用AWS API网关另一种模式
问题描述:
说我有一个型号:我如何引用一个模型使用AWS API网关另一种模式
"Pet":{
"type": "object"
"properties": {
"name":{"type":"integer"},
"age":{"type":"integer"}
}
}
而另一种模式:
"Human":{
"type": "object"
"properties": {
"name":{"type":"integer"},
"age":{"type":"integer"},
"pets":{
"type":"array"
"items": {
<This is where my question is>
}
}
}
}
如何可以引用宠物模型在我的人模型?
随着招摇,我能够说:
"$ref": "#/definitions/Pet"
但API网关似乎不答应。
答
如果你的意思是外面招摇参考模型,你可以做,通过与绝对URL指定如下面
{"type":"array","items":{"$ref":"https://apigateway.amazonaws.com/restapis/<rest_api_id>/models/Pet"}}
对于招摇的模式,从开放API规范这个例子说明如何招摇内参考模型 - https://github.com/OAI/OpenAPI-Specification/blob/master/examples/v2.0/json/petstore.json
"Pets": {
"type": "array",
"items": {
"$ref": "#/definitions/Pet"
}
注意,API网关不支持“默认”的反应,因此,如果您尝试导入上述petstore.json例子,你需要删除“默认”字段。
这是第一篇文章,它实际上注意到AWS是一个外部服务,而招摇的路线是内部的..最后!!!!你有我的祝福:) – ymz