Api-blueprint: 可空类型在方法声明中不起作用

创建于 2016-04-13  ·  3评论  ·  资料来源: apiaryio/api-blueprint

我正在尝试在文档中的示例之后在我的 mson 中使用可空类型,但它因语义错误而失败。

请帮我弄清楚我的 mson 有什么问题以及如何为我的用例制作正确的文档?

谢谢!

Apiary.io Question

最有用的评论

我只想指出,它现在已经部署到 Apiary(没有测试版)。

例如,您可以使用 nullable,如下所示:

+ Response 200 (application/json)
    + Attributes
        + example1 (string, optional, nullable) - An example optional nullable string
        + example2: value (string, optional, nullable) - An example optional nullable string with a sample value

这将导致以下示例有效负载:

{
  "example1": null,
  "example2": "value"
}

连同以下 JSON 模式:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "example1": {
      "type": [
        "string",
        "null"
      ],
      "description": "An example optional nullable string"
    },
    "example2": {
      "type": [
        "string",
        "null"
      ],
      "description": "An example optional nullable string with a sample value"
    }
  }
}

Apiary 中的属性表

screen shot 2016-06-20 at 17 46 45

所有3条评论

@danilvalov嗨,Apiary 没有使用最新版本的 API Blueprint Parser,它增加了对可空性的支持。

Apiary 确实有一个用于改进属性呈现的测试版,其中包括对可空性的支持。 您可以在https://github.com/apiaryio/api-blueprint/issues/191#issuecomment -178044764 上找到有关测试版的更多信息以及如何加入它。

问候,

凯尔

我只想指出,它现在已经部署到 Apiary(没有测试版)。

例如,您可以使用 nullable,如下所示:

+ Response 200 (application/json)
    + Attributes
        + example1 (string, optional, nullable) - An example optional nullable string
        + example2: value (string, optional, nullable) - An example optional nullable string with a sample value

这将导致以下示例有效负载:

{
  "example1": null,
  "example2": "value"
}

连同以下 JSON 模式:

{
  "$schema": "http://json-schema.org/draft-04/schema#",
  "type": "object",
  "properties": {
    "example1": {
      "type": [
        "string",
        "null"
      ],
      "description": "An example optional nullable string"
    },
    "example2": {
      "type": [
        "string",
        "null"
      ],
      "description": "An example optional nullable string with a sample value"
    }
  }
}

Apiary 中的属性表

screen shot 2016-06-20 at 17 46 45

这现在在ApiaryUI 中可见:
image

此页面是否有帮助?
0 / 5 - 0 等级

相关问题

fh-thudson picture fh-thudson  ·  3评论

zatziky picture zatziky  ·  4评论

robbinjanssen picture robbinjanssen  ·  6评论

mootpointer picture mootpointer  ·  4评论

Perni1984 picture Perni1984  ·  6评论