【问题标题】:More than one reference to a defined response object in swagger 2.0对 swagger 2.0 中定义的响应对象的多个引用
【发布时间】:2015-01-07 21:35:28
【问题描述】:

我正在使用 swagger 2.0。我在“定义”中定义了一个名为“mobilePrice”的响应对象。 我有另一个名为“Offer”的响应对象,它具有引用“mobilePrice”的属性“PriceOne”和“PriceTwo”。 代码如下所示:

"mobilePrice": {
  "properties": {
    "amount": {
      "type": "string"
     }
   }
}
"Offer": {
  "properties": {
     "PriceOne": {
       "$ref": "mobilePrice"
      },
      "PriceTwo": {
       "$ref": "mobilePrice"
      }
   }
}

当我尝试在 swagger UI 上看到它时。它根本没有向我显示“PriceTwo”属性。 在尝试各种事情时,我认为问题是由于响应对象“mobilePrice”被多次引用而发生的。谁能帮我允许多次引用同一个对象。

提前谢谢你

【问题讨论】:

    标签: swagger


    【解决方案1】:

    首先,您应该修正您的参考资料。它可能不起作用,但官方认为这不是正确的方法,并且可能会放弃对它的支持。正确的形式是:

    "$ref": "#/definitions/mobilePrice"
    

    其次,您描述的行为是一个已知问题。你可以在这里关注它的进展 - https://github.com/swagger-api/swagger-js/issues/186

    【讨论】:

      猜你喜欢
      • 2019-10-28
      • 2016-12-24
      • 2017-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-11-22
      • 2020-10-28
      相关资源
      最近更新 更多